[Howto] Packaging

Post your tutorials and howtos here.
User avatar
zerozero
Posts: 5373
Joined: 10 Feb 2013 23:37
Location: West Midlands, England
Contact:

[Howto] Packaging

Postby zerozero » 11 Aug 2013 00:50

==========
Thanks to Dan for asking and Schoelje for remembering me that this post could be in the Tutorials session of the Forum ;)
This is a repost from http://forums.solydxk.nl/viewtopic.php?f=60&t=1105
==========

this is a generic introduction to the packaging workflow and a couple tips about the best (in my personal experience) approach to packaging.


1- (in my experience) the best setup
this was a trial&error approach but i believe that the use of virtual-machines has clear advantages
  • keeps our main install clean from unnecessary dev and multiarch packages (and they will be a lot)
  • gives us the freedom to install whatever we want in our main system and at the same time keep the packaging VM within the requirements (only app/lib available in the default solydxk repo)
  • the same can (almost) be achieved with a dedicated partition (and if you don't have the horse-power to run a VM it's a good option) but personally i find cumbersome all the necessary reboots involved in such setup
2- preparing the system
we are just going to cover here the basic tools needed for packaging (we will find out that in each project we will need other libraries/dependencies but that is outside the scope of a topic like this)

Code: Select all

apt install packaging-dev
(this will install a basic set of tools to get us started)

3- packaging methodology
there's good, not-so-bad and bad ways to produce a deb :mrgreen:
  • sudo make install doesn't produce a deb so it's not even considered
  • sudo checkinstall produces a deb
  • personally i prefer dh-make, gives me more robust results
you'll find plenty of literature about the subject (the debian wiki is a wonderful place for that)
https://wiki.debian.org/HowToPackageFor ... tion.27.27
https://wiki.debian.org/IntroDebianPackaging
https://wiki.debian.org/Packaging
https://wiki.debian.org/PackagingTutorial
http://newbiedoc.sourceforge.net/system ... ll.html.en (old howto on checkinstall but with some interesting ideas)
http://www.lucas-nussbaum.net/blog/?p=640 (has a nice pdf)
http://forums.debian.net/viewtopic.php?p=228570 (very good topic about the same subject)

4- a standard procedure
download the source, unpack it and move it to a working directory (not mandatory but keeps things tidier)
check if you need to tweak the folder name (no caps letters, no special characters), and give it a format of <packagename>-<versionnumber> if it doesn't have one
(something like this)

Code: Select all

ls -lA
total 240
drwxr-xr-x 5 solydxk solydxk    620 Aug  9 14:10 xfwm4compositeeditor-0.2.0
-rw-r--r-- 1 solydxk solydxk 242143 Aug  9 14:02 Xfwm4CompositeEditor-0.2.0.tar.gz
cd to the folder and

Code: Select all

dh_make --createorig

Code: Select all

solydxk@solydxk:~/Downloads/xfwm4compositeeditor-0.2.0$ dh_make --createorig

Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch?
 [s/i/m/l/k/n] s

Maintainer name  : unknown
Email-Address    : solydxk@solydxk 
Date             : Fri, 09 Aug 2013 19:28:44 +0000
Package Name     : xfwm4compositeeditor
Version          : 0.2.0
License          : blank
Type of Package  : Single
Hit <enter> to confirm: 
Done. Please edit the files in the debian/ subdirectory now. xfwm4compositeeditor
uses a configure script, so you probably don't have to edit the Makefiles.
at this point is a good idea to check the debian/control file and make the necessary adjustments
http://www.debian.org/doc/debian-policy ... ields.html
it looks like this at this point

Code: Select all

Source: xfwm4compositeeditor
Section: unknown
Priority: extra
Maintainer: unknown <solydxk@solydxk>
Build-Depends: debhelper (>= 8.0.0), autotools-dev
Standards-Version: 3.9.4
Homepage: <insert the upstream URL, if relevant>
#Vcs-Git: git://git.debian.org/collab-maint/xfwm4compositeeditor.git
#Vcs-Browser: http://git.debian.org/?p=collab-maint/xfwm4compositeeditor.git;a=summary

Package: xfwm4compositeeditor
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: <insert up to 60 chars description>
 <insert long description, indented with spaces>
one advantage of dh-make is that it picks the runtime dependencies and even if we don't alter the debian/control it will do it for us.
after the building (without my interference) the control file looks like this

Code: Select all

Package: xfwm4compositeeditor
Version: 0.2.0-1
Architecture: i386
Maintainer: unknown <solydxk@solydxk>
Installed-Size: 48
Depends: libatk1.0-0 (>= 1.12.4), libc6 (>= 2.0), libcairo2 (>= 1.2.4), libdbus-1-3 (>= 1.0.2), libdbus-glib-1-2 (>= 0.78), libfontconfig1 (>= 2.10.0), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.12.0), libgtk2.0-0 (>= 2.14.0), libpango-1.0-0 (>= 1.14.0), libpangocairo-1.0-0 (>= 1.14.0), libpangoft2-1.0-0 (>= 1.14.0), libstdc++6 (>= 4.1.1), libxfce4ui-1-0 (>= 4.9.0), libxfce4util6 (>= 4.9.0), libxfconf-0-2 (>= 4.6.0)
Section: unknown
Priority: extra
Homepage: <insert the upstream URL, if relevant>
Description: <insert up to 60 chars description>
 <insert long description, indented with spaces>
finished that part and saved the new control file

Code: Select all

dpkg-buildpackage
and it should finish like this

Code: Select all

dpkg-deb: building package `xfwm4compositeeditor' in `../xfwm4compositeeditor_0.2.0-1_i386.deb'.
 signfile xfwm4compositeeditor_0.2.0-1.dsc
gpg: keyring `/home/solydxk/.gnupg/secring.gpg' created
gpg: keyring `/home/solydxk/.gnupg/pubring.gpg' created
gpg: skipped "unknown <solydxk@solydxk>": secret key not available
gpg: [stdin]: clearsign failed: secret key not available

 dpkg-genchanges  >../xfwm4compositeeditor_0.2.0-1_i386.changes
dpkg-genchanges: including full source code in upload
 dpkg-source --after-build xfwm4compositeeditor-0.2.0
dpkg-buildpackage: full upload (original source is included)
dpkg-buildpackage: warning: Failed to sign .dsc and .changes file
(of course we are assuming that all the needed building dependencies are installed, if they are not :mrgreen: the real fun begins)
bliss of ignorance

User avatar
Arjen Balfoort
Site Admin
Posts: 9009
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: [Howto] Packaging

Postby Arjen Balfoort » 11 Aug 2013 13:19

Thanks zerozero, I should read this too...on my todo list! :D


SolydXK needs you!
Development | Testing | Translations

User avatar
zerozero
Posts: 5373
Joined: 10 Feb 2013 23:37
Location: West Midlands, England
Contact:

Re: [Howto] Packaging

Postby zerozero » 11 Aug 2013 15:02

additionally if you ever face a situation like this http://forums.solydxk.nl/viewtopic.php? ... 137#p11337 (upload a deb that needs further adaptation of the control file) there's one way to do it without need to rebuild the compilation from scratch.

the easiest guide i found was this https://geekwentfreak-raviteja.rhcloud. ... b-package/
basically you just create a temp directory and move a copy of the deb(s) into there
cd as root into it and (here using homerun as an example)

Code: Select all

home temp # dpkg-deb -x homerun_0.2.3-1_amd64.deb dir_tmp

Code: Select all

