Score:0

Where is the unpacked content of a .deb file when using the "--unpack" option of dpkg?

kz flag

About the dpkg command, a few tutorials do mention of the --unpack option. According with jammy (1) dpkg.1 it indicates

--unpack package-file...
   Unpack the package, but don't configure it. If --recursive or -R option is specified,
   package-file must refer to a directory instead.

Well just how testing, from the MySQL APT Repository page it is possible to get the mysql-apt-config_0.8.24-1_all.deb file. So in the Downloads directory I executed the command:

sudo dpkg --unpack mysql-apt-config_0.8.24-1_all.deb

It works with the following message

(Reading database ... 238377 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.24-1_all.deb ...
Unpacking mysql-apt-config (0.8.24-1) over (0.8.24-1) ...

Even when MySQL is installed.

Question

  • Where is the unpacked the content of a .deb file?

A simple execution of the ls command only shows the current .deb file. I expected a kind of extraction. I am assuming a kind of default directory or other something else was used.

If with the -c option, it is possible to see the directories of the .deb file I am assuming that the --unpack option unpacks the .deb file - if my assumption is incorrect about the latter, please correct me.

Score:1
us flag

If you look at the part immediately about --unpack in the manpage (for --install):

Installation consists of the following steps:

  1. Extract the control files of the new package.

  2. If another version of the same package was installed before the new installation, execute prerm script of the old package.

  3. Run preinst script, if provided by the package.

  4. Unpack the new files, and at the same time back up the old files, so that if something goes wrong, they can be restored.

  5. If another version of the same package was installed before the new installation, execute the postrm script of the old package. Note that this script is executed after the preinst script of the new package, because new files are written at the same time old files are removed.

  6. Configure the package. See --configure for detailed information about how this is done.

Step 4 would seem to indicate that to unpack means to put the files in the package wherever they are supposed to be in the final state of the system. So if the package was supposed to install a /usr/bin/foo or an /etc/bar/baz file, then unpacking will put the corresponding files at those locations.

If you wanted to extract the files to the current directory or something like that instead of extracting them to the final installation targets, then the option is -x or --extract:

-x, --extract archive directory
   Extract the files contained by package.

-X, --vextract archive directory
   Extract and display the filenames contained by a package.
Manuel Jordan avatar
kz flag
Thanks for the feedback - about _So if the package was supposed to install a /usr/bin/foo or an /etc/bar/baz file ..._ for that paths: Are they the ones listed through the `-L` parameter, right? - It seems that use `--unpack` directly is useful to reput/reset some files if they were either deleted or overridden - Am I correct with that assumption?
muru avatar
us flag
Yes and yes. It's also useful if you want more control over the execution of the maintainer scripts (preinst, postinst, etc.) since you can unpack, then modify the scripts, then run them.
Manuel Jordan avatar
kz flag
Wondered why the `--unpack` option from the beginning did not include this information about to _reput/reset_ these files.
Manuel Jordan avatar
kz flag
Just being curious about _since you can unpack, then modify the scripts, then run them_ - therefore: unpack with `--unpack` (ok) - edit with nano/vim (ok) - but: How to install using directly the unpacked edited files?
muru avatar
us flag
I don't understand what you're asking there. Install what exactly?
Manuel Jordan avatar
kz flag
If you use `sudo dpkg -i mysql.deb` it installs mysql, right? - if you use `dpkg --unpack mysql.deb` it unpacks the installation files of the `.deb` file to some explicit paths, you can edit the installation files (as you wrote in your first comment) - so: How do you accomplish the installation process through the unpacked files? in this point the `.deb` file can't be used because it has the original installation files without any edition.
muru avatar
us flag
I said you can edit [the maintainer scripts](https://www.debian.org/doc/manuals/maint-guide/dother.en.html#maintscripts). I'm not sure what you mean by installation files here - please clarify. The maintainer scripts are for doing some configuration (e.g., creating a user, or asking the admin to select some configurable option like the mysql root password, etc.) and the process I talked about is for manipulating such scripts before they're run. See, e.g. https://askubuntu.com/a/482936/158442
Manuel Jordan avatar
kz flag
Huge Thanks for the 2 links. Now I understand the process. I understood in other way.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.