From 52b5860417b794b5086afce863d90a8bfc1b5ca5 Mon Sep 17 00:00:00 2001 From: Keerthi Gowda Date: Wed, 22 Jul 2026 17:05:22 -0700 Subject: [PATCH 1/2] rootfs: remove temporary apt sources before image creation Delete apt source list files for manifest entries marked temp: true after chroot package installation and before creating rootfs.img. This keeps build-time staging repos available during dependency resolution without leaving them configured on target devices. Signed-off-by: Keerthi Gowda --- rootfs/scripts/build-rootfs.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rootfs/scripts/build-rootfs.sh b/rootfs/scripts/build-rootfs.sh index 4dfac297..04f199d4 100755 --- a/rootfs/scripts/build-rootfs.sh +++ b/rootfs/scripts/build-rootfs.sh @@ -709,6 +709,20 @@ umount -l "$ROOTFS_DIR/dev" umount -l "$ROOTFS_DIR/sys" umount -l "$ROOTFS_DIR/proc" +# ============================================================================== +# Step 9.5: Remove temporary apt sources from final image +# ============================================================================== +if [[ "$USE_MANIFEST" -eq 1 && -n "$MANIFEST" ]]; then + jq -c '.apt_sources[]? | select(.temp == true)' "$MANIFEST" | while read -r row; do + NAME=$(echo "$row" | jq -r '.name // "customrepo"') + SOURCE_LIST="$ROOTFS_DIR/etc/apt/sources.list.d/${NAME}.list" + if [[ -f "$SOURCE_LIST" ]]; then + rm -f "$SOURCE_LIST" + echo "[INFO] Removed temporary apt source from final image: ${NAME}" + fi + done +fi + # ============================================================================== # Step 10: Create ext4 rootfs image and write contents # ============================================================================== From 822af7bd521a88cc7f9338cdd35684bc13ced6be Mon Sep 17 00:00:00 2001 From: Keerthi Gowda Date: Mon, 27 Jul 2026 14:51:30 -0700 Subject: [PATCH 2/2] rootfs: clean up local-debs repo and apt caches from final image - Rename manifest flag from temp to build-only for clarity - Remove /opt/local-debs and its apt source list, used only for --local-debs dependency resolution during build - Clear var/lib/apt/lists and var/cache/apt/archives from the rootfs Signed-off-by: Keerthi Gowda --- rootfs/scripts/build-rootfs.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/rootfs/scripts/build-rootfs.sh b/rootfs/scripts/build-rootfs.sh index 04f199d4..eeac9faf 100755 --- a/rootfs/scripts/build-rootfs.sh +++ b/rootfs/scripts/build-rootfs.sh @@ -710,19 +710,31 @@ umount -l "$ROOTFS_DIR/sys" umount -l "$ROOTFS_DIR/proc" # ============================================================================== -# Step 9.5: Remove temporary apt sources from final image +# Step 9.5: Remove build-only apt sources and caches from final image +# - build-only sources declared in the overlay manifest ("build-only": true) +# - local .deb repo created for --local-debs +# - apt indices and downloads cached during the build # ============================================================================== if [[ "$USE_MANIFEST" -eq 1 && -n "$MANIFEST" ]]; then - jq -c '.apt_sources[]? | select(.temp == true)' "$MANIFEST" | while read -r row; do + jq -c '.apt_sources[]? | select(."build-only" == true)' "$MANIFEST" | while read -r row; do NAME=$(echo "$row" | jq -r '.name // "customrepo"') SOURCE_LIST="$ROOTFS_DIR/etc/apt/sources.list.d/${NAME}.list" if [[ -f "$SOURCE_LIST" ]]; then rm -f "$SOURCE_LIST" - echo "[INFO] Removed temporary apt source from final image: ${NAME}" + echo "[INFO] Removed build-only apt source from final image: ${NAME}" fi done fi +if [[ -f "$ROOTFS_DIR/etc/apt/sources.list.d/local-debs.list" ]]; then + rm -f "$ROOTFS_DIR/etc/apt/sources.list.d/local-debs.list" + rm -rf "$ROOTFS_DIR/opt/local-debs" + echo "[INFO] Removed local-debs apt repo from final image" +fi + +rm -rf "$ROOTFS_DIR/var/lib/apt/lists/"* +rm -f "$ROOTFS_DIR/var/cache/apt/archives/"*.deb + # ============================================================================== # Step 10: Create ext4 rootfs image and write contents # ==============================================================================