how to rebuild a Debian / Ubuntu package

Q. I'd like to rebuild a Debian / Ubuntu package called foo with additional option. How do I recompile .deb packages?

A. To build a Debian package, you need the following packages / software installed on system
[a] fakeroot : fakeroot package - runs a command in an environment wherein it appears to have root privileges for file manipulation. This is useful for allowing users to create archives (tar, ar, .deb etc.) with files in them with root permissions/ownership.

[b] dpkg-dev : package building tools for Debian

[c] Development environment - You need gcc, make and all other compiler collection installed on system. Under Debian / Ubuntu package build-essential takes care of everything.
Step #1: Install required packages

Type the following command
$ sudo apt-get install build-essential fakeroot dpkg-dev
Step #2: Install source code package

First, create a directory to store source package, enter:
$ mkdir build
$ cd build
Use apt-get command to install source code for a package called foo
$ sudo apt-get source foo
Install all build-dependencies, enter:
$ sudo apt-get build-dep foo
Unpacks Debian / Ubuntu source archives with Debian source package (.dsc) manipulation tool, enter:
$ dpkg-source -x foo_version-revision.dsc
To just compile the package, you need cd into foo-version directory and issue the command
$ dpkg-buildpackage -rfakeroot -b
If you want to pass custom additonal options to configure, you can set up the DEB_BUILD_OPTIONS environment variable. For instance, if you want pass option called --enable-radio --enable-gui, enter:
$ DEB_BUILD_OPTIONS="--enable-gui --enable-radio" fakeroot debian/rules binary
You can also pass some variables to the Makefile. For example, if you want to compile with gcc v3.4, enter:
$ CC=gcc-3.4 DEB_BUILD_OPTIONS="--enable-gui --enable-radio" fakeroot debian/rules binary
A complete example - mplayer

Let us see how to rebuild mplayer media player package with --enable-radio --disable-ivt options:
# sudo apt-get source mplayer
# sudo apt-get build-dep mplayer
# dpkg-source -x mplayer_version-revision.dsc
# DEB_BUILD_OPTIONS="--enable-gui --enable-radio --disable-ivt" fakeroot debian/rules binary
Now wait for some time as compile procedure going to take its own time. To install the newly-built package, enter:
# dpkg -i ../mplayer_version-revision_arch.deb
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值