From fbad168eda5894a617452865d3348709bc236ccf Mon Sep 17 00:00:00 2001 From: Gunjan Gupta Date: Tue, 2 Jan 2024 03:49:35 +0530 Subject: [PATCH] Fix rpi image creation broken since to #6087 (#6123) * Revert "Don't generate armbian.list if when==image-early" This reverts commit 0b79ff3a6312668291b31651b20c0f3d884f947a. * Remove armbian.list.disabled file if it exists --- lib/functions/main/rootfs-image.sh | 6 +++++ lib/functions/rootfs/distro-specific.sh | 30 ++++++++++++------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/functions/main/rootfs-image.sh b/lib/functions/main/rootfs-image.sh index 25fa0d37f2..45384ace16 100644 --- a/lib/functions/main/rootfs-image.sh +++ b/lib/functions/main/rootfs-image.sh @@ -42,6 +42,12 @@ function build_rootfs_and_image() { # Deploy the full apt lists, including the Armbian repo. create_sources_list_and_deploy_repo_key "image-late" "${RELEASE}" "${SDCARD}/" + # We call this above method too many times. @TODO: find out why and fix the same + # We may have a armbian.list.disabled file lying around. Remove the same + if [[ -e "${SDCARD}"/etc/apt/sources.list.d/armbian.list.disabled ]]; then + rm "${SDCARD}"/etc/apt/sources.list.d/armbian.list.disabled + fi + # remove packages that are no longer needed. rootfs cache + uninstall might have leftovers. LOG_SECTION="apt_purge_unneeded_packages_and_clean_apt_caches" do_with_logging apt_purge_unneeded_packages_and_clean_apt_caches diff --git a/lib/functions/rootfs/distro-specific.sh b/lib/functions/rootfs/distro-specific.sh index abf44efa79..fab1baf258 100644 --- a/lib/functions/rootfs/distro-specific.sh +++ b/lib/functions/rootfs/distro-specific.sh @@ -210,24 +210,22 @@ function create_sources_list_and_deploy_repo_key() { components+=("${RELEASE}-utils") # utils contains packages Igor picks from other repos components+=("${RELEASE}-desktop") # desktop contains packages Igor picks from other repos - if [[ "${when}" != "image-early" ]]; then # only add armbian.list when==image-late - # stage: add armbian repository and install key - if [[ $DOWNLOAD_MIRROR == "china" ]]; then - echo "deb ${SIGNED_BY}https://mirrors.tuna.tsinghua.edu.cn/armbian $RELEASE ${components[*]}" > "${basedir}"/etc/apt/sources.list.d/armbian.list - elif [[ $DOWNLOAD_MIRROR == "bfsu" ]]; then - echo "deb ${SIGNED_BY}http://mirrors.bfsu.edu.cn/armbian $RELEASE ${components[*]}" > "${basedir}"/etc/apt/sources.list.d/armbian.list - else - echo "deb ${SIGNED_BY}http://$([[ $BETA == yes ]] && echo "beta" || echo "apt").armbian.com $RELEASE ${components[*]}" > "${basedir}"/etc/apt/sources.list.d/armbian.list - fi + # stage: add armbian repository and install key + if [[ $DOWNLOAD_MIRROR == "china" ]]; then + echo "deb ${SIGNED_BY}https://mirrors.tuna.tsinghua.edu.cn/armbian $RELEASE ${components[*]}" > "${basedir}"/etc/apt/sources.list.d/armbian.list + elif [[ $DOWNLOAD_MIRROR == "bfsu" ]]; then + echo "deb ${SIGNED_BY}http://mirrors.bfsu.edu.cn/armbian $RELEASE ${components[*]}" > "${basedir}"/etc/apt/sources.list.d/armbian.list + else + echo "deb ${SIGNED_BY}http://$([[ $BETA == yes ]] && echo "beta" || echo "apt").armbian.com $RELEASE ${components[*]}" > "${basedir}"/etc/apt/sources.list.d/armbian.list + fi - # replace local package server if defined. Suitable for development - [[ -n $LOCAL_MIRROR ]] && echo "deb ${SIGNED_BY}http://$LOCAL_MIRROR $RELEASE ${components[*]}" > "${basedir}"/etc/apt/sources.list.d/armbian.list + # replace local package server if defined. Suitable for development + [[ -n $LOCAL_MIRROR ]] && echo "deb ${SIGNED_BY}http://$LOCAL_MIRROR $RELEASE ${components[*]}" > "${basedir}"/etc/apt/sources.list.d/armbian.list - # disable repo if SKIP_ARMBIAN_REPO==yes, or if when==image-early. - if [[ "${SKIP_ARMBIAN_REPO}" == "yes" ]]; then - display_alert "Disabling Armbian repo" "${ARCH}-${RELEASE} :: skip:${SKIP_ARMBIAN_REPO:-"no"} when:${when}" "info" - mv "${SDCARD}"/etc/apt/sources.list.d/armbian.list "${SDCARD}"/etc/apt/sources.list.d/armbian.list.disabled - fi + # disable repo if SKIP_ARMBIAN_REPO==yes, or if when==image-early. + if [[ "${when}" == "image-early" || "${SKIP_ARMBIAN_REPO}" == "yes" ]]; then + display_alert "Disabling Armbian repo" "${ARCH}-${RELEASE} :: skip:${SKIP_ARMBIAN_REPO:-"no"} when:${when}" "info" + mv "${SDCARD}"/etc/apt/sources.list.d/armbian.list "${SDCARD}"/etc/apt/sources.list.d/armbian.list.disabled fi declare CUSTOM_REPO_WHEN="${when}"