Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

HowTo Build a Package from Source the Smart Way

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Message
Author
harishankar
Posts: 75
Joined: 2006-09-17 06:43

Re: HowTo Build a Package from Source the Smart Way

#31 Post by harishankar »

Thanks Hadret. I've not yet found how exactly to use python-support.

Is there a full tutorial on this subject anywhere online? Every packaging tutorial for Debian uses the standard debian utils. Even the tutorials for python apps don't rely on python-support.

By the way, there is a confusion: they say python-support and python-central should be used only for packaging python libraries/modules and not application/scripts. Is this true?

harishankar
Posts: 75
Joined: 2006-09-17 06:43

Re: HowTo Build a Package from Source the Smart Way

#32 Post by harishankar »

Here's where I am really confused about packaging for Python applications and not a single answer have I found online:

1. How should privately used application modules be handled by distutils? Does distutils provide method for handling private modules? py_modules seem to be for public modules and doesn't seem the right way to package an application.
OR
2. Should I give up distutils and use a standard Makefile instead of using python distutils at all when packaging for Debian?

3. Which is ultimately the easiest and most sane method of python application packaging in Debian? There seem to be an infinite number of policies, rules and instructions which all add up to giving me a headache. :oops:

I've looked at so many documents and help files online, but not a single one is comprehensive enough to give me a clue about the right way of doing things. The official Debian documentation is confusing, very long and doesn't provide step by step instructions on Python packages.

harishankar
Posts: 75
Joined: 2006-09-17 06:43

Re: HowTo Build a Package from Source the Smart Way

#33 Post by harishankar »

I've gone ahead and used the distutils/CDBS method as outlined here: https://wiki.edubuntu.org/PackagingGuide/Python

I'm not sure it's the right "Debian" way, but it seems the easiest method so far.

User avatar
Hadret
Posts: 354
Joined: 2007-07-19 13:04
Location: Berlin

Re: HowTo Build a Package from Source the Smart Way

#34 Post by Hadret »

I'm packaging gwibber application for Debian and, as you may guess, it's python app. As I said before - you can use CDBS, but if you want to see your package in Debian repositories, sooner or later you will have to move it to python-support. If you still want to use CDBS you should look into gwibber package for Ubuntu - it's using CDBS (you could also collate Ubuntu package with Debian package). I think that page to which link I have provided earlier is a bit outdated, but it's still good source for learning how to build python application packages.

Let's look into gwibber source, shall we?

Code: Select all

dget -x http://mentors.debian.net/debian/pool/main/g/gwibber/gwibber_1.2.0+bzr352-1.dsc
Now let's go into debian/ folder and see what do we've got there. Files which are relevant for us are debian/control and debian/rules. Don't hesitate to open them in your favorite editor. Which parts are important? I will bold them:
debian/control

Source: gwibber
Section: gnome
Priority: optional
Build-Depends: debhelper (>=7)
Build-Depends-Indep: python (>=2.5.4), python-distutils-extra, python-support (>=1.0)
Standards-Version: 3.8.1

Package: gwibber
Architecture: all || assuming that your package is arch independent ||
Depends: ${misc:Depends}, ${python:Depends}
debian/rules

#!/usr/bin/make -f

build:

clean:
dh_testdir
dh_testroot

rm -rf build
dh_clean install-stamp

install: install-stamp

install-stamp:
dh_testdir
dh_testroot
dh_prep
dh_installdirs

python setup.py install --root=$(CURDIR)/debian/pkg-name || assuming that you've got setup.py for your python app ||
touch $@

binary-arch:

binary-indep: install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installman pkg-name.1 || assuming that you've got man page for your package ||
dh_pysupport
dh_compress
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
As you see, it's not really harder than CDBS, is it? (:

Remember that this is only example and there are paths that you need to edit, and there might be some options that you will need enter but... I think that after some small changes, this should work (:

It's also a good idea to look into some other debian packages of python application sources.

harishankar
Posts: 75
Joined: 2006-09-17 06:43

Re: HowTo Build a Package from Source the Smart Way

#35 Post by harishankar »

Thanks.

The above is basically the Makefile approach + python distutils right?

I was greatly confused about why we invoke python-support here... This is where my confusion arose from.

It is said that you can use CDBS + python-support or python-central.

So what is the difference between the methods highlighted by you and the one at Ubuntuwiki? Is it only the fact that we are writing our own rules file and not importing the one from CDBS?

I'm sorry if I write incoherently and confused, because I am. I read too many docs recently and it's all swimming in my head.

User avatar
Hadret
Posts: 354
Joined: 2007-07-19 13:04
Location: Berlin

Re: HowTo Build a Package from Source the Smart Way

#36 Post by Hadret »

I'm sorry, it's my bad! I wasn't thinking about CDBS but python-central - use python-support NOT python-central. Using CDBS isn't something bad, but not every sponsor/maintainer likes it. Check this out for more informations: http://wiki.debian.org/Games/ToolsDiscuss/CDBS.

Here you can find some examples for python applications on Debian: http://wiki.debian.org/DebianPython/NewPolicy and http://wiki.debian.org/DebianPython.

One more time - I'm sorry for writing wrong informations about CDBS and making you more confused! :oops:

User avatar
stoffepojken
Posts: 705
Joined: 2007-01-25 01:21
Location: Stockholm, Sweden

Re: HowTo Build a Package from Source the Smart Way

#37 Post by stoffepojken »

Hadret wrote:I'm packaging gwibber application for Debian and, as you may guess, it's python app. As I said before - you can use CDBS, but if you want to see your package in Debian repositories, sooner or later you will have to move it to python-support. If you still want to use CDBS you should look into gwibber package for Ubuntu - it's using CDBS (you could also collate Ubuntu package with Debian package). I think that page to which link I have provided earlier is a bit outdated, but it's still good source for learning how to build python application packages.

Let's look into gwibber source, shall we?

Code: Select all

dget -x http://mentors.debian.net/debian/pool/main/g/gwibber/gwibber_1.2.0+bzr352-1.dsc
Now let's go into debian/ folder and see what do we've got there. Files which are relevant for us are debian/control and debian/rules. Don't hesitate to open them in your favorite editor. Which parts are important? I will bold them:
debian/control

Source: gwibber
Section: gnome
Priority: optional
Build-Depends: debhelper (>=7)
Build-Depends-Indep: python (>=2.5.4), python-distutils-extra, python-support (>=1.0)
Standards-Version: 3.8.1

Package: gwibber
Architecture: all || assuming that your package is arch independent ||
Depends: ${misc:Depends}, ${python:Depends}
debian/rules

#!/usr/bin/make -f

build:

clean:
dh_testdir
dh_testroot

rm -rf build
dh_clean install-stamp

install: install-stamp

install-stamp:
dh_testdir
dh_testroot
dh_prep
dh_installdirs

python setup.py install --root=$(CURDIR)/debian/pkg-name || assuming that you've got setup.py for your python app ||
touch $@

binary-arch:

binary-indep: install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installman pkg-name.1 || assuming that you've got man page for your package ||
dh_pysupport
dh_compress
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
As you see, it's not really harder than CDBS, is it? (:

Remember that this is only example and there are paths that you need to edit, and there might be some options that you will need enter but... I think that after some small changes, this should work (:

It's also a good idea to look into some other debian packages of python application sources.
Hi Hadret

Will we see gwibber in Sid anytime soon?

harishankar
Posts: 75
Joined: 2006-09-17 06:43

Re: HowTo Build a Package from Source the Smart Way

#38 Post by harishankar »

Thanks. Now I understand. Yes, I think python-support seems to be the better bet at the moment.

Also I'll try to avoid using CDBS and doing it the manual way next time. I agree with a lot of the sentiments on the Debian wiki. CDBS *is* a bit of black magic and hides too much behind the scenes. However, it does provide a very simple method of creating a package when you just need a very simple and straightforward mechanism.

I think I'll look at some official Python software packaged in Debian and see how they do it.

User avatar
Hadret
Posts: 354
Joined: 2007-07-19 13:04
Location: Berlin

Re: HowTo Build a Package from Source the Smart Way

#39 Post by Hadret »

stoffepojken wrote:Will we see gwibber in Sid anytime soon?
I certainly hope so (: http://ftp-master.debian.org/new/gwibbe ... 350-2.html
harishankar wrote:I think I'll look at some official Python software packaged in Debian and see how they do it.
This is one of the best ways of learning IMO. You can also look here, find some package that you'd like to adopt into Debian and ask for help on mentors.d.n. When you will find mentor, he will explain to you all the black magic, not only the CDBS one (:

User avatar
kanonmat
Posts: 59
Joined: 2008-10-28 21:33
Location: Linköping, Sweden

Re: HowTo Build a Package from Source the Smart Way

#40 Post by kanonmat »

(Originally I was going to compile htpdate, as my ISP blocks ntp. What's up with that? o.O )
Following this guide I'm trying with the backintime example and get the following errors:
1. Some key error with gpgv. It doesn't help to add ED75F599 with seahorse. (apt-get source backintime as root gives an error too.)
2. dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit status 2

Running "apt-get build-dep backintime" shows I have the needed dependencies.

Code: Select all

[~/bin/paket/backintime]$ apt-get source backintime
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Need to get 877kB of source archives.
Get:1 http://ftp.sunet.se sid/main backintime 0.9.26-1 (dsc) [1243B]
Get:2 http://ftp.sunet.se sid/main backintime 0.9.26-1 (tar) [872kB]
Get:3 http://ftp.sunet.se sid/main backintime 0.9.26-1 (diff) [3445B]
Fetched 877kB in 1s (783kB/s)      
gpgv: keyblock resource `/home/duke/.gnupg/trustedkeys.gpg': general error
gpgv: Signature made Tue 19 May 2009 10:17:24 PM CEST using DSA key ID ED75F599
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./backintime_0.9.26-1.dsc
dpkg-source: info: extracting backintime in backintime-0.9.26
dpkg-source: info: unpacking backintime_0.9.26.orig.tar.gz
dpkg-source: info: applying backintime_0.9.26-1.diff.gz


[~/bin/paket/backintime]$ cd backintime-0.9.26/
[~/bin/paket/backintime/backintime-0.9.26]$ dpkg-buildpackage -rfakeroot -us -uc
dpkg-buildpackage: set CFLAGS to default value: -g -O2
dpkg-buildpackage: set CPPFLAGS to default value: 
dpkg-buildpackage: set LDFLAGS to default value: 
dpkg-buildpackage: set FFLAGS to default value: -g -O2
dpkg-buildpackage: set CXXFLAGS to default value: -g -O2
dpkg-buildpackage: source package backintime
dpkg-buildpackage: source version 0.9.26-1
dpkg-buildpackage: source changed by Jonathan Wiltshire <debian@jwiltshire.org.uk>
dpkg-buildpackage: host architecture amd64
 fakeroot debian/rules clean
dh clean 
   dh_testdir
   dh_auto_clean
   dh_clean
rm -rf locale common/po/*.mo
find /home/duke/bin/paket/backintime/backintime-0.9.26 -name "*\.py[co]" -delete
rm -f common/Makefile gnome/Makefile kde4/Makefile
 dpkg-source -b backintime-0.9.26
dpkg-source: info: using source format `1.0'
dpkg-source: info: building backintime using existing backintime_0.9.26.orig.tar.gz
dpkg-source: info: building backintime in backintime_0.9.26-1.diff.gz
dpkg-source: info: building backintime in backintime_0.9.26-1.dsc
 debian/rules build
dh build
   dh_testdir
   debian/rules override_dh_auto_configure
make[1]: Entering directory `/home/duke/bin/paket/backintime/backintime-0.9.26'
cd common && ./configure
All OK. Now run:
    make
    sudo make install
cd gnome && ./configure --no-check
All OK. Now run:
    make
    sudo make install
cd kde4 && ./configure --no-check 
All OK. Now run:
    make
    sudo make install
make[1]: Leaving directory `/home/duke/bin/paket/backintime/backintime-0.9.26'
   dh_auto_build
   dh_auto_test
 fakeroot debian/rules binary
dh binary
   dh_testroot
   dh_prep
   dh_installdirs
   debian/rules override_dh_auto_install
make[1]: Entering directory `/home/duke/bin/paket/backintime/backintime-0.9.26'
cd common && DESTDIR=../debian/backintime-common /usr/bin/make install
make[2]: Entering directory `/home/duke/bin/paket/backintime/backintime-0.9.26/common'
Makefile:3: *** missing separator.  Stop.
make[2]: Leaving directory `/home/duke/bin/paket/backintime/backintime-0.9.26/common'
make[1]: *** [override_dh_auto_install] Error 2
make[1]: Leaving directory `/home/duke/bin/paket/backintime/backintime-0.9.26'
make: *** [binary] Error 2
dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit status 2


[~/bin/paket/backintime/backintime-0.9.26]$ ls
AUTHORS  common/  gnome/  LICENSE      maketar.sh  README  TRANSLATIONS      VERSION
CHANGES  debian/  kde4/   makedeb.sh*  plugins/    TODO    updateversion.sh
I have a look with tree. As I dont have gnome or kde, I try to run:

Code: Select all

[~/bin/paket/backintime/backintime-0.9.26]$ ./common/backintime &
python: can't open file '/usr/share/backintime/common/backintime.py': [Errno 2] No such file or directory
[1] 11890
There is a makedeb.sh and there are other executables, are those of any use?
phenomII965, gigabyte ma790xt-ud4p, 8600gt on desktop
hp 6910p laptop. athlon 3200+, asus an8e, 6600gt on spare desktop
sid user

frank56
Posts: 193
Joined: 2009-03-27 17:51

Re: HowTo Build a Package from Source the Smart Way

#41 Post by frank56 »

This has got to be a basic aka as dumb question, but what the heck does CODE: Select ALL mean? is that a prompt that comes with some linux programs. I expect to see a list with some check boxes to "Select" Frank
Hi! my name if Frank. I have tried before to jump into linux about 8 years ago, but gave up after not being able to get hardware going. Now I will try again, and feel a need to learn to do more from the command line Frank

harishankar
Posts: 75
Joined: 2006-09-17 06:43

Re: HowTo Build a Package from Source the Smart Way

#42 Post by harishankar »

frank56 wrote:This has got to be a basic aka as dumb question, but what the heck does CODE: Select ALL mean? is that a prompt that comes with some linux programs. I expect to see a list with some check boxes to "Select" Frank
No, it's the forum system's interface. If you click "Select all" all the code in the code box will be selected. It's to allow you to easily copy the code posted by others. :D

frank56
Posts: 193
Joined: 2009-03-27 17:51

Re: HowTo Build a Package from Source the Smart Way

#43 Post by frank56 »

I am trying to follow the steps to build a deb package for chestnut-dialer. Steps 1-4 dont seem to match the steps below
"To be more specific" Step 2 says to download the source, I take that to mean for me download chestnut-dialer from sourceforge, but the steps below "to be more specific" are quite diffrent. Here are the errors I am getting so far. Perhaps because I dont understand the steps.

franksnetwork:/home/frank# apt-get build-dep chestnut-dialer

Reading package lists... Done

Building dependency tree

Reading state information... Done

E: Could not open file /var/lib/apt/lists/ftp.us.debian.org_debian_dists_sid_main_source_Sources - open (2 No such file or directory)

Also where "package" and or xxxx is specified in this example do I put complete file name, in this case its
chestnut-dialer-0.3.2-0.3 or can I just put chestnut-dialer ?

franksnetwork:/home/frank#
Hi! my name if Frank. I have tried before to jump into linux about 8 years ago, but gave up after not being able to get hardware going. Now I will try again, and feel a need to learn to do more from the command line Frank

Stian1979
Posts: 316
Joined: 2007-07-29 14:57

Re: HowTo Build a Package from Source the Smart Way

#44 Post by Stian1979 »

Then you would run:

Code: Select all

make 
su -c checkinstall -D make install
The trouble with checkinstall is that it does not Debian-ize the source or understand package dependencies. It simply keeps track of the files that the DEB contains.

It also annoys me that the files are installed at the same time that the package is built. (That's why you have to become root to use the checkinstall command). I wish it would just build the DEB and then let me decide when I want to install it.
I want to make a deb from gspca, would this be the way to go?
I tryed, but got errors.
Image
Debian Bullseye

frank56
Posts: 193
Joined: 2009-03-27 17:51

Re: HowTo Build a Package from Source the Smart Way

#45 Post by frank56 »

This post helped me successfully debianize a project from sourceforge.net A NON DEBIAN Source. I regret not listening to

"If you're really eager to compile and there is no Debian-ized source in Unstable or Testing, you can still build a DEB package by using dh-make. " I was going around in circles avoiding dh-make. Thanks to Soul Singing for this great post
And to so many others on this site for helping me accomplish this finally. As my hill billy friend said, 2 heads are better than one even as one of them is a sheeps head, bah bah, or whaterver sound a sheep makes.

Again, as great as this post is, I could not have got Klavaro typing tutor up and running without so many that helped me on this project. I think I will try chestnut-dialer next.

So if you are debianizing, from a NON deb source use dh-make. I was confused, I didnt think a deb source should need "debianizing". Also I used bugsbunny tar -xjvf xxxxx.tar.bz2 for my file and I followed Soul Singers example for PDFEDit
on this same post he puts a link. I am so happy, and great full I would like to post this in General but, that could be double posting. Frank
Hi! my name if Frank. I have tried before to jump into linux about 8 years ago, but gave up after not being able to get hardware going. Now I will try again, and feel a need to learn to do more from the command line Frank

frank56
Posts: 193
Joined: 2009-03-27 17:51

Re: HowTo Build a Package from Source the Smart Way

#46 Post by frank56 »

I followed the example in this link, for building a package from non debian source. I can run my program chestnut dialer from terminal but I am lost, about what I have to do to configure the front end for gnome, or gtk2...Frank
Hi! my name if Frank. I have tried before to jump into linux about 8 years ago, but gave up after not being able to get hardware going. Now I will try again, and feel a need to learn to do more from the command line Frank

User avatar
Soul Singin'
Posts: 1605
Joined: 2008-12-21 07:02

Re: HowTo Build a Package from Source the Smart Way

#47 Post by Soul Singin' »

julian67 wrote:A useful addition to the first post would be on applying patches.
While editing my original post, I spent some time thinking about this suggestion. It would be nice to include information about how to patch the source code.

The trouble is that different packages use different patch maintenance systems (e.g. dpatch, quilt, cdbs and dbs). A proper discussion of patching would describe each method and is therefore outside the scope of the original post (which is to explain the various methods of building a package from source).

As a person gains more experience building DEB packages, he/she will encounter the various methods and learn how to use them. For beginners, simply building a DEB package is an achievement, so I would prefer to teach them how to walk before teaching them how to run.
harishankar wrote:I request you to include information on how exactly to package small Python programs (not shared modules) for Debian.
From the responses, it appears that this would be an excellent topic for another HowTo. Unfortunately, I won't be able to help you write that one because I don't know anything about Python.
.

User avatar
obeliks
Posts: 14
Joined: 2009-02-14 19:51
Location: Finland

Re: HowTo Build a Package from Source the Smart Way

#48 Post by obeliks »

Thank you very much for your post. I just printed this. I only print the very best of Howtos. :D
Image

User avatar
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: HowTo Build a Package from Source the Smart Way

#49 Post by dbbolton »

You need to install the "devscripts" package to use debchange/dch.
GitHub | zsh docs in Letter PDF
Telemachus wrote:Put down the CGI.

User avatar
actionM
Posts: 890
Joined: 2007-05-01 02:11

Re: HowTo Build a Package from Source the Smart Way

#50 Post by actionM »

Thanks Soul Singin' for the help guide! I just compiled something besides a kernel for the first time! It was dropbox. Can't live without the dropbox.
--------------------
Debian Lenny - Xfce4

Post Reply