APT-build — optimize your Debian!

[ Friday, 23 November 2007, P2O2 ]


Certainly most of the Linux users would like to have their systems fully optimized for their rigs but do not have the stamina or enough knowledge to play with the Gentoo installation paradigm. But here comes the rescue — an apt-build goody available under every distro armed with the big gun – APT package manager.

Author: Gallus Annonimus

Time to make the beast work for us. First we have to install it. Issue the command:


apt-get install apt-build

Now it’s time to configure it. In doing so, we’ll be asked for an optimization level — whether we want to create an apt-build repo for APT, and a question about processor architecture. Of course all options can be reconfigured in this way:


dpkg-reconfigure apt-build

The above command offers two additional options for the gcc compiler and make builder. Their descriptions can be found in system manuals: man gcc and man make.

Optimizing system

Let’s go to the next step and start optimizing our system. Our program makes use of deb-src entries contained in the etc/apt/sources.list file. Thanks to the source addresses compilation and installation processes are fully automatic (similar to emerge found in Gentoo). Apt-build downloads sources of the main application and its dependencies, compiles them, creates a deb package, and finally installs the package.

We are offered a broad spectrum of options. I list only a few basic ones:

  • apt-build update — updates repo list,
  • apt-build upgrade — updates operating system,
  • apt-build install program — installs an application,
  • apt-build world — something for hard-core users, it recompiles whole system!

Other useful options:

  • --noupdate — useful for underpowered machines and when we do not want to update repos (apt-build refreshes repos with every invocation),
  • --yes — we do not have time to approve every stupid question during program installation,
  • --force-yes — we approve unauthorized packages (ATTENTION: apt-build does not install unauthorized packages — what’s worse is it won’t ask us for this; the option’s highly recommended),
  • --reinstall — reinstalls a package,
  • --rebuild — builds a package from the beginning.

Make your Debian anew!

Anyone ready to jump to the deep waters of system recompilation, after reading above remarks, has to acquaint himself with a few things without which the compilation process will not yield.

At first the apt-build command should spit out the message:

-----Rebuilding the world!-----

-----Building package list-----

Please read README.Debian first.

Of course, the system failed to rebuild due to the fact it didn’t have a full list of system packages. We’ll try to amend this omission with the following command (it can be issued in one row without the backslash too):


dpkg --get-selections | awk '{if ($2 == "install") print $1}'> \

 /etc/apt/apt-build.list

I suggest to add two options — --yes and --force-yes — to make the rebuilding process fully automatic. Recompilation should start without a problem now. But you will never achieve 100% certainty that the compilation will go smoothly, that it will not stop at some point even after you’ve made every theoretical precaution.

But what about USE flags?

A lot of you wonder whether we could have accessed USE flags, as we were able to recompile our system like Gentoo distros. For those uninitiated into compilation secrets: USE flags are special options for portage (Gentoo package control system). They free us from typing a lot of compilation options. For example, if we use GNOME and we do not need KDE parts we can preset the compiler to process applications for the first graphical environment only. Sorry, but apt-build cannot manage USE flags.

In spite of being at an early stage of development, the program is promising. In my opinion it will be able to compete with Gentoo’s portage in the future. But as for today, the apt-build system it too young and underdeveloped to compete with the stable, mature, and easy to use portage. Anyway, don’t worry. Debian wasn’t created to be compiled by users, contrary to Gentoo. Users should make use of Debian’s gigantic default repositories of ready-to-use binaries. But who from us, the users, never wanted to optimize his system in the past and wouldn’t like to optimize it in the future?

 

Translated by P2O2, Proof-read by Jake Conroy

Subscribe to RSS feed for this article!

12 Comments

fold this thread bob f  Saturday, 24 November 2007 o godz. 2:22 pm #  Add karma Subtract karma  +0

I have used apt-build in the past, and if I remember correctly only the explicity named application was built. The dependencies binaries where downloaded/installed and the named package only was built. IMHO, Gentoo’s USE flags are what makes building from source make sense and without these, I found apt-build to be more of a novelty.

(Comments wont nest below this level)
fold this thread vook  Wednesday, 2 April 2008 o godz. 2:40 am #  Add karma Subtract karma  +1

The term “Gentoo’s USE flags” implies that you believe that this is something that Gentoo has created and/or offers that other distributions and UNIX variants do not. Gentoo just tells you about them right away during the install. You can always completely customize the compilation process by creating a make.conf file in /etc – (linux didn’t invent this either btw – it’s been around a long time).

No, apt-build is not a novelty. It just doesn’t hold your hand the way Gentoo’s documentation does.

Nothing against Gentoo btw – it has gotten people excited about Linux in a way other distributions have not – and it has outstanding documentation. I just hope people realize that Gentoo doesn’t offer anything that wasn’t available before. If I really want the fastest and most optimized open OS around and I’m willing to tediously build it from scratch, I’ll pass on Gentoo and go straight for FreeBSD (or one of the others).

 
 
fold this thread Catnap  Sunday, 25 November 2007 o godz. 10:36 pm #  Add karma Subtract karma  --1

I tried apt-build a year or two ago. IIRC, “apt-build world” failed after a couple of hours of compiling. It might work better in the future because, AFAIK, Debian developers now do more automatic build testing than they used to in the past. (They don’t use apt-build to do this testing, though. ;-)

Nowadays I dual boot between the good old binary-Debian and a source-distro called Source Mage that is designed from the ground up to build all packages from source. The easy-to-use “sorcery” package manager in Source Mage is written in Bash and they try to avoid adding any patches or distro-specific configurations to packages, so Source Mage is refreshingly different from Debian. I love both of these distros.

