Debian package management: Difference between revisions

From wiki
Jump to navigation Jump to search
Line 12: Line 12:


<pre>
<pre>
# ...
apt-cache pkgnames | sort
# perform a full text search on all available package lists for the POSIX regex pattern given
# perform a full text search on all available package lists for the POSIX regex pattern given
# (options available)
# (options available)
$ apt-cache search regex...
$ apt-cache search regex...
$ apt-cache search --names-only regex...
$ apt-cache search --full regex...
</pre>
</pre>



Revision as of 12:12, 7 April 2023

APT

apt-cache -- query the APT cache

# ...
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

APT: resynchronising the package index files from their sources

$ sudo apt-get update

APT: installing ...

$ 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

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

APT: removing ...

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

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

$ 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, ...)?

$ apt-file search PATTERN

which files does a certain PACKAGE include?

$ apt-file list PACKAGE

dpkg, dpkg-query, dpkg-deb

dpkg

installing a Debian package

$ sudo dpkg --install PACKAGE.deb

removing a Debian package

$ sudo dpkg --remove PACKAGE

verifying a Debian package

$ sudo dpkg --verify PACKAGE

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

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?

$ dpkg-deb --contents PACKAGE.deb

what's the official package name?

$ dpkg-deb --info PACKAGE.deb

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

$ 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?

$ 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

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

$ dpkg-query --list

is there an installed package, that sounds like XYZ?

$ dpkg-query --list | fgrep XYZ

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

$ dpkg-query --list PACKAGE

all details of specified package

$ dpkg-query --status PACKAGE

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

$ dpkg-query --listfiles PACKAGE

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

$ 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
$ 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
$ 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, ...)?

$ dpkg-query --search FILE

misc

dpkg-source -- Debian source package (.dsc) manipulation tool

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

needs a:

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

rpm2deb -- converting packages from ... to ...

alien --to-deb ...

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 ...

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

fiddling with the tree before creating the .deb

$ 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

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

history of this article

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