Debian package management: Difference between revisions

From wiki
Jump to navigation Jump to search
imported>Johayek
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== intro ==
* dpkg – Debian package … – for handling the packages themselves
* APT – "Advanced Packaging Tool" – on top of dpkg commands, dealing with dependencies and repositories
* apt-... – addons to APT
== APT ==
== APT ==


Line 10: Line 15:


* https://manpages.debian.org/unstable/apt/apt-cache.8.en.html
* https://manpages.debian.org/unstable/apt/apt-cache.8.en.html
<pre>
# ...
apt-cache pkgnames | sort
# perform a full text search on all available package lists for the POSIX regex pattern given
# (options available)
$ apt-cache search regex...
$ apt-cache search --names-only regex...
$ apt-cache search --full regex...
</pre>


=== apt-get -- APT package handling utility -- command-line interface ===
=== apt-get -- APT package handling utility -- command-line interface ===
Line 19: Line 35:
<pre>$ sudo apt-get update</pre>
<pre>$ sudo apt-get update</pre>


=== APT: installing ... ====
==== APT: installing ... ====
<pre>
<pre>
$ sudo apt-get install PACKAGE
$ sudo apt-get install PACKAGE
Line 30: Line 46:
# just download it to the cache directory being specified (instead of /var/cache/apt/archives/):
# just download it to the cache directory being specified (instead of /var/cache/apt/archives/):
$ sudo apt-get install --download-only --option dir::cache=$HOME/tmp PACKAGE
$ sudo apt-get install --download-only --option dir::cache=$HOME/tmp PACKAGE
# install PACKAGE
$ sudo apt-get install PACKAGE
</pre>
</pre>


Line 53: Line 72:


In case of an optional resp. alternate dependency that's not shown (clearly).
In case of an optional resp. alternate dependency that's not shown (clearly).
=== which (installed?) package includes a certain FILE (utility, ...)? ===
<pre>$ apt-file search PATTERN</pre>
=== which files does a certain PACKAGE include? ===
<pre>$ apt-file list PACKAGE</pre>


== dpkg, dpkg-query, dpkg-deb ==
== dpkg, dpkg-query, dpkg-deb ==
Line 59: Line 84:


* https://manpages.debian.org/unstable/dpkg/dpkg.1.en.html
* https://manpages.debian.org/unstable/dpkg/dpkg.1.en.html
==== installing a Debian package ====
<pre>$ sudo dpkg --install PACKAGE.deb</pre>
==== removing a Debian package ====
<pre>$ sudo dpkg --remove PACKAGE</pre>
==== verifying a Debian package ====
<pre>$ sudo dpkg --verify PACKAGE</pre>
=== dpkg-deb -- Debian package archive (.deb) manipulation tool ===
* https://manpages.debian.org/unstable/dpkg/dpkg-deb.1.en.html
'''dpkg-deb''' packs, unpacks and provides information about Debian archives.
Use '''dpkg''' to install and remove packages from your system.
==== which files are included? will be created from this package file? ====
<pre>$ dpkg-deb --contents PACKAGE.deb</pre>


==== what's the official package name? ====
==== what's the official package name? ====
<pre>$ dpkg --info PACKAGE.deb</pre>
<pre>$ dpkg-deb --info PACKAGE.deb</pre>


==== which files are included? will be created from this package file? ====
==== what is the content of the ctrl-tarfile you can extract from PACKAGE.deb? ====
<pre>$ dpkg --contents PACKAGE.deb</pre>
<pre>$ dpkg-deb --ctrl-tarfile PACKAGE.deb | tar tvf  -
drwxr-xr-x root/root        0 2018-08-27 17:39 ./
-rw-r--r-- root/root    21773 2018-08-27 17:39 ./md5sums
-rw-r--r-- root/root      229 2018-08-27 17:39 ./control
-rw-r--r-- root/root      1071 2018-08-27 17:36 ./conffiles
-rwxr-xr-x root/root      1228 2018-08-27 17:39 ./postinst</pre>
 
* PACKAGE.deb contains a tarball (ctrl-tarfile).
* the tarball contains ... .
 
==== what conffiles does PACKAGE.deb contain? ====
<pre>$ dpkg-deb --ctrl-tarfile PACKAGE.deb | tar xf  - --to-stdout ./conffiles</pre>


==== installing the Debian package ====
* PACKAGE.deb contains a tarball (ctrl-tarfile),
<pre>$ sudo dpkg --install PACKAGE.deb</pre>
* the tarball contains ./conffiles,
* ./conffiles is only a list of what is to be treated as conffiles, it does not contain the conffiles themselves, they are an ordinary part of PACKAGE.deb


