Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions rootfs/scripts/build-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,32 @@ umount -l "$ROOTFS_DIR/dev"
umount -l "$ROOTFS_DIR/sys"
umount -l "$ROOTFS_DIR/proc"

# ==============================================================================
# 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(."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 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
# ==============================================================================
Expand Down
Loading