This question already has an answer here:

If I want to make minor changes to the source code of a Debian package, how do I go about downloading, incrementing the package version, building the (modified) source, and installing it on my computer?

marked as duplicate by chaos, user364819, A.B., David Foerster, Eric Carvalho May 19 '15 at 17:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @CiroSantilli六四事件法轮功 This question is not a duplicate of mine. It doesn't touch on modifying and rebuilding the deb package, incrementing the package version etc. It's just about downloading the source. – sashoalm May 17 '15 at 8:16
  • I think it does ask for how to build as well: "get the source code for these applications as well as update them?", "I would like to add features". This one is better phrased of course :-) – Ciro Santilli 新疆改造中心法轮功六四事件 May 17 '15 at 8:59
  • @sashoalm: Please read the top answer of that question: “To build a package from source, first […]. Then use dpkg-buildpackage to create a .deb file.” That sounds a lot like instructions to (re-)build Debian packages to me. – David Foerster May 19 '15 at 7:32

There's basically two ways to do it, the first one is the classic form, you'll get the source with:


 $ apt-get source package

Then you'll be able to modify it:

 $ cd package
 $ vim some_file

Rebuild it:

$ sudo apt-get build-dep package
$ dch -i (which will open your editor to edit the changefile, here's where you can increment the package version)

$ debuild -us -uc -b

And install it:

$ sudo dpkg -i ../package.deb

New Ubuntu Approach

The new way (the Ubuntu way) is by using bzr branches, you'll get the code by using:

$ bzr branch lp:ubuntu/package #which will download the latest ubuntu package (the precise one)

$ bzr branch lp:ubuntu/oneiric/package #to get the package in oneiric

You can also get the code using:

$ pull-lp-source package #lp-source is part of the ubuntu-dev-tools pkg

pull-lp-source used to be called just lp-source in older versions.

Then you'll be able to edit it:

$ cd package 
$ vim some_file

Rebuild it:

$ dch -i 
$ debcommit
$ bzr bd -- -b -us -uc

And install it:

$ sudo dpkg -i ../package.deb

I recommend that you check the Ubuntu packaging guide out to know the details.

Also you might enconter problems if the package depends of others

  • Using apt-get source openjdk-7 took around 2 minutes for me, while using bzr branch took over an hour and I decided to kill the process. I'm wondering what would be the usefulness of this "new approach". – Andrea Lazzarotto Oct 7 '14 at 10:19
  • many thanks I did it, just need to install before: apt-get install dpkg-dev apt-get install dchroot devscripts apt-get install fakeroot – Sérgio Jan 14 '15 at 18:28
  • 3
    You need sudo apt-get install devscripts to get the debuild command. – benjaoming Apr 8 '15 at 10:28
  • debuild doesn't create a delta source package while dpkg-buildpackage does... – Daniel Alder Dec 1 '15 at 11:30
  • bzr branch lp:ubuntu/xenial/lightdm bzr: ERROR: Not a branch: "bzr+ssh://bazaar.launchpad.net/+branch/ubuntu/xenial/lightdm/". bzr branch lp:ubuntu/lightdm bzr: ERROR: Not a branch: "bzr+ssh://bazaar.launchpad.net/+branch/ubuntu/lightdm/". Ubuntu packaging guide, specifically 4.2. Getting the source says: bzr branch ubuntu:lightdm lightdm.quickswitch bzr: ERROR: Not a branch: "bzr+ssh://bazaar.launchpad.net/+branch/ubuntu/lightdm/". What a mess. :-( – Stéphane Gourichon Aug 15 '16 at 16:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.