Deb

From Omnia
Revision as of 18:40, 17 December 2020 by Kenneth (talk | contribs) (→‎building a deb package)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

building a deb package

Good looking articles:

Build deb

Create deb:

dpkg -b [DIR]
# creates: [DIR].deb

Create deb with target name:

dpkg -b [DIR] [NAME].deb
# creates: [NAME].deb

Package layout:

[DIR]/
  /etc/myfile
  #...etc...
  DEBIAN/control    # REQUIRED, similar to RPM spec file
  DEBIAN/postinst   # pre/post scripts

Maintainer scripts - {pre,post}{inst,rm}

DEBIAN/postinst
DEBIAN/preinst
DEBIAN/postrm
DEBIAN/prerm

NOTE: Comments do not appear to be allowed in DEBIAN/control.

DEBIAN/control: (minimal with warning)

Package: deb1
Version: 1.0

DEBIAN/control: (minimal no warnings)

Package: ken1
Version: 1.0
Architecture: somearch
Maintainer: Kenneth <kenneth@gmail.com>
Description: This is a description with
        multiple lines

DEBIAN/control:

Package: deb1
Version: 1.0
Section: web
Priority: optional
Architecture: all
Essential: no
Maintainer: Joe Brockmeier [jzb@dissociatedpress.net]
Provides: deb1
Description: The description can contain free-form text
             describing the function of the program, what
             kind of features it has, and so on.

Debian repo archive is divided into multiple areas: main (the free software), non-free (the not really free software) and contrib (free software that depends on non-free software)

CheckInstall

apt install checkinstall

See Linux/CheckInstall

ref: https://wiki.debian.org/CheckInstall

deb vs rpm

"I'm wondering if anyone could please tell me the differences in these two software formats and why that data makes one better than another (or perhaps makes them the same)."
"I don't think one is superior than the other. They are quite similar in functionality and have the same pros and limitations e.g. you have to resolve dependencies manually when installing rpms with rpm and debs with dpkg. What tends to differ is the wrappers around rpm and dpkg which provide additional functionality e.g automatic dependency checking and resolution. On most Debian based distros, apt and its related tools are the preferred wrapper and on rpm based distros, there is a wider selection e.g. yum, urpmi, yast, smart, apt etc. For years apt was the superior tool because it had a few years head start, but tools like yum, urpmi and SMART have caught up and have more or less the same features as apt.
The debates you see on the net about rpm vs deb, tend to be really flawed because a lot of people compare apt vs rpm instead of comparing rpm vs dpkg. Apt can be used with rpm based distros so its not unique to Debian based distros. Its just that many rpm based distros don't use it by default." (*.deb vs *.rpm - Linux Forums)


"Debian's package system is often considered superior to RPMs. IMHO, this is not because of technical reasons. In fact, Debian's advantage (with respect to packaging) comes from 2 issues outside of the packaging system:
- apt-get. Whenever you want to install a .deb, you'll get it - and its dependencies from the Debian archive. (Debian packages "in the wild" - outside of Debian or related distributions - are rare.)
- The Debian policy. Becoming a Debian developer requires one to agree to a "contract". Errors against the policy have a very high priority in the bug tracking system.
Red Hat on the other hand never enforced such a policy for RPMs. Their package format was adopted by many distributions and independent programmers, each using their own conventions. And this makes it difficult to mix packages from different sources." [1]


"The packaging policies have nothing to do with it. The mechanism to create a DEB package is more powerful, understandable, and flexible than the mechanism to create an RPM package." (RPM vs DEB on technical merits alone. [LWN.net])

Commands

Install deb package:

dpkg -i [package].deb

Remove package:

dpkg -r [package]

Show package information:

dpkg -I [package].deb

Show required dependencies:

dpkg -P [package].deb  # TODO: verify verify


Extract control files

DEB files are ar archives, which contain three files:

debian-binary
control.tar.gz
data.tar.gz

Extract deb files:

ar vx [PACKAGE].deb
tar -tzvf control.tar.gz  # list files
tar -zvxf control.tar.gz

Extra data files:

cat data.tar.xz | xz -d | tar -xv

One liner:

ar p [PACKAGE].deb control.tar.gz | tar zx

References:

rpm to deb commands

Install package:

rpm -Uvh [PACKAGE].rpm
dpkg -i [PACKAGE].deb

Remove package:

rpm -e [PACKAGE]
dpkg -r [PACKAGE]

Package info:

rpm --info [PACAKGE].rpm
dpkg -I [PACKAGE].deb

List install package files:

rpm -qvl [PACKAGE]
dpkg -L [PACKAGE]

List deb package files:

rpm -qvlp [PACKAGE].rpm
dpkg -c [PACAKGE].deb

List installed packages:

rpm -qa
dpkg -l

Extract files from deb package:

rpm2cpio [PACAKGE].rpm | cpio -dmvi
dpkg -x [PACKAGE].deb [TARGETFOLDER]

keywords