=== dpkg-query ===
=== dpkg-query ===
Line 87: Line 144:
==== what's the content of an installed package (e.g. PACKAGE) ====
==== what's the content of an installed package (e.g. PACKAGE) ====
<pre>$ dpkg-query --listfiles PACKAGE</pre>
<pre>$ dpkg-query --listfiles PACKAGE</pre>
==== what conffiles does an installed package (e.g. PACKAGE) include ====
<pre>$ dpkg-query --showformat='${Conffiles}\n' --show PACKAGE
$ dpkg-query --showformat='${Conffiles}\n' --show PACKAGE | perl -pe 's/^ \s* (.*?) \s* \w+ $/$1/x'</pre>
===== backup all the conffiles of an installed package (e.g. PACKAGE), each one for itself =====
<pre>$ sudo ~jochen.hayek/bin/create_snapshot.sh $( dpkg-query --showformat='${Conffiles}\n' --show PACKAGE | perl -pe 's/^ \s* (.*?) \s* \w+ $/$1/x' )</pre>
===== backup all the conffiles of an installed package (e.g. PACKAGE) to a single tarball =====
<pre>$ sudo tar cvf ~/tmp/PACKAGE.conffiles-$(date '+%Y%m%d%H%M%S').tar --directory / $( dpkg-query --showformat='${Conffiles}\n' --show PACKAGE | perl -pe 's/^ \s* (.*?) \s* \w+ $/$1/x' )</pre>


==== which installed package includes a certain FILE (utility, ...)? ====
==== which installed package includes a certain FILE (utility, ...)? ====
<pre>$ dpkg-query --search FILE</pre>
<pre>$ dpkg-query --search FILE</pre>


=== dpkg-deb -- Debian package archive (.deb) manipulation tool ===
= misc =


* https://manpages.debian.org/unstable/dpkg/dpkg-deb.1.en.html
* https://superuser.com/questions/408082/how-do-i-get-a-list-of-available-i-e-uninstalled-packages-in-debian How do I get a list of available (i.e. uninstalled) packages in Debian?
 
'''dpkg-deb''' packs, unpacks and provides information about Debian archives.
 
Use '''dpkg''' to install and remove packages from your system.


= dpkg-source -- Debian source package (.dsc) manipulation tool =
= dpkg-source -- Debian source package (.dsc) manipulation tool =
Line 118: Line 181:
* https://www.howtoforge.com/converting_rpm_to_deb_with_alien : alien -k ... ('''important''')
* https://www.howtoforge.com/converting_rpm_to_deb_with_alien : alien -k ... ('''important''')
* https://unix.stackexchange.com/questions/9714/what-is-the-need-for-fakeroot-command-in-linux#9720 ('''important''')
* https://unix.stackexchange.com/questions/9714/what-is-the-need-for-fakeroot-command-in-linux#9720 ('''important''')
* https://salsa.debian.org/perl-team/modules/packages/libdbd-oracle-perl/blob/master/debian/README -- Oracle's Instant Client package comes as RPM -- how to convert to .deb


== alien --to-deb ... ==
== alien --to-deb ... ==
Line 129: Line 193:
you do not have root priviliges,
you do not have root priviliges,
but you need to pretend to have them for achieving certain goals like creating a Debian package:
but you need to pretend to have them for achieving certain goals like creating a Debian package:
<pre>$ fakeroot --unknown-is-real ...</pre>
<pre>$ fakeroot ...</pre>


== special issues ==
== special issues ==
=== fiddling with the tree before creating the .deb ===
=== fiddling with the tree before creating the .deb ===
Because you actually do create real files (to be owned by root), you now do need to make use of sudo instead of only fakeroot:
<pre>$ env EMAIL='john.doe@COMPANY.com' alien --to-deb --keep-version ...
<pre>$ sudo env EMAIL='john.doe@COMPANY.com' alien --to-deb --keep-version ...
$ cd ...
$ cd ...
# here you want to change a few bits  
# here you want to change a few bits  
$ sudo env EMAIL='john.doe@COMPANY.com' debian/rules binary
$ sudo chown ...
$ fakeroot debian/rules binary
</pre>
</pre>



Latest revision as of 13:41, 26 February 2024

intro[edit]

  • dpkg – Debian package … – for handling the packages themselves
  • APT – "Advanced Packaging Tool" – on top of dpkg commands, dealing with dependencies and repositories
  • apt-... – addons to APT

APT[edit]

apt-cache -- query the APT cache[edit]

# ...
apt-cache pkgnames | sort

# perform a full text search on all available package lists for the POSIX regex pattern given
# (options available)
$ apt-cache search regex...
$ apt-cache search --names-only regex...
$ apt-cache search --full regex...

apt-get -- APT package handling utility -- command-line interface[edit]

APT: resynchronising the package index files from their sources[edit]

$ sudo apt-get update

APT: installing ...[edit]

$ sudo apt-get install PACKAGE

# do not *really* install the PACKAGE,
# just download it to the default cache directory:
$ sudo apt-get install --download-only PACKAGE

# do not *really* install the PACKAGE,
# just download it to the cache directory being specified (instead of /var/cache/apt/archives/):
$ sudo apt-get install --download-only --option dir::cache=$HOME/tmp PACKAGE

# install PACKAGE
$ sudo apt-get install PACKAGE

APT: installing the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list[edit]

$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade

APT: removing ...[edit]

$ sudo apt-get remove PACKAGE
$ sudo apt-get autoremove PACKAGE

