From 07d7d1a077fc4bce51cedad33ffef964e9a199dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Pe=C4=8Dovnik?= Date: Sun, 31 Jul 2022 11:28:44 +0200 Subject: [PATCH] Remove deprecated functionality (#4034) * Remove deprecated functionality Since we are storing version number outside, we don't neet to deal with month cache rebuild here. Removing the code * Change cron to more appropriate date We tend to make releases by the end of the month, so cache rebuild in the middle is better then at the start of the month --- .github/workflows/update-cache.yml | 12 ++--- lib/debootstrap.sh | 85 ++++++++++++------------------ 2 files changed, 41 insertions(+), 56 deletions(-) diff --git a/.github/workflows/update-cache.yml b/.github/workflows/update-cache.yml index df3fc29dce..ce030baed5 100644 --- a/.github/workflows/update-cache.yml +++ b/.github/workflows/update-cache.yml @@ -8,8 +8,8 @@ name: Build Rootfs Cache on: schedule: - - cron: "30 0 1 * *" # Runs at 00:30 UTC on the 1st of every month. - + - cron: "30 0 15 * *" # Runs at 00:30 UTC on the 15st of every month. + push: branches: - 'master' @@ -36,7 +36,7 @@ jobs: rootfscache_version: ${{ steps.env-vars.outputs.rootfscache_version }} if: ${{ github.repository_owner == 'Armbian' }} steps: - + # Synyching procedure expects this value - run: | echo "not empty" > changes @@ -59,7 +59,7 @@ jobs: sudo mountpoint -q build/cache/rootfs.upload && sudo fusermount -u build/cache/rootfs.upload || true sudo apt-get -y -qq install sshfs sudo mkdir -p build/cache/rootfs.upload || true - + # locally mount via NFS if [[ $(curl -s http://ifconfig.me) == "93.103.15.56" ]]; then sudo mount nas:/tank/armbian/users.armbian.com/upload/rootfs build/cache/rootfs.upload @@ -74,7 +74,7 @@ jobs: - id: env-vars name: Read current version run: | - + ROOTFSCACHE_VERSION=$(wget --tries=10 -O - -o /dev/null https://github.com/armbian/mirror/releases/download/rootfs/rootfscache.version || true) ROOTFSCACHE_VERSION=$(( ${ROOTFSCACHE_VERSION:-"0"} + 1 )) echo "${ROOTFSCACHE_VERSION}" @@ -362,7 +362,7 @@ jobs: sudo apt-get -y -qq install parallel buildtorrent ANNOUNCE=$(cat trackerslist/trackers_best_ip.txt | head -1)ANNOUNCE=$(cat trackerslist/trackers_best_ip.txt | sed '/^$/d' | shuf -n 1) - TRACKERS=$(cat trackerslist/trackers_all.txt | sed '/^\s*$/d' | while read line; do printf ",""${line}"; done | cut -c 2-) + TRACKERS=$(cat trackerslist/trackers_all.txt | sed '/^\s*$/d' | while read line; do printf ",""${line}"; done | cut -c 2-) WEBSEEDS="--webseeds="https://github.com/armbian/mirror/releases/download/rootfs/\$FILE,"$(curl -s https://cache.armbian.com/mirrors | jq -r '.'default' | .[] | values' | sed -e 's/$/rootfs\/$FILE/' | tr '\n' , | sed 's/.$//')" cd build/cache/rootfs.upload diff --git a/lib/debootstrap.sh b/lib/debootstrap.sh index c2ab2376d6..a79dc4c6ad 100644 --- a/lib/debootstrap.sh +++ b/lib/debootstrap.sh @@ -119,60 +119,45 @@ PRE_INSTALL_DISTRIBUTION_SPECIFIC # create_rootfs_cache() { - if [[ "$ROOT_FS_CREATE_ONLY" == "force" ]]; then - local cycles=1 - else - local cycles=2 + + + local packages_hash=$(get_package_list_hash "$ROOTFSCACHE_VERSION") + local cache_type="cli" + [[ ${BUILD_DESKTOP} == yes ]] && local cache_type="xfce-desktop" + [[ -n ${DESKTOP_ENVIRONMENT} ]] && local cache_type="${DESKTOP_ENVIRONMENT}" + [[ ${BUILD_MINIMAL} == yes ]] && local cache_type="minimal" + local cache_name=${RELEASE}-${cache_type}-${ARCH}.$packages_hash.tar.lz4 + local cache_fname=${SRC}/cache/rootfs/${cache_name} + local display_name=${RELEASE}-${cache_type}-${ARCH}.${packages_hash:0:3}...${packages_hash:29}.tar.lz4 + + [[ "$ROOT_FS_CREATE_ONLY" == force ]] && break + + if [[ -f ${cache_fname} && -f ${cache_fname}.aria2 ]]; then + rm ${cache_fname}* + display_alert "Partially downloaded file. Re-start." + download_and_verify "_rootfs" "$cache_name" fi - # seek last cache, proceed to previous otherwise build it - for ((n=0;n<${cycles};n++)); do + display_alert "Checking local cache" "$display_name" "info" - FORCED_MONTH_OFFSET=${n} - - local packages_hash=$(get_package_list_hash "$(date -d "$D -${FORCED_MONTH_OFFSET} month" +"%Y-%m-module$ROOTFSCACHE_VERSION" | sed 's/^0*//')") - local cache_type="cli" - [[ ${BUILD_DESKTOP} == yes ]] && local cache_type="xfce-desktop" - [[ -n ${DESKTOP_ENVIRONMENT} ]] && local cache_type="${DESKTOP_ENVIRONMENT}" - [[ ${BUILD_MINIMAL} == yes ]] && local cache_type="minimal" - local cache_name=${RELEASE}-${cache_type}-${ARCH}.$packages_hash.tar.lz4 - local cache_fname=${SRC}/cache/rootfs/${cache_name} - local display_name=${RELEASE}-${cache_type}-${ARCH}.${packages_hash:0:3}...${packages_hash:29}.tar.lz4 - - [[ "$ROOT_FS_CREATE_ONLY" == force ]] && break - - if [[ -f ${cache_fname} && -f ${cache_fname}.aria2 ]]; then - rm ${cache_fname}* - display_alert "Partially downloaded file. Re-start." - download_and_verify "_rootfs" "$cache_name" + if [[ -f ${cache_fname} && -n "$ROOT_FS_CREATE_ONLY" ]]; then + echo "$cache_fname" > $cache_fname.current + display_alert "Checking cache integrity" "$display_name" "info" + sudo lz4 -tqq ${cache_fname} + [[ $? -ne 0 ]] && rm $cache_fname && exit_with_error "Cache $cache_fname is corrupted and was deleted. Please restart!" + # sign if signature is missing + if [[ -n "${GPG_PASS}" && "${SUDO_USER}" && ! -f ${cache_fname}.asc ]]; then + [[ -n ${SUDO_USER} ]] && sudo chown -R ${SUDO_USER}:${SUDO_USER} "${DEST}"/images/ + echo "${GPG_PASS}" | sudo -H -u ${SUDO_USER} bash -c "gpg --passphrase-fd 0 --armor --detach-sign --pinentry-mode loopback --batch --yes ${cache_fname}" || exit 1 fi - - display_alert "Checking local cache" "$display_name" "info" - - if [[ -f ${cache_fname} && -n "$ROOT_FS_CREATE_ONLY" ]]; then - echo "$cache_fname" > $cache_fname.current - display_alert "Checking cache integrity" "$display_name" "info" - sudo lz4 -tqq ${cache_fname} - [[ $? -ne 0 ]] && rm $cache_fname && exit_with_error "Cache $cache_fname is corrupted and was deleted. Please restart!" - # sign if signature is missing - if [[ -n "${GPG_PASS}" && "${SUDO_USER}" && ! -f ${cache_fname}.asc ]]; then - [[ -n ${SUDO_USER} ]] && sudo chown -R ${SUDO_USER}:${SUDO_USER} "${DEST}"/images/ - echo "${GPG_PASS}" | sudo -H -u ${SUDO_USER} bash -c "gpg --passphrase-fd 0 --armor --detach-sign --pinentry-mode loopback --batch --yes ${cache_fname}" || exit 1 - fi - break - elif [[ -f ${cache_fname} ]]; then - break - else - display_alert "searching on servers" - download_and_verify "_rootfs" "$cache_name" - [[ -f ${cache_fname} ]] && break - fi - - if [[ ! -f $cache_fname ]]; then - display_alert "not found: try to use previous cache" - fi - - done + break + elif [[ -f ${cache_fname} ]]; then + break + else + display_alert "searching on servers" + download_and_verify "_rootfs" "$cache_name" + [[ -f ${cache_fname} ]] && break + fi if [[ -f $cache_fname && ! -f $cache_fname.aria2 ]]; then