From 13bc96d4dc0a670e6dc2b0c7859f48d3e64b7156 Mon Sep 17 00:00:00 2001
From: khramshinr <khramshinr@gmail.com>
Date: Thu, 24 Oct 2024 14:14:17 +0600
Subject: T6684: new Debian package repo snapshot logic

Added functionality to store version information for temporarily installed packages.
---
 .../live-build/0001-save-package-info.patch        | 30 ++++++++++++----------
 1 file changed, 17 insertions(+), 13 deletions(-)

(limited to 'docker/patches/live-build/0001-save-package-info.patch')

diff --git a/docker/patches/live-build/0001-save-package-info.patch b/docker/patches/live-build/0001-save-package-info.patch
index abb4308d..3ce22fe1 100644
--- a/docker/patches/live-build/0001-save-package-info.patch
+++ b/docker/patches/live-build/0001-save-package-info.patch
@@ -1,33 +1,36 @@
-From 3ddf0e979c352f2917be6a949fb8dd37b5c9f2b7 Mon Sep 17 00:00:00 2001
+From 9dacc8bf99310b2216be24a42f2c0475080cf039 Mon Sep 17 00:00:00 2001
 From: khramshinr <khramshinr@gmail.com>
-Date: Wed, 28 Aug 2024 14:38:15 +0600
+Date: Thu, 24 Oct 2024 14:22:57 +0600
 Subject: [PATCH] T6684: new Debian package repo snapshot logic
 
-save information about all installed packages and teir source repo, including temporary packages
+Save information about all installed packages and teir source repo, including temporary packages
+Added functionality to store version information for temporarily installed packages.
 ---
- functions/packages.sh | 7 +++++++
+ functions/packages.sh | 9 +++++++++
  scripts/build/chroot  | 6 ++++++
  scripts/build/clean   | 2 +-
- 3 files changed, 14 insertions(+), 1 deletion(-)
+ 3 files changed, 16 insertions(+), 1 deletion(-)
 
 diff --git a/functions/packages.sh b/functions/packages.sh
-index 9e25df5f3..4d1fa695e 100755
+index 2481edc25..a6c2c1e8d 100755
 --- a/functions/packages.sh
 +++ b/functions/packages.sh
-@@ -60,6 +60,13 @@ Install_packages ()
+@@ -60,6 +60,15 @@ Install_packages ()
  			Chroot chroot "aptitude install --without-recommends ${APTITUDE_OPTIONS} ${_LB_PACKAGES}"
  			;;
  	esac
 +
 +  # save information about all temporary installed packages and source repos
 +	for PACKAGE in ${_LB_PACKAGES}; do
-+		Chroot chroot "apt-cache policy ${PACKAGE}"  | sed -n '/\*\*\*/,$p' | grep -P 'http:|https:' -m 1 | awk -v pkg="${PACKAGE}" '{print $2" "$3" "pkg}' >> chroot.packages.all.info
++		INSTALLED_VERSION=$(Chroot chroot "apt-cache policy ${PACKAGE}" | grep 'Installed:' | awk '{print $2}')
++		Chroot chroot "apt-cache policy ${PACKAGE}"  | sed -n '/\*\*\*/,$p' | grep -P 'http:|https:' -m 1 | \
++		awk -v pkg="${PACKAGE}" -v version="${INSTALLED_VERSION}" '{print $2" "$3" "pkg" "version}' >> chroot.packages.all.info
 +
 +	done
 +
  	unset _LB_PACKAGES # Can clear this now
  }
-
+ 
 diff --git a/scripts/build/chroot b/scripts/build/chroot
 index a0aa10be0..700762e78 100755
 --- a/scripts/build/chroot
@@ -35,7 +38,7 @@ index a0aa10be0..700762e78 100755
 @@ -48,6 +48,12 @@ for _PASS in install live; do
  	fi
  done
-
+ 
 +# save information about all installed packages and source repos
 +Chroot chroot "dpkg-query -W" | while read PACKAGE; do
 +  Chroot chroot "apt-cache policy ${PACKAGE}"  | sed -n '/\*\*\*/,$p' | grep -P 'http:|https:' -m 1 | awk -v pkg="${PACKAGE}" '{print $2" "$3" "pkg}' >> chroot.packages.all.info
@@ -50,11 +53,12 @@ index 6549fc635..4376d7525 100755
 --- a/scripts/build/clean
 +++ b/scripts/build/clean
 @@ -159,7 +159,7 @@ if [ "${RM_CHROOT}" = "true" ]; then
-
+ 
  	rm -rf chroot chroot.tmp
-
+ 
 -	rm -f chroot.packages.live chroot.packages.install
 +	rm -f chroot.packages.live chroot.packages.install chroot.packages.all.info
  	rm -f chroot.files
+ 
+ 	rm -f "$(Installed_tmp_packages_file)"
 
- 	rm -f "$(Installed_tmp_packages_file)"
\ No newline at end of file
-- 
cgit v1.2.3