apt-rdepends - performs ... dependency listings (also a reverse one)[edit]

$ apt-rdepends --reverse PACKAGE

In case of an optional resp. alternate dependency that's not shown (clearly).

which (installed?) package includes a certain FILE (utility, ...)?[edit]

$ apt-file search PATTERN

which files does a certain PACKAGE include?[edit]

$ apt-file list PACKAGE

dpkg, dpkg-query, dpkg-deb[edit]

dpkg[edit]

installing a Debian package[edit]

$ sudo dpkg --install PACKAGE.deb

removing a Debian package[edit]

$ sudo dpkg --remove PACKAGE

verifying a Debian package[edit]

$ sudo dpkg --verify PACKAGE

dpkg-deb -- Debian package archive (.deb) manipulation tool[edit]

dpkg-deb packs, unpacks and provides information about Debian archives.

Use dpkg to install and remove packages from your system.

which files are included? will be created from this package file?[edit]

$ dpkg-deb --contents PACKAGE.deb

what's the official package name?[edit]

$ dpkg-deb --info PACKAGE.deb

what is the content of the ctrl-tarfile you can extract from PACKAGE.deb?[edit]

$ dpkg-deb --ctrl-tarfile PACKAGE.deb | tar tvf  -
drwxr-xr-x root/root         0 2018-08-27 17:39 ./
-rw-r--r-- root/root     21773 2018-08-27 17:39 ./md5sums
-rw-r--r-- root/root       229 2018-08-27 17:39 ./control
-rw-r--r-- root/root      1071 2018-08-27 17:36 ./conffiles
-rwxr-xr-x root/root      1228 2018-08-27 17:39 ./postinst
  • PACKAGE.deb contains a tarball (ctrl-tarfile).
  • the tarball contains ... .

what conffiles does PACKAGE.deb contain?[edit]

$ dpkg-deb --ctrl-tarfile PACKAGE.deb | tar xf  - --to-stdout ./conffiles
  • PACKAGE.deb contains a tarball (ctrl-tarfile),
  • the tarball contains ./conffiles,
  • ./conffiles is only a list of what is to be treated as conffiles, it does not contain the conffiles themselves, they are an ordinary part of PACKAGE.deb

dpkg-query[edit]

which packages are installed (together with a couple of details)?[edit]

$ dpkg-query --list

is there an installed package, that sounds like XYZ?[edit]

$ dpkg-query --list | fgrep XYZ

details of an installed package (that you know the name of, e.g. PACKAGE)[edit]

$ dpkg-query --list PACKAGE

all details of specified package[edit]

$ dpkg-query --status PACKAGE

what's the content of an installed package (e.g. PACKAGE)[edit]

$ dpkg-query --listfiles PACKAGE

what conffiles does an installed package (e.g. PACKAGE) include[edit]

$ dpkg-query --showformat='${Conffiles}\n' --show PACKAGE
$ dpkg-query --showformat='${Conffiles}\n' --show PACKAGE | perl -pe 's/^ \s* (.*?) \s* \w+ $/$1/x'
backup all the conffiles of an installed package (e.g. PACKAGE), each one for itself[edit]
$ sudo ~jochen.hayek/bin/create_snapshot.sh $( dpkg-query --showformat='${Conffiles}\n' --show PACKAGE | perl -pe 's/^ \s* (.*?) \s* \w+ $/$1/x' )
backup all the conffiles of an installed package (e.g. PACKAGE) to a single tarball[edit]
$ sudo tar cvf ~/tmp/PACKAGE.conffiles-$(date '+%Y%m%d%H%M%S').tar --directory / $( dpkg-query --showformat='${Conffiles}\n' --show PACKAGE | perl -pe 's/^ \s* (.*?) \s* \w+ $/$1/x' )

which installed package includes a certain FILE (utility, ...)?[edit]

$ dpkg-query --search FILE

misc[edit]

dpkg-source -- Debian source package (.dsc) manipulation tool[edit]

$ dpkg-source --extract ....dsc

needs a:

  • *.dsc
  • *.debian.tar.*
  • *.orig.tar.*

rpm2deb -- converting packages from ... to ...[edit]

alien --to-deb ...[edit]

this command line creates a Debian package from an RPM package (using that e-mail address for the (local Debian) package maintainer).
CAVEAT: won't actually work, because creating a Debian package requires running this as root

$ env EMAIL='john.doe@COMPANY.com' alien --to-deb --keep-version ...

some command line parameters can only get passed to "alien" as environment variables.

fakeroot ...[edit]

you do not have root priviliges, but you need to pretend to have them for achieving certain goals like creating a Debian package:

$ fakeroot ...

special issues[edit]

fiddling with the tree before creating the .deb[edit]

$ env EMAIL='john.doe@COMPANY.com' alien --to-deb --keep-version ...
$ cd ...
# here you want to change a few bits 
$ sudo chown ...
$ fakeroot debian/rules binary

open questions[edit]

  • how to deal with dependencies specified within the RPM package?

history of this article[edit]

This blog article got created 1st, but then the content got moved here to the wiki: