From 31d1661f0e5ab1b823742c93995b1ca44ba9de1a Mon Sep 17 00:00:00 2001 From: nkraetzschmar <9020053+nkraetzschmar@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:02:27 +0200 Subject: [PATCH] build source index (#27) include source packages into the package pool and create corresponding source index Fixes gardenlinux/gardenlinux#2384 --- create_dist | 13 +++++++++++++ download_pkgs | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/create_dist b/create_dist index 8644fc2..8dbedbc 100755 --- a/create_dist +++ b/create_dist @@ -23,6 +23,19 @@ for arch in all amd64 arm64; do echo " $hash $size main/binary-$arch/Packages.gz" >> "$index_files" done +dir="$target/dists/$dist/main/source" +mkdir -p "$dir" +(cd "$target" && dpkg-scansources pool) > "$dir/Sources" + +size="$(wc -c "$dir/Sources" | awk '{ print $1 }')" +hash="$(sha256sum "$dir/Sources" | head -c 64)" +echo " $hash $size main/source/Sources" >> "$index_files" +gzip < "$dir/Sources" > "$dir/Sources.gz" +rm "$dir/Sources" +size="$(wc -c "$dir/Sources.gz" | awk '{ print $1 }')" +hash="$(sha256sum "$dir/Sources.gz" | head -c 64)" +echo " $hash $size main/source/Sources.gz" >> "$index_files" + date="$(date -R -u)" cat << EOF | gpg --clearsign > "$target/dists/$dist/InRelease" diff --git a/download_pkgs b/download_pkgs index cd5b179..ddbe6d2 100755 --- a/download_pkgs +++ b/download_pkgs @@ -37,6 +37,15 @@ find download -name "*_all.deb" -or -name "*_$arch.deb" | sort | while read -r p cp --update=none "$pkg" "$target/pool/$hash/" done +find download -name "*.dsc" | sort | while read -r src; do + hash="$(sha256sum < "$src" | head -c 64)" + mkdir -p "$target/pool/$hash" + cp --update=none "$src" "$target/pool/$hash/$(basename "$src")" + awk '/^Files:$/ { flag = 1; next } !/^ / { flag = 0; } flag { print $3 }' < "$src" | while read f; do + cp --update=none "download/$f" "$target/pool/$hash/$f" + done +done + rm -rf download sort -o pkgs -u pkgs @@ -52,6 +61,7 @@ join -v 1 <(cat arch_import_list recursive_depends | sort | uniq) pkgs | { grep mkdir apt_download (cd apt_download && xargs apt-get download) < recursive_needed +(cd apt_download && xargs apt-get source --download-only) < recursive_needed find apt_download -name "*.deb" | while read -r pkg; do hash="$(sha256sum < "$pkg" | head -c 64)" @@ -60,4 +70,13 @@ find apt_download -name "*.deb" | while read -r pkg; do rm "$pkg" done +find apt_download -name "*.dsc" | while read -r src; do + hash="$(sha256sum < "$src" | head -c 64)" + mkdir -p "$target/pool/$hash" + cp --update=none "$src" "$target/pool/$hash/$(basename "$src")" + awk '/^Files:$/ { flag = 1; next } !/^ / { flag = 0; } flag { print $3 }' < "$src" | while read f; do + cp --update=none "apt_download/$f" "$target/pool/$hash/$f" + done +done + rm -rf apt_download