sudo apt install kodi
-> Installs kodi and additionally kodi-bin kodi-data kodi-repository-kodi kodi-visualization-spectrum kodi-x11 libjs-iscroll python-olefile python-pil python-pycryptodome
Now I assume that the backup will save all installed packages - I by this understand that all additionally packages are also installed so e.g. sudo apt install kodi-bin
-> sets kodi-bin as manually installed sudo apt remove kodi
-> removes kodi and all packages but not kodi-bin!
So either your method does not list all installed packages (including dependencies) which would be the good case or all dependencies will in a backup case also be installed without dependencies.
My method lists all installed packages, so on a restore you can restore all of the packages you had installed previously. If you want to remove unused dependencies, I’d consider that out of scope of a backup/restore (which is trying to restore the state of a machine to the backed-up state), and is something you’d handle before and/or after the backup/restore with sudo apt autoremove, not something the backup/restore should account for.
I disagree. Apt maintains the state of which packages were manually installed and which were automatically installed as a dependency. Your method would not maintain that state entirely since it would just mark all packages as manually installed.
There should be a command for getting the installed versions along with that auto/manual state, but I’m unable to find it right now.
However, if all you want is the list of manually installed packages, then apt-mark showmanual will do that for you.
or if you auto-snooptube-dl the whole Cyberpunk 2077 walkthrough playlist in max quality 4k@60fps … not many people with the machines capable of outputing that for us though …
thanks for that one, added to my backup script! And I agree, it’s much better to get only the manual installations, otherwise when doing an apt install with the full pkglist it will mark all of them as manually installed and removing dependencies will be a lot harder.
Won’t it just install the dependency packages when whatever depends on them gets installed, and then when they come up on the list they just won’t get installed again? That would maintain the dependency state, as long as you can guarantee that they won’t get installed before whatever depends on them gets installed (maybe that guarantee isn’t possible?).
For a start, that guarantee is not sought … by listing all the packages in alphabetical order you’ve lost a lot of the obvious information.
It would be a messy job to sort the packages into dependency order yourself. You may find yourself doing the analysis of the dependency graph, replicating the work that apt presumably already did when you installed initially.
Is it possible that apt is smart enough to work the way you suggest is possible? Yes. (In other words, could it eliminate redundantly specified package names from a large list of packages to install, taking into account the dependencies between packages? Having eliminated them it would of course have to immediately add them back as required dependencies.)
Does it work that way? No idea. You would have to go and study the source code.
Does it even try to? No idea.
Is it really possible? I wonder. If A depends on B and B depends on A, and I install A then I will end up with both A and B installed. Later on, if I only list the installed packages, how would software by examining that list know whether I installed A or I installed B? By using a “manual” flag, it would actually know that A was “manual” and B was automatically installed, as a dependency. ??
Now someone can edit this pkg.list (.list) file and remove or add whatever preferred in order to or not to (re)install/restore very same packages again with: xargs -a "201230pkg.list" apt-get install
or xargs -a "201230pkg.list" aptitude install --without-recommends
@Gavaudan for further options please take a look at man aptitude.
Unfortunately it actually happens fairly often and is one of the main reasons I try to stay away from deb/rpm based systems. There are mainly two options how this may happen (without user consent):
system bootstrapping (during initial installation packages are mostly forced, without dependency checks)
change of dependencies over the time (so that two manually installed packages become interdependent either directly or via another dependency)
It just means that you have to install them at the same timeand if they all (both) have post-installation scripts then there could be problems with configuring the newly installed package.
See, this is where I disagree: the state of the machine includes having the packages you installed marked as “installed manually” and the ones that came in as dependencies as “installed as dependency” (or whatever the proper terminology is).
If you would preserve state, then uninstalling the main package would have the same effect pre or post restore: it would uninstall the package, and an apt autoremove would uninstall its dependencies. This does not happen when you install the dependencies manually. See transcripts below:
Install kodi, let system figure out dependencies
[02:38] nighty@saltmine ~$ sudo apt install kodi
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
fonts-noto-hinted fonts-noto-mono fonts-roboto-unhinted javascript-common kodi-bin kodi-data kodi-repository-kodi kodi-visualization-spectrum kodi-x11 libcec4 libcrossguid0
libfstrcmp0 libjs-iscroll libmicrohttpd12 libp8-platform2 python-olefile python-pil python-pycryptodome
Suggested packages:
apache2 | lighttpd | httpd python-pil-doc python-pil-dbg
The following NEW packages will be installed
fonts-noto-hinted fonts-noto-mono fonts-roboto-unhinted javascript-common kodi kodi-bin kodi-data kodi-repository-kodi kodi-visualization-spectrum kodi-x11 libcec4
libcrossguid0 libfstrcmp0 libjs-iscroll libmicrohttpd12 libp8-platform2 python-olefile python-pil python-pycryptodome
0 to upgrade, 19 to newly install, 0 to remove and 4 not to upgrade.
# SNIP
[02:48] nighty@saltmine ~$ sudo dpkg -P kodi
(Reading database ... 443621 files and directories currently installed.)
Removing kodi (2:18.6+dfsg1-2ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for desktop-file-utils (0.24+linuxmint1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
[02:48] nighty@saltmine ~$ sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED
fonts-noto-hinted fonts-roboto-unhinted kodi-bin kodi-data kodi-repository-kodi kodi-visualization-spectrum kodi-x11 libcec4 libcrossguid0 libfstrcmp0 libjs-iscroll
libmicrohttpd12 libp8-platform2 python-olefile python-pil python-pycryptodome
0 to upgrade, 0 to newly install, 16 to remove and 4 not to upgrade.
After this operation, 86,4 MB disk space will be freed.
# SNIP
Install kodi and one of its dependencies
[02:49] nighty@saltmine ~$ sudo apt install kodi fonts-noto-hinted
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
fonts-roboto-unhinted kodi-bin kodi-data kodi-repository-kodi kodi-visualization-spectrum kodi-x11 libcec4 libcrossguid0 libfstrcmp0 libjs-iscroll libmicrohttpd12
libp8-platform2 python-olefile python-pil python-pycryptodome
Suggested packages:
python-pil-doc python-pil-dbg
The following NEW packages will be installed
fonts-noto-hinted fonts-roboto-unhinted kodi kodi-bin kodi-data kodi-repository-kodi kodi-visualization-spectrum kodi-x11 libcec4 libcrossguid0 libfstrcmp0 libjs-iscroll
libmicrohttpd12 libp8-platform2 python-olefile python-pil python-pycryptodome
0 to upgrade, 17 to newly install, 0 to remove and 4 not to upgrade.
Need to get 33,0 MB of archives.
After this operation, 86,5 MB of additional disk space will be used.
# SNIP
[02:49] nighty@saltmine ~$ sudo dpkg -P kodi
(Reading database ... 443621 files and directories currently installed.)
Removing kodi (2:18.6+dfsg1-2ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for desktop-file-utils (0.24+linuxmint1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
[02:50] nighty@saltmine ~$ sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED
fonts-roboto-unhinted kodi-bin kodi-data kodi-repository-kodi kodi-visualization-spectrum kodi-x11 libcec4 libcrossguid0 libfstrcmp0 libjs-iscroll libmicrohttpd12
libp8-platform2 python-olefile python-pil python-pycryptodome
0 to upgrade, 0 to newly install, 15 to remove and 4 not to upgrade.
After this operation, 86,3 MB disk space will be freed.
# SNIP
[02:50] nighty@saltmine ~$ dpkg -l |grep fonts-noto-hinted
ii fonts-noto-hinted 20200323-1build1~ubuntu20.04.1 all obsolete metapackage to pull in a subset of Noto fonts
[02:50] nighty@saltmine ~$ sudo dpkg -P fonts-noto-hinted
(Reading database ... 440926 files and directories currently installed.)
Removing fonts-noto-hinted (20200323-1build1~ubuntu20.04.1) ...
As you can see, when I include fonts-noto-hinted in the apt install command, removal of kodi does not put it in the apt autoremove list, and it has to be manually deinstalled.
Pro tip: since this qualifies as “code”, you can embed it between triplets of backticks (the ` character) to enclose it in a code box. That way it takes up less vertical space, and we don’t have to scroll past reams and reams of not so relevant text to get to the next post. Here’s what that list would look like, formatted as code:
Question: How do I ask Backups to save all my dates in the Calendar and all my contacts? Which folder should I ask it to save? It saves “Home Purism” by default… Does it contain the calendar and contacts? Or do I have to add more by pressing the “+”?