home temp # dpkg-deb --control homerun_0.2.3-1_amd64.deb dir_tmp/DEBIAN
at this point you open the control file as root in a file editor (it's located at /temp/dir_tmp/DEBIAN) make the changes and save

Code: Select all

home temp # dpkg -b dir_tmp homerun_0.2.3-1_amd64.deb
rebuild the deb.
bliss of ignorance

williammanda
Posts: 39
Joined: 02 Dec 2013 17:18

Re: [Howto] Packaging

Postby williammanda » 05 Dec 2013 21:43

I'm coming from the ubuntu distro world and prior to that windows. Installing files / packages gets progressively more involved. It was an adjustment from windows to ubuntu and it seems another adjustment of lesser quantity to debian. Basically it seems that there are less packages for debian distros than ubuntu distros meaning there will be some compiling involved. Looking at this tutorial...is this the expected process that I would need to follow each time I found some software that I wanted to use but wasn't already packaged?

User avatar
hushpuppy
Posts: 91
Joined: 02 Mar 2013 12:47

Re: [Howto] Packaging

Postby hushpuppy » 22 Dec 2013 12:13

The latest version of the Debian New Maintainers' Guide, was published this morning. This guide is authoritative, except where it isn't, in which case the debian docs it links to are. It pretty much covers every aspect of packaging and maintenance: getting started, setting up dh_make and quilt, required files, package building, updating, and patching.
Ohne Musik wäre das Leben ein Irrtum (Without music, life would be a mistake) - Friedrich Nietzsche

User avatar
zerozero
Posts: 5373
Joined: 10 Feb 2013 23:37
Location: West Midlands, England
Contact:

Re: [Howto] Packaging

Postby zerozero » 22 Dec 2013 12:16

i'm reading it now ;) (thanks for the heads-up)
lots of great stuff in there
bliss of ignorance

User avatar
kobros
Posts: 194
Joined: 28 Nov 2013 14:48
Location: Netherlands

Re: [Howto] Packaging

Postby kobros » 22 Dec 2013 15:35

hushpuppy wrote:The latest version of the Debian New Maintainers' Guide, was published this morning. [.............]
Thanks hushpuppy.
Linux User #312596.
Mepis/Debian/antiX/MX/Win7

User avatar
hushpuppy
Posts: 91
Joined: 02 Mar 2013 12:47

Re: [Howto] Packaging

Postby hushpuppy » 23 Dec 2013 19:01

zerozero wrote:i'm reading it now ;) (thanks for the heads-up)
lots of great stuff in there
Skimming through it, it's okay at explaining the basics, but not very good at what to do when things don't work. I was also hoping for something a bit deeper since I can see little point in using quilt if it cannot generate fuzz-free patches.

I'd also love to know how a package as complex as razorqt is created, with all of its interdependences, and how inheritance in the debian/control and other files work in multiple-binary debs. I'd like to know what project management tools are used. I can see all the .ex files but, in various packages I've looked at, there appears to be no standard methodology. I guess I'm old-school, because I would like to see some flow charts that explain how it all hangs together. Of course, given the complexity of debhelper, dpkg, quilt, a multitude of languages, and everything else, that's probably impossible. And that's without mentioning all the bugs these systems come with.

On the up-side, there are packages available to make sure we have the latest documentation. A meta-package would be nice so that we could get all of them in one go, or they could all have a common prefix to make them easier to find. And, because it's debian, there's another documentation sub-section for the same thing on the website, as well as a subsection for books.

As always, if in doubt, rtfm. The question is, which one?

ETA: Raphael Herzog (the man behind quilt 3.0) has a set of debian packaging tutorials that explains, inter alia, how quilt works.

As always, if at first you don't succeed, blame someone else :twisted:

ETA: Herzog with Roland Mas also wrote the Debian Administrator's Handbook, which is also available as a package. Chapter 15 is the most relevant for this howto:

Code: Select all

15. Creating a Debian Package
15.1. Rebuilding a Package from its Sources
15.1.1. Getting the Sources
15.1.2. Making Changes
15.1.3. Starting the Rebuild
15.2. Building your First Package
15.2.1. Meta-Packages or Fake Packages
15.2.2. Simple File Archive
15.3. Creating a Package Repository for APT
15.4. Becoming a Package Maintainer
15.4.1. Learning to Make Packages
15.4.2. Acceptance Process
Sourceforge also hosts some GUIs for package management:As always, if the man page doesn't exist, learn roff and write it yourself :geek:

ETA: And because a picture paints a thousand words:

Code: Select all

# debtree -b -I --no-recommends --no-alternatives --no-provides --no-versions --no-conflicts --condense razorqt > e.dot && dot -Tsvg e.dot -o dep-graph-razorqt.svg
debtree can create dependency graphs.
dep-graph-razorqt.svg.gz
build-depends dependency graph
(24.86 KiB) Downloaded 372 times
In this one, even though the package builds without a problem, I can easily see three dependences that haven't been met, and at least one with gnome dependences that I might want to get rid of.
Ohne Musik wäre das Leben ein Irrtum (Without music, life would be a mistake) - Friedrich Nietzsche

User avatar
Arjen Balfoort
Site Admin
Posts: 9009
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: [Howto] Packaging

Postby Arjen Balfoort » 29 Jan 2014 14:12

I wasn't able to install kcm-ufw on the business editions: it was compiled with a newer libc6.
So, I used our BE to recompile it from source.

These are the steps I had to take:
  1. Install these:

    Code: Select all

    sudo apt install packaging-dev dh-make kdelibs5-dev
  2. Downloaded the source: http://craigd.wikispaces.com/
  3. Unpacked it, replaced the "_" with "-" in the directory name
  4. cd'd into that folder
  5. Code: Select all

    dh_make --createorig
  6. Adapt the control file:

    Code: Select all

    nano debian/control
    , and add python-ufw as a Recommends (only exists in testing).
  7. Build the package:

    Code: Select all

    dpkg-buildpackage
Installed, and tested on BE, but needs further testing.
Attachments
kcm-ufw_0.4.3-1_amd64.deb
(843.63 KiB) Downloaded 160 times


SolydXK needs you!
Development | Testing | Translations

Deleted User 2763

Re: [Howto] Packaging

Postby Deleted User 2763 » 29 Jan 2014 14:33

Cool.
Thanks for the post.
-H

Monti
Posts: 25
Joined: 28 Feb 2015 02:02

Re: [Howto] Packaging

Postby Monti » 05 Mar 2015 15:25

Thanks guys!


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 2 guests