(Comments wont nest below this level)
 
fold this thread Dann  Wednesday, 17 December 2008 o godz. 8:32 am #  Add karma Subtract karma  --1

I’ve had trouble with apt-build quitting on me before. This is only when it stumbles upon a package to install that does not exist in the repository (I’m at a loss as to why).
Just edit the apt-build.list file and erase everything up to and including the package that doesn’t work and continue on.

Cheers.

(Comments wont nest below this level)
 
fold this thread Laurent  Wednesday, 17 December 2008 o godz. 5:47 pm #  Add karma Subtract karma  --1

And?
Can you quantify the improvement in term of speed?

I highly doubt it changes anything if you already have a libc6-686

(Comments wont nest below this level)
 
fold this thread madman  Monday, 9 March 2009 o godz. 11:24 am #  Add karma Subtract karma  +0

It’s true; without “–force-yes”, you will just get a reinstall of the same old binary package! Furthermore, all your optimizations are ignored anyway! It seems that apt-build is an old, half-baked attempt, and really is just a “novelty” item – unless you use something like this:

apt-build install –rebuild –reinstall –yes –force-yes

…set your environment variables before you run it!:

export CFLAGS_APPEND=”-O3 -march=pentium3 -fomit-frame-pointer”

export CXXFLAGS_APPEND=$CFLAGS_APPEND

Otherwise your regular CFLAGS (and all of /etc/apt/apt-build.conf) will be ignored. See the manpage for dpkg-buildsource for more info. BTW, the command-line options for apt-build behave slightly different that the documentation claims; hence –reinstall AND –rebuild together. With a little cleaning up, apt-build could be a great utility. If you want USE flags – USE=”gentoo” =)

(Comments wont nest below this level)
fold this thread falk  Tuesday, 8 December 2009 o godz. 3:25 pm #  Add karma Subtract karma  +0

“…set your environment variables before you run it!:

[…]

Otherwise your regular CFLAGS (and all of /etc/apt/apt-build.conf) will be ignored.”

Nope, what you see are the commands called by make. Apt-build uses a wrapper (apt-build-wrapper; probably in /usr/lib/apt-build/) wich adds the options from apt-build.conf. Read README.Debian (propably in /usr/share/doc/apt-build/).

The real gcc calls you’ll see after typing ‘ps ax | grep gcc’.

 
 
fold this thread cww  Friday, 2 October 2009 o godz. 2:16 am #  Add karma Subtract karma  --1

I had to put the following in my APT preferences file in order to make apt-get choose a package from the local repository over a package from the remote repository. Note that priorities over 1000 have a special meaning; see the apt_preferences man page.

Package: *
Pin: release o=apt-build
Pin-Priority: 1001

Awesome work. Thanks!

(Comments wont nest below this level)
 
fold this thread Tom  Thursday, 25 March 2010 o godz. 10:48 am #  Add karma Subtract karma  --1

Hi@ALL

i run apt-get world –reinstall –force-yes -yes
and always apt-build stops cause it doesn’t diffrent find sources?
How can i run a broken step? What is the problem of missing
sources? sources.list is debian-lenny default

Thanks for Help..

(Comments wont nest below this level)
 
fold this thread quequotion  Tuesday, 19 October 2010 o godz. 5:52 pm #  Add karma Subtract karma  --1

Many of these issues in apt-build have been fixed. The documentation has not been updated unfortunately :( (neither has apt’s for that matter)

I have found that having multiple source lists (in /etc/apt/source.list.d/) prevents apt-build from getting a full list of sources.

It only reads ONE source file (default /etc/apt/sources.list), so I made a redundant file “/etc/apt/apt-build.sources” containing all my sources and use the parameter “–sources-list /etc/apt-build.sources” with every call to apt-build.

(Comments wont nest below this level)
fold this thread Maski  Sunday, 27 February 2011 o godz. 7:51 pm #  Add karma Subtract karma  --1

Could you explaine a litte more about the right sources to get apt-build to download all the sources.

fold this thread quequotion  Monday, 18 April 2011 o godz. 6:31 pm #  Add karma Subtract karma  --1

You’ll need to have deb-src lines for each source, and all sources listed in one file.

ie:

deb http://some.software.repo….
deb-src http://some.software.repo….

then you can use apt build like:

apt-build -sources-list /path/to/list install somepackage

Some repositories might not have a source repo (due to licensing or copyright problems or whatever) if this is the case, it’s ok to ignore apt-build complaining about it. Software distributed as binary-only cannot be optimised per architecture.

 
 
 
Name (required)
E-mail (required - never shown publicly)
URI

Adjust field size: shrink | enlarge)


You can use simple HTML in your comments. Some examples are as follows:
  • A hyperlink: <a href="polishlinux.org">GNU/Linux for everyone!</a>,
  • Strong text: <strong>Strong text</strong>,
  • Italic text: <em>italic text</em>,
  • Strike: <strike>strike</strike>,
  • Code: <code>printf("hello world");</code>,
  • Block quote: <blockquote>Block quote</blockquote>

About the Author

Przemysław Pawełczyk

New AdTaily ads!

Are you a film buff?

film buffs community, movie recommendations and reviews

RSS: Comments

You can follow the comments to this article through a special channel RSS 2.0 .

Related articles: Debian

 more »

Related articles: Software managers

 more »

PolishLinux Top Content


Become our fan on Facebook!

PolishLinux.org on Facebook

Follow PolishLinux on Twitter!

Follow polishlinux on Twitter

Google Ads