Build Service/Deb builds
From openSUSE
Contents |
Debian Builds
This page will provide info on packaging for the debian based linux distributions supported by the openSUSE Build Service, namely:
- Debian
- Debian Etch
- xUbuntu
- xUbuntu 6.06
- xUbuntu 7.04
- xUbuntu 7.10
Debian packages are divided in two great categories: binary and source. The binary packages has .deb extension and they contains the compiled version of the application you want to distribute. While, the source packages are not a single file (like source .rpm mechanism), but instead they are composed by three files:
- the pristine tarball
- a diff file
- a dsc file
An important note, is that the Build Service will not create a source repository for .deb-based distribution, but only the .deb will be created.
Hence, it is important to keep in mind because a 'standard' Debian repository is composed by at least two directory:
(your repository root) | +-binary +-source
while the Build Service will create directly the binary dir with the name of distribution (e.g. http://download.opensuse.org/repositories/home:/EmmeG/Debian_Etch/ correspond to binary dir and not to repository root... that it is http://download.opensuse.org/repositories/home:/EmmeG/ ).
Also, keep in mind that the three part for creating a source package are not needed in order to create a .deb package, but instead are necessary when you create a source repository and allow for automatically compiling and packaging on user's machine via apt-get.
Build Service will not create source repository, so you simple don't need to know how they are constructed and used.
Minimum set of files required to create .deb
In order to create a .deb package successfully, you have to create at least these files:
- packageName.dsc
- debian.changelog
- debian.control
- debian.rules
And of course a tarball (tar.bz2) that contains the package source code to compile.
packageName.dsc
A minimal template for this file is:
Format: 1.0 Source: packageName Version: 5.6-3 Binary: packageName Maintainer: FirstName LastName <email@hostname.org> Architecture: any Build-Depends: debhelper (>= 4.1.16), nameOfPackageNeededToBuildIt Files: d57283ebb8157ae919762c58419353c8 133282 packageName_5.6.orig.tar.gz 2fecf324a32123b08cefc0f047bca5ee 63176 packageName_5.6-1.diff.tar.gz
In the above template are listed only the mandatory fields, but there are many optional fields. You can find all information about these fields at http://www.debian.org/doc/debian-policy/ch-controlfields.html
I report here a summary for let you to understand what they means:
- Format : is the format version of the .deb package. Write 1.0
- Source : is the name of source package without .tar.bz2
- Version : is composed by the version of the source and the revision of the package; in the template 5.6 is the version of the source code, while 3 (after '-') is the revision of the debian package. Everytime you change one of the files necessary to create a .deb you should increment it
- Binary : is the name of binary package as seen by the apt manager (e.g: for install it you specify apt-get install theNameYouWriteInBinaryField )
- Maintainer : is the name of source maintanier (not your name, or packager name)
- Architecture : the list of architecture you want to compile it
- Build-Depends : the library necessary for compile it. You Must specify 'debhelper (>= 4.1.16)' because it contains all helper script used by the system for compile
- Files: in theory you must specify the MD5SUM and dimension in byte of the .orig.tar.gz and .diff.tar.gz, but in practice just put some values, is not important if they are not correct... the important is that there are two lines with three field as showed in the template. (e.g. you can cat and paste the two lines in the template and substitute packageName with the name of the .deb you want to create and it's ok... Build Service will do the rest)
debian.changelog
The Debian mechanism for creating a .deb is to put inside the source tree a directory called 'debian' with a lot of file necessary to automize the compiling and packaging process.
You don't neet to do it by yourself, the Build Service will create the directory for you and it will put all files called debian.fileName
This is valid for all .deb-based distribution!! Hence, also for Ubuntu repository you have to create a file called debian.changelog (and not ubuntu.changelog).
This is the minimal template:
packageName (5.6-3) stable; urgency=low * Initial Release -- YourName <youremail@hostname.de> Mon, 25 Dec 2007 10:50:38 +0100
You could think that it's just a changelog... but the syntax is so constrained that a little error (a whitespace missing) that all process of creating package fails !! :-( So, pay attention to the syntax specificed at http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
debian.control
This file are used to describe the package and the dependencies, this if a minimal template:
Source: packageName
Section: sectionName
Priority: optional
Maintainer: yourName <yourEmail@hostname.de>
Build-Depends: debhelper (>= 4.1.16), nameOfPackageNeededToBuildIt
Package: nameOfPackage
Architecture: any
Depends: ${shlibs:Depends}
Description: This first line is a brief description
Then, here there is the long description of the package...
also here the syntax is very painful (look at the documentation of Debian Policy
to avoid errors http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description)
Here there are some informations redundant that you can copy from .dsc file: 'Build-Depends', 'Package' is the same of 'Binary', 'Architecture', 'Maintainer' typically is the same of last list of debian.changelog
debian.rules
This is a Makefile style files that contains all rule for extracting, compile, install and package the source. You can change want you want inside this file... but is more simple to change just some lines to compile it... the rest of the file can be left untouched.
#!/usr/bin/make -f # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # This is the debhelper compatibility version to use. export DH_COMPAT=4 CFLAGS = -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif build: build-stamp build-stamp: dh_testdir # Add here commands to compile the package. ./configure make all # --- end custom part for compiling touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp # Add here commands to clean up after the build process. make clean # --- end custom part for cleaning up dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package # The DESTDIR Has To Be Exactly /usr/src/packages/BUILD/debian/debian/<nameOfPackage> make install DESTDIR=/usr/src/packages/BUILD/debian/ace # --- end custom part for installing # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot # dh_installdebconf dh_installdocs dh_installexamples dh_installmenu # dh_installlogrotate # dh_installemacsen # dh_installpam # dh_installmime # dh_installinit dh_installcron dh_installman dh_installinfo # dh_undocumented dh_installchangelogs dh_link dh_strip dh_compress dh_fixperms # dh_makeshlibs dh_installdeb # dh_perl dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install
Configuring sources.list
After the creation of .deb packages, you want to add the repository in the sources.list in order to use apt-get to intall your package.
For example, if you want to add my repository to a Debian distro, add the following line to sources.list:
deb http://download.opensuse.org/repositories/home:/EmmeG/Debian_Etch ./
For Ubuntu change the last field with the Ubuntu directory
deb http://download.opensuse.org/repositories/home:/EmmeG/xUbuntu_7.10 ./
BUT IF YOU RUN APT-GET UPDATE, YOU'LL GET AN ERROR In fact, when apt-get try to fetch data from http://download.opensuse.org/repositories/home:/EmmeG/ the main server reply with an HTTP redirection (302), and apt-get consider this an error!!!
Unluckly, is not a bug of apt-get... is a decision of apt developers; they consider a very unsafe choose to use 302 redirection for packages repository (why ?!?! they don't tell to us, they just said that it's unsafe)
But you can solve this problem in two ways:
- if you have a server, mirror the repository on your space and point users to that
- search on http://en.opensuse.org/Mirrors_Development_Build a server that mirror your repository and point users to that (hoping that the mirror is permanent)
Examples
You can see examples in my home project directory: https://build.opensuse.org/project/show?project=home%3AEmmeG
The quick way
You probably already have a package.tar.bz2 file that you use for your RPM distros, in order to reuse it for the debian based builds and to avoid all the trouble of the steps mentioned above, just do the following:
# grab the .dsc file from http://packages.debian.org/ and rename it to package.dsc # grab the .diff.gz file from http://packages.debian.org/ # extract the .diff file to an empty directory # extract the pacth with "patch -p0 < filename" it will create a "debian/" subdirectory # move the .changelog file out of the debian directory and rename it to package.changes # compress the debian/ directory into a debian.tar.gz file # upload the debian.tar.gz, package.changes and package.dsc to the buildservice.
NOTE: Replace "package" with the name of your package in the above description.
That's it, all debian based builds should work fine now. To do updates, just upload a new pristine package.tar.bz2 file, edit the package.changes file and trigger rebuild.

