1

In a LXC container I want be able to note the packages I've just updated to then recreate that situation any date after that.

I think I want to do something like:

dpkg-query --show | sed "s/\t/=/" > somewhere_safe.txt

That'd give a list like:

adduser=3.118
apache2=2.4.38-3+deb10u4
apache2-bin=2.4.38-3+deb10u4
apache2-data=2.4.38-3+deb10u4
apache2-utils=2.4.38-3+deb10u4
apparmor=2.13.2-10
apt=1.8.2.1
apt-listchanges=3.19
apt-transport-https=1.8.2.1
apt-utils=1.8.2.1
# and so on

Then post process that with an apt upgrade script that takes them all as arguments. Am I going about this the right way?

Rationale: apt update doesn't have an "as of this date" argument, meaning I couldn't recreate something if I wanted to, yet I generally speaking want something recreatable in respect of packages even if I'm not using docker-style image repositories.

paul_h
  • 121

1 Answers1

1
apt list --installed | sed s/Listing...// | awk -F "/" '{print $1}' >  $(date +aptlist-%m.%d.%Y-%H.%M.%S.txt)

Creates the file which lists all of the installed packages.

xargs -a ThatFileCratedAbove.txt sudo apt-get install

Will install them from the list

....I would test the file first with apt-get -s install to simulate installation, just to make sure the list is not going to cause any problems.. (though that might take a long time)

.
.
.

UPDATE FOR VERSION REQUIREMENT... If you wanted to capture the version and be able to install those versions later, then your apt list snapshot would need to be created like this instead of above:

apt list --installed | sed s/Listing...// | awk -F"[[:blank:]/]" '{ if( $1 ne '' ) print $1"="$3}' >  $(date +aptlist-%m.%d.%Y-%H.%M.%S.txt)
WU-TANG
  • 3,316