目錄
- apt-get source
- apt-src
- debuild
- dpkg-buildpackage
方法1: apt-get source
準備:
1. 設定檔要有 deb-src
/etc/apt/sources.list
deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu precise main restricted universe multiverse
2. 安裝:
# unpack, build and upload Debian source packages.
apt-get install dpkg-dev
# compile tools
apt-get install devscripts build-essential fakeroot
usage:
#獲得 *.orig.tar.gz *.dsc 及 *.diff.gz
apt-get source <packagename>
# satisfy the build dependencies for a source package.
apt-get build-dep packagename
建立 deb:
cd source-path
# binary-only build
dpkg-buildpackage -b
方法2: apt-src
安裝:
apt-get install apt-src
更新 apt-src 的 list:
apt-src update
- install - Install a source package into the current directory
- list - List installed source packages and their locations
- import - Tell apt-src about an existing source tree
- build - Build source package trees
# 這過程會下載其他 *-dev package
mkdir /usr/src/nginx
cd /usr/src/nginx
apt-src install nginx
Need to get 1353 kB of source archives. Get:1 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise/universe nginx 1.1.19-1 (dsc) [2041 B] Get:2 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise/universe nginx 1.1.19-1 (tar) [716 kB] Get:3 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise/universe nginx 1.1.19-1 (diff) [635 kB] Fetched 1353 kB in 2s (545 kB/s) gpgv: Signature made Fri Apr 13 12:34:20 2012 UTC using DSA key ID D1028C8D gpgv: Can't check signature: public key not found dpkg-source: warning: failed to verify signature on ./nginx_1.1.19-1.dsc dpkg-source: info: extracting nginx in nginx-1.1.19 dpkg-source: info: unpacking nginx_1.1.19.orig.tar.gz dpkg-source: info: unpacking nginx_1.1.19-1.debian.tar.gz dpkg-source: info: applying perl-use-dpkg-buildflags.patch
# 它會下載
nginx_1.1.19.orig.tar.gz, <-- source code
nginx_1.1.19-1.debian.tar.gz, <-- debian 目錄
nginx_1.1.19-1.dsc
並解開到 nginx-1.1.19
# import source
apt-src import nginx --version 1.1.19-1 --location /usr/src/nginx/nginx-1.1.19
apt-src list
i nginx 1.1.19-1 /etc/nginx/nginx-1.1.19
# 建立 deb:
# 之後會見到一大堆 package, 與 apt-cache search 見到的一棣
apt-src build nginx
nginx_1.1.19-1_all.deb
# 設定如何 compile
查看 opts:
./configure --help | less
設定檔在:
/usr/src/nginx/nginx-1.1.19/debian/rules
內容:
# 決定了 Build 什麼 ~~ #FLAVOURS:=full light extras naxsi # 我想 build full 而已 FLAVOURS:=full ................ config.status.full: config.env.full config.sub config.guess cd $(BUILDDIR_full) && CFLAGS="$(CFLAGS)" CORE_LINK="$(LDFLAGS)" ./configure \ --prefix=/etc/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-client-body-temp-path=/var/lib/nginx/body \ --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \ --http-log-path=/var/log/nginx/access.log \ --http-proxy-temp-path=/var/lib/nginx/proxy \ --http-scgi-temp-path=/var/lib/nginx/scgi \ --http-uwsgi-temp-path=/var/lib/nginx/uwsgi \ --lock-path=/var/lock/nginx.lock \ --pid-path=/var/run/nginx.pid \ --with-debug \ --with-http_addition_module \ --with-http_dav_module \ --with-http_geoip_module \ --with-http_gzip_static_module \ --with-http_image_filter_module \ --with-http_realip_module \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_sub_module \ --with-http_xslt_module \ --with-ipv6 \ --with-sha1=/usr/include/openssl \ --with-md5=/usr/include/openssl \ --with-mail \ --with-mail_ssl_module \ --add-module=$(MODULESDIR)/nginx-auth-pam \ --add-module=$(MODULESDIR)/nginx-echo \ --add-module=$(MODULESDIR)/nginx-upstream-fair \ --add-module=$(MODULESDIR)/nginx-dav-ext-module \ $(CONFIGURE_OPTS) >$@ touch $@ ................ # 雖然不會 build, 不過仍有把包 naxsi 的 !! # 刪除了就不打了. config.status.naxsi: config.env.naxsi config.sub config.guess cd $(BUILDDIR_naxsi) && CFLAGS="$(CFLAGS)" CORE_LINK="$(LDFLAGS)" ./configure \ --prefix=/etc/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-client-body-temp-path=/var/lib/nginx/body \ --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \ --http-log-path=/var/log/nginx/access.log \ --http-proxy-temp-path=/var/lib/nginx/proxy \ --http-scgi-temp-path=/var/lib/nginx/scgi \ --http-uwsgi-temp-path=/var/lib/nginx/uwsgi \ --lock-path=/var/lock/nginx.lock \ --pid-path=/var/run/nginx.pid \ --with-http_ssl_module \ --without-mail_pop3_module \ --without-mail_smtp_module \ --without-mail_imap_module \ --without-http_uwsgi_module \ --without-http_scgi_module \ --with-ipv6 \ --add-module=$(MODULESDIR)/nginx-upstream-fair \ --add-module=$(MODULESDIR)/nginx-cache-purge \ --add-module=$(MODULESDIR)/naxsi/naxsi_src \ $(CONFIGURE_OPTS) >$@ touch $@
最後把不用的清走
修改 control 檔
Source: nginx Section: httpd Priority: optional Maintainer: Kartik Mistry <[email protected]> Uploaders: Jose Parrella <[email protected]>, Fabio Tranchitella <[email protected]>, Michael Lustfield <[email protected]>, Dmitry E. Oboukhov <[email protected]>, Cyril Lavier <[email protected]> Build-Depends: autotools-dev, debhelper (>= 7), dpkg-dev (>= 1.15.7), libexpat-dev, libgd2-noxpm-dev, libgeoip-dev, liblua5.1-dev, libmhash-dev, libpam0g-dev, libpcre3-dev, libperl-dev, libssl-dev, libxslt1-dev, zlib1g-dev Standards-Version: 3.9.3 Homepage: http://nginx.net Vcs-Svn: svn://svn.debian.org/svn/collab-maint/deb-maint/nginx/trunk Vcs-Browser: http://svn.debian.org/wsvn/collab-maint/deb-maint/nginx/trunk Package: nginx Architecture: all Depends: nginx-full | nginx-light, ${misc:Depends} Description: small, but very powerful and efficient web server and mail proxy Nginx (engine x) is a web server created by Igor Sysoev and kindly provided to the open-source community. This server can be used as standalone HTTP server and as a reverse proxy server before some Apache or another big server to reduce load to backend servers by many concurrent HTTP-sessions. . This is a dummy package that selects nginx-full by default, but also can be installed with nginx-light for upgrading to nginx-light directly. Package: nginx-doc Architecture: all Section: doc Depends: lsb-base (>= 3.2-14), ${misc:Depends} Description: small, but very powerful and efficient web server (documentation) Nginx (engine x) is a web server created by Igor Sysoev and kindly provided to the open-source community. This server can be used as standalone HTTP server and as a reverse proxy server before some Apache or another big server to reduce load to backend servers by many concurrent HTTP-sessions. . This package provides extra documentation to help unleash the power of Nginx.
dpkg-buildpackage
$ dpkg-buildpackage
This will do everything to make full binary and source packages for you.
It will:
- clean the source tree (debian/rules clean)
- build the source package (dpkg-source -b)
- build the program (debian/rules build)
- build binary packages (fakeroot debian/rules binary)
- sign the source .dsc file, using gpg
- create and sign the upload .changes file, using dpkg-genchanges and gpg
# for your own local use
dpkg-buildpackage -us -uc
Quick rebuild:
# make a .deb file without rebuilding the upstream sources
fakeroot debian/rules binary
# simply do the following to see if it builds or not
fakeroot debian/rules build
debuild
debuild - build a Debian package
debuild creates all the files necessary for uploading a Debian package.
It first runs dpkg-buildpackage, then runs lintian on the .changes file created (assuming that lintian is installed)
/etc/devscripts.conf
DEBSIGN_KEYID=Your_GPG_keyID DEBUILD_LINTIAN_OPTS=-i -I --show-overrides
debuild clean
debuild
OR
debuild -us -uc
DOC:
http://www.debian.org/doc/manuals/maint-guide/build.en.html
File
.tar.gz
.dsc # description file(the name of the package, both, in its filename as well as content)
.deb
.changes