diff --git a/.github/workflows/nic-integrity.yml b/.github/workflows/nic-integrity.yml new file mode 100644 index 0000000..8d80b40 --- /dev/null +++ b/.github/workflows/nic-integrity.yml @@ -0,0 +1,28 @@ +name: NIC Integrity + +on: + push: + +jobs: + check: + runs-on: ubuntu-latest + env: + THEOS: ${{ github.workspace }}/theos + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: recursive + path: templates + + - name: Checkout theos/theos + uses: actions/checkout@v4 + with: + repository: theos/theos + submodules: recursive + path: ${{ env.THEOS }} + + - name: Check + run: | + cd templates + ./integrity_check.sh diff --git a/integrity_check.sh b/integrity_check.sh new file mode 100755 index 0000000..ee79cf5 --- /dev/null +++ b/integrity_check.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -e + +WORKSPACE_DIR=$(mktemp -d --tmpdir='' "templates.XXXXXXXXXX") +TEMPLATES_DIR=$(pwd) + +# For each directory containing a valid NIC templates' source +TEMPLATES_SOURCES=$(find "${TEMPLATES_DIR}" -type d -name NIC -exec dirname {} \;) + +cd "${WORKSPACE_DIR}" + +EXIT_CODE=0 + +for TEMPLATES_SOURCE in $TEMPLATES_SOURCES; do + "${THEOS}/bin/nicify.pl" "${TEMPLATES_SOURCE}" 2> /dev/null + RESULT_FILE=$(ls *.nic.tar) + EXTRACT_DIR=$(mktemp -d -p . "${RESULT_FILE}.XXXXXXXXXX") + tar -xf "${TEMPLATES_DIR}/${RESULT_FILE}" -C "${EXTRACT_DIR}" + # thanks to https://stackoverflow.com/a/49633090 + if ! diff -r --no-dereference --brief -x '.keep' "${TEMPLATES_SOURCE}" "${EXTRACT_DIR}"; then + EXIT_CODE=1 + # per https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables + if [[ "${GITHUB_ACTIONS}" = "true" ]]; then + # per https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message + echo "::error file=${RESULT_FILE},title=Mismatch::The NIC file does not match the template directory" + fi + fi + rm -r "${EXTRACT_DIR}" + rm "${RESULT_FILE}" +done + +rm -r "${WORKSPACE_DIR}" + +exit "${EXIT_CODE}" diff --git a/iphone_preference_bundle.nic.tar b/iphone_preference_bundle.nic.tar index 80fe5cc..77e5257 100644 Binary files a/iphone_preference_bundle.nic.tar and b/iphone_preference_bundle.nic.tar differ