name: Changes on: workflow_dispatch: workflow_call: inputs: runner: required: true type: string reference: required: true type: string packagesrepo: required: false type: string jobs: Prepare: runs-on: Linux name: Source changes if: ${{ github.repository_owner == 'Armbian' }} steps: - name: Runner prepare uses: armbian/actions/runner-prepare@main # we are comparing hash on subdirs so we need full clone - name: Checkout repository uses: actions/checkout@v3.1.0 with: fetch-depth: 0 repository: armbian/build path: build ref: ${{ inputs.reference }} clean: true - name: Checkout support scripts uses: actions/checkout@v3.1.0 with: fetch-depth: 0 repository: armbian/scripts path: scripts ref: master clean: true - name: Remove previous artefacts if any run: | printenv > 2.txt sudo rm -rf changes 2>/dev/null || true - name: Determine changed kernels run: | PACKAGESREPO=${{ inputs.packagesrepo }} BETA=${PACKAGESREPO:-yes} # Declare this folder as safe if [[ -z $(cat ${HOME}/.gitconfig 2>/dev/null | grep "directory = \*") ]]; then git config --global --add safe.directory "*" fi # fake function enable_extension () { return 0 } VALUES="legacy current edge" # [[ "$BETA" == no ]] && VALUES="legacy current" MATRIX=$(for BRANCH in $VALUES; do FILES=$(cat build/config/targets*.conf | grep $BRANCH | grep -v "^$" | grep -v "^#" | sed -n $LINE'p' | cut -d " " -f1 | uniq) while IFS= read -r line; do unset LINUXFAMILY KERNELPATCHDIR LINUXCONFIG KERNELSOURCE KERNEL_VERSION_LEVEL KERNELSWITCHOBJ BOARDFAMILY=$(cat build/config/boards/$line.* | grep BOARDFAMILY | cut -d'"' -f2) BOARD=$line source build/config/boards/$line.conf 2> /dev/null || true source build/config/boards/$line.wip 2> /dev/null || true source build/config/sources/families/${BOARDFAMILY}.conf 2> /dev/null || true # exceptions handling [[ ${BOARDFAMILY} == *x86 ]] && BOARDFAMILY=x86 [[ ${BOARDFAMILY} == *arm64 ]] && BOARDFAMILY=arm64 [[ ${BOARDFAMILY} == sun*i ]] && BOARDFAMILY=sunxi [[ ${BOARDFAMILY} == sun8i-v3s ]] && BOARDFAMILY=sunxi [[ ${BOARDFAMILY} == sun*iw* && ${BRANCH} != legacy ]] && BOARDFAMILY=sunxi64 [[ ${BOARDFAMILY} == meson8b ]] && BOARDFAMILY=meson [[ ${BOARDFAMILY} == meson-* || ${BOARDFAMILY} == jethub ]] && BOARDFAMILY=meson64 [[ ${BOARDFAMILY} == rk35xx && ${BRANCH} != legacy ]] && BOARDFAMILY=rockchip64 [[ ${BOARDFAMILY} == rk3399 && ${BRANCH} != legacy ]] && BOARDFAMILY=rockchip64 [[ ${BOARDFAMILY} == jetson-nano && ${BRANCH} != legacy ]] && BOARDFAMILY=media [[ ${BOARDFAMILY} == media && ${BRANCH} == legacy ]] && BOARDFAMILY=station-p2 [[ ${BOARDFAMILY} == rockpis && ${BRANCH} != legacy ]] && BOARDFAMILY=rockchip64 [[ ${BOARDFAMILY} == bcm2711 && ${BRANCH} == legacy ]] && continue #[[ -n "${KERNELSWITCHOBJ}" ]] && KERNELBRANCH=${KERNELSWITCHOBJ/=/:} ref_type=${KERNELBRANCH%%:*} if [[ $ref_type == head ]]; then ref_name=HEAD else ref_name=${KERNELBRANCH##*:} fi [[ -z ${LINUXFAMILY} ]] && LINUXFAMILY=$BOARDFAMILY [[ -z ${KERNELPATCHDIR} ]] && KERNELPATCHDIR=$LINUXFAMILY-$BRANCH [[ -z ${LINUXCONFIG} ]] && LINUXCONFIG=linux-$LINUXFAMILY-$BRANCH [[ -z ${KERNELSOURCE} ]] && KERNELSOURCE="https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable" case $ref_type in branch) CALC_HASH=$(git ls-remote "${KERNELSOURCE}" refs/heads/"${ref_name}" 2> /dev/null | awk '{print $1}') ;; tag) CALC_HASH=$(git ls-remote "${KERNELSOURCE}" tags/"${ref_name}" 2> /dev/null | awk '{print $1}') ;; head) CALC_HASH=$(git ls-remote "${KERNELSOURCE}" HEAD 2> /dev/null | awk '{print $1}') ;; commit) CALC_HASH=$ref_name ;; esac SRC="$(pwd)/build" CALC_PATCHES=$(git -C $SRC log --format="%H" -1 -- $(realpath --relative-base="$SRC" "${SRC}/patch/kernel/${KERNELPATCHDIR}")) [[ -z "$CALC_PATCHES" ]] && CALC_PATCHES="null" CALC_CONFIG=$(git -C $SRC log --format="%H" -1 -- $(realpath --relative-base="$SRC" "${SRC}/config/kernel/${LINUXCONFIG}.config")) [[ -z "$CALC_CONFIG" ]] && CALC_CONFIG="null" # ignore diff checking in case of network errrors kernel_hash="scripts/hash-beta/linux-image-${BRANCH}-${LINUXFAMILY}.githash" if [[ -f $kernel_hash ]] ; then STORED_HASH=$(sed -n '1p' < "${kernel_hash}") STORED_PATCHES=$(sed -n '2p' < "${kernel_hash}") STORED_CONFIG=$(sed -n '3p' < "${kernel_hash}") fi # if stored is null, we don't check [[ "$STORED_PATCHES" == "null" ]] && CALC_PATCHES="null" [[ "$STORED_CONFIG" == "null" ]] && CALC_CONFIG="null" # in bugfix rebuild, we rebuild all kernels (current branch only) if [[ "$BETA" == no ]]; then echo "${LINUXFAMILY}:${BOARDFAMILY}:${BRANCH}:${line}:${ARCH}" elif [[ "$CALC_HASH" == "$STORED_HASH" && "$CALC_CONFIG" == "$STORED_CONFIG" && "$CALC_PATCHES" == "$STORED_PATCHES" ]];then : else echo "${LINUXFAMILY}:${BOARDFAMILY}:${BRANCH}:${line}:${ARCH}" fi done <<< "$FILES" done | sort | uniq | sort -u -t: -k1,3 ) echo "${MATRIX}" |sed '/^$/d' > changes - name: Upload changes uses: actions/upload-artifact@v3 with: path: changes name: changes if-no-files-found: ignore