mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
include (clean/real) apt lists in built images; update xapian index during image build, not rootfs; don't leave junk in the rootfs cache
- revert #5139 Revert "Apt lists is needed for synpatic index generation"
This reverts commit 63e9bd3baa
- this actually only left junk in rootfs cache for the future to find
This commit is contained in:
@@ -42,6 +42,16 @@ function build_rootfs_and_image() {
|
||||
# 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
|
||||
|
||||
# for IMAGES (not the rootfs cache!), we wanna ship a valid /var/lib/apt/lists.
|
||||
# copy it over from the host-side cache into the image, and run a final apt-get update+clean, to clean off what is not needed for this specific image.
|
||||
LOG_SECTION="apt_lists_copy_from_host_to_image_and_update" do_with_logging apt_lists_copy_from_host_to_image_and_update
|
||||
|
||||
# creating xapian index that synaptic runs faster
|
||||
if [[ "${BUILD_DESKTOP}" == yes ]]; then
|
||||
display_alert "Recreating Synaptic search index" "Please wait - updating Xapian index for image" "info"
|
||||
chroot_sdcard "[[ -f /usr/sbin/update-apt-xapian-index ]] && /usr/sbin/update-apt-xapian-index -u"
|
||||
fi
|
||||
|
||||
# for reference, debugging / sanity checking
|
||||
LOG_SECTION="list_installed_packages" do_with_logging list_installed_packages
|
||||
|
||||
|
||||
@@ -50,6 +50,32 @@ function apt_purge_unneeded_packages_and_clean_apt_caches() {
|
||||
wait_for_disk_sync "after cleaning ${SDCARD}${dir_var_lib_apt_lists}"
|
||||
}
|
||||
|
||||
function apt_lists_copy_from_host_to_image_and_update() {
|
||||
display_alert "Copying host-side apt list cache into image" "apt-get update and clean image-side" "info"
|
||||
|
||||
declare -i local_apt_cache_lists_count
|
||||
if [[ "${LOCAL_APT_CACHE_INFO[USE]}" == "yes" ]]; then
|
||||
# If using a host-side local cache, copy the lists into the image...
|
||||
run_host_command_logged mkdir -pv "${LOCAL_APT_CACHE_INFO[SDCARD_LISTS_DIR]}"
|
||||
display_alert "Copying host-side local apt list cache dir" "${LOCAL_APT_CACHE_INFO[SDCARD_LISTS_DIR]}" "debug"
|
||||
run_host_command_logged cp -pr "${LOCAL_APT_CACHE_INFO[HOST_LISTS_DIR]}"/* "${LOCAL_APT_CACHE_INFO[SDCARD_LISTS_DIR]}"/
|
||||
|
||||
# Count how many files we have in the lists dir.
|
||||
local_apt_cache_lists_count="$(ls -1 "${LOCAL_APT_CACHE_INFO[SDCARD_LISTS_DIR]}" | wc -l)"
|
||||
display_alert "After copying host-side cache into image" "${local_apt_cache_lists_count} files" "info"
|
||||
fi
|
||||
|
||||
# ...and update the lists in the image; this makes sure we're not shipping stale lists. also clean.
|
||||
# Attention: this is NOT using `chroot_sdcard_apt_get_update` or any `chroot_sdcard_apt_get` variant,
|
||||
# since would actually mount the lists from the host, which is not what we want.
|
||||
display_alert "Updating apt lists in image" "apt-get update and clean" "info"
|
||||
chroot_sdcard apt-get -y -o "APT::Get::List-Cleanup=1" -o "APT::Clean-Installed=1" update
|
||||
chroot_sdcard apt-get -y -o "APT::Get::List-Cleanup=1" -o "APT::Clean-Installed=1" clean
|
||||
|
||||
local_apt_cache_lists_count="$(ls -1 "${LOCAL_APT_CACHE_INFO[SDCARD_LISTS_DIR]}" | wc -l)"
|
||||
display_alert "After updating and cleaning image apt list cache" "${local_apt_cache_lists_count} files" "info"
|
||||
}
|
||||
|
||||
# this is called:
|
||||
# 1) install_deb_chroot "${DEB_STORAGE}/somethingsomething.deb" (yes, it's always ${DEB_STORAGE})
|
||||
function install_deb_chroot() {
|
||||
@@ -81,7 +107,7 @@ function install_deb_chroot() {
|
||||
# install in chroot via apt-get, not dpkg, so dependencies are also installed from repo if needed.
|
||||
declare -g if_error_detail_message="Installation of $install_target failed ${BOARD} ${RELEASE} ${BUILD_DESKTOP} ${LINUXFAMILY}"
|
||||
declare -a extra_apt_envs=()
|
||||
extra_apt_envs+=("ARMBIAN_IMAGE_BUILD_BOOTFS_TYPE=${BOOTFS_TYPE:-"unset"}") # used by package postinst scripts to bevahe
|
||||
extra_apt_envs+=("ARMBIAN_IMAGE_BUILD_BOOTFS_TYPE=${BOOTFS_TYPE:-"unset"}") # used by package postinst scripts to bevahe
|
||||
DONT_MAINTAIN_APT_CACHE="yes" chroot_sdcard_apt_get --no-install-recommends install "${install_target}" # don't auto-maintain apt cache when installing from packages.
|
||||
unset extra_apt_envs
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ function create_new_rootfs_cache_via_debootstrap() {
|
||||
|
||||
# Done with debootstrap. Clean-up it's litterbox.
|
||||
display_alert "Cleaning up after debootstrap" "debootstrap cleanup" "info"
|
||||
run_host_command_logged rm -rf "${SDCARD}/var/cache/apt"
|
||||
run_host_command_logged rm -rf "${SDCARD}/var/cache/apt" "${SDCARD}/var/lib/apt/lists"
|
||||
|
||||
local_apt_deb_cache_prepare "after debootstrap second stage" # just for size reference in logs
|
||||
|
||||
@@ -227,12 +227,6 @@ function create_new_rootfs_cache_via_debootstrap() {
|
||||
free_space=$(LC_ALL=C df -h)
|
||||
display_alert "Free disk space on rootfs" "SDCARD: $(echo -e "${free_space}" | awk -v mp="${SDCARD}" '$6==mp {print $5}')" "info"
|
||||
|
||||
# creating xapian index that synaptic runs faster # @TODO: yes, but better done board-side on first run
|
||||
if [[ $BUILD_DESKTOP == yes ]]; then
|
||||
display_alert "Recreating Synaptic search index" "Please wait" "info"
|
||||
chroot_sdcard "[[ -f /usr/sbin/update-apt-xapian-index ]] && /usr/sbin/update-apt-xapian-index -u || true"
|
||||
fi
|
||||
|
||||
# this is needed for the build process later since resolvconf generated file in /run is not saved
|
||||
run_host_command_logged rm -v "${SDCARD}"/etc/resolv.conf
|
||||
run_host_command_logged echo "nameserver $NAMESERVER" ">" "${SDCARD}"/etc/resolv.conf
|
||||
|
||||
Reference in New Issue
Block a user