From 7c3b85bb182ee5e31f42393559640a254a3a173b Mon Sep 17 00:00:00 2001
From: OSAK Buildhauer <osak@fsmpi.rwth-aachen.de>
Date: Wed, 9 Jan 2019 11:51:55 +0000
Subject: [PATCH] Finished create_offlinerepo.sh and added offlinerepo creation
 to build process

---
 assemble_image.sh     |  1 +
 create_offlinerepo.sh | 38 +++++++++++++++++++++++++++++++++-----
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/assemble_image.sh b/assemble_image.sh
index 13de324..f9dd388 100755
--- a/assemble_image.sh
+++ b/assemble_image.sh
@@ -24,6 +24,7 @@ mv "$workspace/part_files"/grub/* "$workspace/part_files"/boot/grub/
 rm -rf "$workspace/part_files"/grub
 
 cp "$iso_file" "$workspace/part_files/kubuntu.iso"
+./create_offlinerepo.sh "$workspace/part_files/archive" "$iso_file" vim htop
 
 rm -f "$workspace/part.img"
 truncate -s "$image_size" "$workspace/part.img"
diff --git a/create_offlinerepo.sh b/create_offlinerepo.sh
index a89c11e..5e5891c 100755
--- a/create_offlinerepo.sh
+++ b/create_offlinerepo.sh
@@ -17,24 +17,52 @@ shift || usage
 packages="$@"
 
 workspace="/workspace"
+APT_SOURCE_URL_OVERRIDE="http://ftp.halifax.rwth-aachen.de/ubuntu/"
 
 rm -rf "$workspace"/offlinerepo
 mkdir -p "$workspace"/offlinerepo
+mkdir -p "$dest"
 
 7z e -so "$iso_file" casper/filesystem.squashfs > "$workspace"/offlinerepo/filesystem.squashfs
 unsquashfs -no-xattrs -d "$workspace"/offlinerepo/squashfs-root "$workspace"/offlinerepo/filesystem.squashfs 
 
+ISO_RELEASE="$(grep DISTRIB_CODENAME "$workspace/offlinerepo/squashfs-root/etc/lsb-release" | cut -d= -f 2-)"
+ISO_VERSION="$(grep DISTRIB_RELEASE "$workspace/offlinerepo/squashfs-root/etc/lsb-release" | cut -d= -f 2-)"
+ISO_DESCRIPTION="$(grep DISTRIB_DESCRIPTION "$workspace/offlinerepo/squashfs-root/etc/lsb-release" | cut -d'"' -f 2)"
+echo "deb $APT_SOURCE_URL_OVERRIDE ${ISO_RELEASE} main restricted universe multiverse" > "$workspace/offlinerepo/squashfs-root/etc/apt/sources.list"
+echo "deb $APT_SOURCE_URL_OVERRIDE ${ISO_RELEASE}-security main restricted universe multiverse" >> "$workspace/offlinerepo/squashfs-root/etc/apt/sources.list"
+echo "deb $APT_SOURCE_URL_OVERRIDE ${ISO_RELEASE}-updates main restricted universe multiverse" >> "$workspace/offlinerepo/squashfs-root/etc/apt/sources.list"
 apt-get -o Dir="$workspace"/offlinerepo/squashfs-root update
 
 {
 	apt-get -o Dir="$workspace"/offlinerepo/squashfs-root upgrade --print-uris -qq
 	apt-get -o Dir="$workspace"/offlinerepo/squashfs-root install --reinstall --print-uris -qq $packages
 } | cut -d"'" -f2 | while read url; do wget -nc -P "$dest" "$url"; done
+apt-get -o Dir="$workspace"/offlinerepo/squashfs-root install --reinstall --print-uris -qq $packages
 
-{
-	cd "$dest"
-	rm -rf "$dest"/Packages.*
-	dpkg-scanpackages . | gzip > Packages.gz
-}
+mkdir -p "$dest/dists/$ISO_RELEASE/lip/binary-amd64"
+( cd "$dest" && dpkg-scanpackages . | gzip > "dists/$ISO_RELEASE/lip/binary-amd64/Packages.gz" )
+
+cat <<EOF > "$dest/dists/$ISO_RELEASE/lip/binary-amd64/Release"
+Archive: $ISO_RELEASE
+Version: $ISO_VERSION
+Component: lip
+Origin: Ubuntu
+Label: Ubuntu
+Architecture: amd64
+EOF
+
+touch "$dest/.aptignr"
+cat <<EOF > "$dest/Release"
+Origin: Ubuntu
+Label: LIP Ubuntu Extra Packages
+Suite: $ISO_RELEASE
+Version: $ISO_VERSION
+Codename: $ISO_RELEASE
+Date: $(LC_ALL=C date -u)
+Architectures: amd64
+Components: lip
+Description: $ISO_DESCRIPTION
+EOF
 
 # Maybe sort files into the usual directory structure ("pool/main/g/glib2.0...")
-- 
GitLab