1,环境
build-essential(gcc, g++, libc6-dev,make, dpkg-dev), python, perl, gfortran
autoconf, automake, patch, xutils
dh-make,debhelper, devscripts, pbuilder
file, gnupg,fakeroot
2, 简单打包
mkdir pack
mv ./pack ./package.tar.gz
cd ./pack
tar zxvf ./package.tar.gz
cd ./package
dh_make -e account@domain.com -f ../package.tar.gz
... Answer prompts.
... Fix source tree
... If it is a script package, set debian/control to "Architecture: all"
... Do not erase ../package.orig.tar.gz
debuild or dpkg-buildpackage -rfakeroot -uc -b
... Make sure no warning happens.
注:我用这种办法成功把 pidgin_2.5.5 打成 deb 包。正如前篇文章说的,我已经成功在机器上将源码编译通过了,但是在 dpkg-buildpackage 时总出错,有如下提示:
*** Warning: Linking the shared library perl.la against the
*** static library /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a is not portable!
...
关键是先前编译的依赖我都解决了,怎么现在会不能通过呢,后来,小改了下 debian/rules 文件就可以正常通过了。原来是 dh_make 生成的 rules 文件还是有些小问题。先前让我不理解的 deb 包的依赖问题其实不是问题,build 过程会在 control 中自动添加依赖。
总结经验,打包前要对软件包进行编译试用,再将其打包,整个过程很简单。下面的方法太长,暂没有试。
3, 用dpatch和pbuilder打包
mkdir pack
mv ./pack ./package.tar.gz
cd ./pack
tar zxvf ./package.tar.gz
cp ./package ./package.org
cd ./package
dh_make -e account@domain.com -f ../package.tar.gz
... Answer prompts.
... Fix source tree by editor
... Try building packages with "dpkg-buildpackage -rfakeroot -us -uc"
... Edit source to make source buildable.
... Do not erase ../package.orig.tar.gz
cd ..
cp ./package ./package.bak
mv ./package/debian ./debian
diff -Nru package-orig package > patch-file
... You may overwrite package directory while doing this.
... Make sure to keep package.bak for your safety
mkdir -p debian/patches
dpatch patch-template patch-file \
-p "01_patchname" "patch-file description" \
< patch-file > debian/patches/01_patchname.dpatch
cd debian/patches
echo 01_patchname.dpatch >00list
cd ../..
rm -rf package
gvim debian/rules
现在文件debian/rules的内容是:
config.status: configure
./configure --prefix=/usr --mandir=/usr/share
build: config.status
${MAKE}
clean:
$(testdir)
$(testroot)
${MAKE} distclean
rm -rf debian/imaginary-package debian/files debian/substvars
可以用编辑器修改debian/rules文件为以下内容使其使用dpatch:
config.status: patch configure
./configure --prefix=/usr --mandir=/usr/share
build: config.status
${MAKE}
clean: clean-patched unpatch
clean-patched:
$(testdir)
$(testroot)
${MAKE} distclean
rm -rf debian/imaginary-package debian/files debian/substvars
patch: patch-stamp
patch-stamp:
dpatch apply-all
dpatch call-all -a=pkg-info >patch-stamp
unpatch:
dpatch deapply-all
rm -rf patch-stamp debian/patched
现在可以用dpatch系统重新打包了
tar zxvf package.orig.tar.gz
cp -a debian/ package/debian
cd package
sudo pbuilder update
pdebuild
主要参考:http://wiki.ubuntu.org.cn/Debian-maint-guide/A
没有评论:
发表评论