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

netanel_h
Posts: 4
Joined: 2009-09-15 09:10
Location: Israel

Re: HowTo Build a Package from Source the Smart Way

#51 Post by netanel_h »

I want to add a small but very imoprtant (in my opinion) tip, which can save a lot of time during build packages from large amount of source code (e.g. building OpenOffice).
When we compile something and at the middle we get some error which stop the build process, if we will start the build again after fixing the problem, as default there is a clean stage at the start of the build, and all what has done till the error is deleted. Morever, we can't test our fix till the compilation pass all the stages till the error. After all the waste of the time, maybe our fix isn't fix at all and we get the same error again... :(

However, dpkg-buildpackage has an -nc attribute, which means building without clean stage at the begining. That means the build is continued after some needed stages from the stage we got the error. This attribute can save a lot of time for humans, and a large amount of "blood, toil, tears, and sweat" from our unfortunate computer.

Just:

Code: Select all

dpkg-buildpackage -rfakeroot -nc

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: HowTo Build a Package from Source the Smart Way

#52 Post by llivv »

Thanks for the over emphisis, I'm still a noob when it comes to compiling from source. And knowing this, i've only attempted it a few times up until reading your tutorial...

I have a question because in my haste and inexperience I use apt as root when downloading the source.
I built the deb with the source owned by root, but noticed that before I installed.
If I installed uzbl_0.0.0~git.20100105-1_i386.deb with dpkg would the programs permissions be different
than if I built the same deb with source owned by user.
I'm thinking I should start over and get some practice at doing these things the right way.
  • drwxr-xr-x 9 root root 880 Jan 17 19:29 uzbl-0.0.0~git.20100105
    -rw-r--r-- 1 root root 6703 Jan 17 19:29 uzbl_0.0.0~git.20100105-1.diff.gz
    -rw-r--r-- 1 root root 1102 Jan 17 19:29 uzbl_0.0.0~git.20100105-1.dsc
    -rw-r--r-- 1 root root 3674 Jan 17 19:29 uzbl_0.0.0~git.20100105-1_i386.changes
    -rw-r--r-- 1 root root 145064 Jan 17 19:29 uzbl_0.0.0~git.20100105-1_i386.deb
    -rw-r--r-- 1 root root 133875 Jan 6 22:18 uzbl_0.0.0~git.20100105.orig.tar.gz
I want to test your method using this source as well from the Authors github
  • drwxr-xr-x 8 llivv llivv 672 Jan 5 19:59 .
    drwxr-xr-x 96 llivv llivv 9928 Jan 17 20:52 ..
    -rw-r--r-- 1 llivv llivv 3551 Jan 5 19:59 AUTHORS
    -rw-r--r-- 1 llivv llivv 19698 Jan 5 19:59 callbacks.c
    -rw-r--r-- 1 llivv llivv 3444 Jan 5 19:59 callbacks.h
    -rw-r--r-- 1 llivv llivv 486 Jan 5 19:59 config.h
    drwxr-xr-x 2 llivv llivv 328 Jan 5 19:59 docs
    -rw-r--r-- 1 llivv llivv 5823 Jan 5 19:59 events.c
    -rw-r--r-- 1 llivv llivv 820 Jan 5 19:59 events.h
    drwxr-xr-x 4 llivv llivv 96 Jan 5 19:59 examples
    drwxr-xr-x 8 llivv llivv 328 Jan 5 19:59 .git
    -rw-r--r-- 1 llivv llivv 91 Jan 5 19:59 .gitattributes
    -rw-r--r-- 1 llivv llivv 60 Jan 5 19:59 .gitignore
    -rwxr-xr-x 1 llivv llivv 699 Jan 5 19:59 hash.sh
    -rw-r--r-- 1 llivv llivv 3233 Jan 5 19:59 inspector.c
    -rw-r--r-- 1 llivv llivv 78 Jan 5 19:59 inspector.h
    -rw-r--r-- 1 llivv llivv 35147 Jan 5 19:59 LICENSE
    -rw-r--r-- 1 llivv llivv 4389 Jan 5 19:59 Makefile
    drwxr-xr-x 2 llivv llivv 240 Jan 5 19:59 misc
    -rw-r--r-- 1 llivv llivv 28101 Jan 5 19:59 README
    drwxr-xr-x 2 llivv llivv 72 Jan 5 19:59 sandbox
    drwxr-xr-x 2 llivv llivv 136 Jan 5 19:59 tests
    -rwxr-xr-x 1 llivv llivv 1933 Jan 5 19:59 uzbl-browser
    -rw-r--r-- 1 llivv llivv 86974 Jan 5 19:59 uzbl-core.c
    -rw-r--r-- 1 llivv llivv 10165 Jan 5 19:59 uzbl-core.h
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

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

Re: HowTo Build a Package from Source the Smart Way

#53 Post by Soul Singin' »

llivv wrote:I have a question because in my haste and inexperience I use apt as root when downloading the source.
I built the deb with the source owned by root, but noticed that before I installed.
If I installed uzbl_0.0.0~git.20100105-1_i386.deb with dpkg would the programs permissions be different
than if I built the same deb with source owned by user.
I do not know, but I suspect that the permissions would be the same as they would be if you had built the DEB with "user-owned source." Here's my reasoning:
  • A DEB is a file that contains two tarballs (data.tar.gz and control.tar.gz) and a text file (debian-binary).
  • When a tarball is extracted, ownership of the files passed to the user that extracts the tar ball.
  • So when you install it (as root), the permissions should be given to root (i.e. just like they would be if you had built the DEB with "user-owned source").
Another reason to suspect that they would be the same stems from the fact that a normal user has to use fakeroot to build a DEB. So if you crack open a (properly built) DEB, you'll see that the files are owned by root. For example:

Code: Select all

[ Mon 18-Jan-2010 11.37 XXXX ] DEBs $ dpkg --contents barrybackup-gui_0.15-1~bpo50+1_i386.deb
drwxr-xr-x root/root         0 2009-12-20 04:02 ./
drwxr-xr-x root/root         0 2009-12-20 04:03 ./usr/
drwxr-xr-x root/root         0 2009-12-20 04:03 ./usr/bin/
-rwxr-xr-x root/root    166580 2009-12-20 04:03 ./usr/bin/barrybackup
drwxr-xr-x root/root         0 2009-12-20 04:03 ./usr/share/
drwxr-xr-x root/root         0 2009-12-20 04:02 ./usr/share/doc/
drwxr-xr-x root/root         0 2009-12-20 04:03 ./usr/share/doc/barrybackup-gui/
-rw-r--r-- root/root      2401 2009-12-20 03:52 ./usr/share/doc/barrybackup-gui/copyright
-rw-r--r-- root/root      1958 2009-12-20 03:53 ./usr/share/doc/barrybackup-gui/changelog.Debian.gz
-rw-r--r-- root/root     43624 2009-08-29 00:03 ./usr/share/doc/barrybackup-gui/changelog.gz
drwxr-xr-x root/root         0 2009-12-20 04:03 ./usr/share/barry/
drwxr-xr-x root/root         0 2009-12-20 04:03 ./usr/share/barry/glade/
-rw-r--r-- root/root     11733 2009-12-20 04:02 ./usr/share/barry/glade/BackupWindow.glade
-rw-r--r-- root/root     10825 2009-12-20 04:02 ./usr/share/barry/glade/ConfigDlg.glade
-rw-r--r-- root/root      5520 2009-12-20 04:02 ./usr/share/barry/glade/PasswordDlg.glade
-rw-r--r-- root/root      5807 2009-12-20 04:02 ./usr/share/barry/glade/PromptDlg.glade
-rw-r--r-- root/root      8457 2009-12-20 04:02 ./usr/share/barry/glade/DatabaseSelectDlg.glade
drwxr-xr-x root/root         0 2009-12-20 04:03 ./usr/share/man/
drwxr-xr-x root/root         0 2009-12-20 04:03 ./usr/share/man/man1/
-rw-r--r-- root/root      1344 2009-12-20 04:02 ./usr/share/man/man1/barrybackup.1.gz
drwxr-xr-x root/root         0 2009-12-20 04:02 ./usr/share/menu/
-rw-r--r-- root/root       219 2009-12-20 03:52 ./usr/share/menu/barrybackup-gui


Hope this helps,
- Soul Singin'
.

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: HowTo Build a Package from Source the Smart Way

#54 Post by llivv »

Yes, I believe I understand both your logic and your natural deductive reasoning.
Not everything is immediately apparent, although with a bit of thought it becomes clearer..

Before I read your tutorial, I had already tried to compile the uzbl souce from git several times.
It's a bit more complex than it appears at the beginning, as it's dependency list is quite large,
and just installing the binary version with apt doesn't bring the build deps needed, so I finally realized.
Thanks again for the tutorial, I will be reading it many times as I learn how to build form source.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

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

Re: HowTo Build a Package from Source the Smart Way

#55 Post by Soul Singin' »

llivv wrote:and just installing the binary version with apt doesn't bring the build deps needed, so I finally realized.
Hi Will,

Yes. "Package dependencies" and "build dependencies" are two different things.

Code: Select all

apt-get install whizbar

installs whizbar and the packages needed to run it.

Code: Select all

apt-get build-dep whizbar
installs the packages needed to build whizbar.

Happy DEB Building!,
- Soul Singin'
.

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: HowTo Build a Package from Source the Smart Way

#56 Post by llivv »

I built a new source directory for uzbl and got the source using apt as user...
I forgot to run apt-get build-dep, again so I ran it as a second step, I will remember to run apt-get build-dep first before downloading the source, to reinforce and emphize.
than I ran dpkg-buildpackage but I had misread my notes and used -vc instead of -uv at the end of the command. So I did it again. both times the source compiled without showing any errors.
I purged uzbl binary with aptitude and installed the deb I just built using your tutorial and dpkg -i uzbl_0.0.0~git.20100105-1_i386.deb
and I've been posting from it here all day.

I'm currently streaching my horizons using your tutorial on the git source..
I think I figured out what I forgot that caused a few compile errors. I need to run the dpkg-buildpackage command again with the proper arguments this time....
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: HowTo Build a Package from Source the Smart Way

#57 Post by stevepusser »

I've managed to package a few smaller Python packages from the raw source using the automagic powers of cdbs.

Shoot--can't find the Debian guide right now, but this Ubuntu guide is exactly the same procedure:

https://wiki.ubuntu.com/PackagingGuide/Python

cdbs also has a simple method of applying patches from devian/patches, it also works pretty much automagically.

Soul Singin' wrote:
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.
.
MX Linux packager and developer

milomak
Posts: 2158
Joined: 2009-06-09 22:20
Been thanked: 1 time

Re: HowTo Build a Package from Source the Smart Way

#58 Post by milomak »

the howto should make mention of the fact that you can change the compile options by editing debian/rules. and dependencies required can be changed by editing debian/control.
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid

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

Re: HowTo Build a Package from Source the Smart Way

#59 Post by Soul Singin' »

milomak wrote:the howto should make mention of the fact that you can change the compile options by editing debian/rules. and dependencies required can be changed by editing debian/control.
You mean like this ...
Soul Singin' wrote:You might then have to tweak the debian/rules file (e.g. to set configuration options) or set a shell variable. It all depends on the package in question.
Or like this ...
Soul Singin' wrote:To illustrate the point, I grabbed the upstream source for PDFedit and ran dh_make. I didn't do anything else. dh_make automatically produced the following debian/control file:

Code: Select all

Source: pdfedit
Section: unknown
Priority: extra
Maintainer: Xxxx Xxxxx <xxxx@xxxx>
Build-Depends: debhelper (>= 7), autotools-dev
Standards-Version: 3.7.3
Homepage: <insert the upstream URL, if relevant>

Package: pdfedit
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: <insert up to 60 chars description>
 <insert long description, indented with spaces>
In particular, notice the third line from the bottom. The list of package dependencies is automatically generated by the build process.


Granted the second quote comes from my response to Telemachus, but it's on the first page of this thread.

More importantly, my goal was not to provide a comprehensive guide to packaging. My goal was to help people start packaging. As a person starts packaging, he/she will quickly learn what the debian/rules and debian/control files are.
.

milomak
Posts: 2158
Joined: 2009-06-09 22:20
Been thanked: 1 time

Re: HowTo Build a Package from Source the Smart Way

#60 Post by milomak »

You might then have to tweak the debian/rules file (e.g. to set configuration options) or set a shell variable. It all depends on the package in question.
You'll notice it is under the section that deals with non-debianised source. seeing as i was dealing with debianised source i gave that part a miss.
Granted the second quote comes from my response to Telemachus, but it's on the first page of this thread.
if it were my HOW-TO I would edit the main post. I would think the point of a HOW-TO is to provide the information upfront.

All the above being said, your HOW-TO is a good one. It put me on the right path and the rest I was able to research using google.
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid

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

Re: HowTo Build a Package from Source the Smart Way

#61 Post by Soul Singin' »

milomak wrote:All the above being said, your HOW-TO is a good one. It put me on the right path and the rest I was able to research using google.
Glad it helped. I'll probably incorporate your suggestions (and the suggestions of others) at some point in the future. Right now, I'm short on time.

Thanks,
- Soul Singin'
.

badhat101
Posts: 27
Joined: 2010-08-18 20:55

Re: HowTo Build a Package from Source the Smart Way

#62 Post by badhat101 »

I'm following the guide but I get stuck building a package with dh_make. The dpkg-buildpackage always exits with the error

Code: Select all

dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit status 2
I'm not certain what to do with the debian/rules file. I'm assuming this is why I have the exit error upon building...

Any help?

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

Re: HowTo Build a Package from Source the Smart Way

#63 Post by Soul Singin' »

badhat101 wrote:I'm following the guide but I get stuck building a package with dh_make.
First, you should not post support questions in a HowTo thread. You should create a new thread.

Second, when you create a new thread, please:
  • tell us what package you are trying to build
  • post your debian/rules file
  • tell us if you have installed fakeroot, devsripts, etc.
Looking forward to working with you,
- Soul Singin'
.

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: HowTo Build a Package from Source the Smart Way

#64 Post by nadir »

found this link:
http://meetbot.debian.net/debian-women/ ... 5.log.html
For me it is interesting. If not for this thread, let me know ( it is rather an intro).

Edit:
Someone is so nice to rewrite the tutorials for the debian-wiki
(i don't know the name at the moment):
http://wiki.debian.org/IntroDebianPackaging
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

User avatar
csaba
Posts: 127
Joined: 2007-08-02 05:30

Re: HowTo Build a Package from Source the Smart Way

#65 Post by csaba »

I'm trying to make a deb out of apache thrift, so far with just a littlebit of success. I'm using the dh_make + dpkg-buildpackage approach. Also i'm running purely without X from the tty, on squeeze, under virtualbox, for full enjoyment purposes. although i'm not sure that this is relevant to the point but i'll mention it anyway.
I would like to give the configure script a few flags (mainly to switch off a few functionalities) and if my conclusions are correct this can be done by editing the file debian/rules. Probably yes, cause this howto also mentions this fact a few times.
You might then have to tweak the debian/rules file (e.g. to set configuration options) or set a shell variable.
Hopefully i'm not misunderstanding that this means that in this file i could pass to the configure script a few parameters, somehow. Probably the easiest solution would be to just set an env. variable and pass all the options i want to configure through it. Although i'm just thinking loudly, feel free to correct me anytime if i'm wrong.
At the moment my default rules file has only one line (i used dh_make --createorig for debianizing the upstream source), which is '<tab>dh $@', so i really dont comprehend where could i put my custom options and even how would those options be passed to configure. The next thing that i'll try to do will be to lok into a debian source package and it's rules file for some clues, but if there is a quick fix for this, feel free to enlighten me with the information.

thanx
Omnes homines natura scire desiderant.

Post Reply