archlinux强化篇之debian[转自SIR]

标题: archlinux强化篇之debian
http://www.linuxsir.org/bbs/thread328137.html

1、前言

之所以在archlinux上提及debian强化,主要在于debian充沛的镜像资源、庞大的软件库和大多数包的打包质量优良,在arch上装上 debian的包管理就可方便的从附近的debian镜像获取软件源码和非常有价值的patch及少量可以使用的二进制包,而且占地不多对系统本身没啥影 响,只要你只是apt-get update和apt-get source来用,除非你apt-get dist-upgrade,那样的话,arch就gone away了,只剩下纯粹的debian了

2、实干

aur上曾有过dpkg和apt的包,不过现在搜不找不到了,可能是上传的老兄亦或被别人删了,下面贴下对应的pkgbuild,具体的(email联系)我会放到附件里。
简单步骤:
代码:cd dpkg
makepkg
sudo pacman -U dpkg-1.14.18-2-i686.pkg.tar.gz
cd ../apt
makepkg
sudo pacman -U apt-0.7.12-2-i686.pkg.tar.gzdpkg
代码:pkgname=dpkg
pkgver=1.14.18
pkgrel=2
pkgdesc="Debian Package Manager"
arch=(i686 x86_64)
url="http://www.debian.org"
license="GPL"
depends=('bzip2' 'zlib')
source=(http://ftp.debian.org/debian/pool/main/d/dpkg/dpkg_${pkgver}.tar.gz)
#md5sums=('')

build() {
cd ${startdir}/src/${pkgname}-${pkgver}
./configure PERL_LIBDIR=/usr/lib/perl5/vendor_perl \
--prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib \
--with-zlib=static --with-bz2=static \
--without-dselect --without-start-stop-daemon

make DESTDIR=${startdir}/pkg install

mv ${startdir}/pkg/usr/share/perl5 ${startdir}/pkg/usr/lib

}apt
代码:pkgname=apt
pkgver=0.7.12
pkgrel=2
pkgdesc="Advanced front-end for dpkg"
arch=(i686 x86_64)
url="http://packages.debian.org/sid/apt"
license="GPL"
depends=('bzip2' 'zlib' 'dpkg')
source=(http://ftp.debian.org/debian/pool/main/a/apt/apt_${pkgver}.tar.gz)
#md5sums=('')

build() {
cd ${startdir}/src/${pkgname}-${pkgver}
cp ${startdir}/makefile-doc doc/makefile
install -d build/doc/doxygen
./configure --prefix=/usr --sysconfdir=/etc --localedir=/var

make || return 1

install -d ${startdir}/pkg/{etc/{apt/apt.conf.d,logrotate.d/apt},usr/{bin,lib/apt/methods,share/{apt,bug/apt/script,man/man{1,5,8}}}}
install -d ${startdir}/pkg/usr/lib/dpkg/methods/apt
install -d ${startdir}/pkg/var/{lib/apt/lists/partial,cache/apt/archives/partial}

cp bin/apt-* ${startdir}/pkg/usr/bin/

find bin/ -type f -name "libapt-pkg*.so.*" \
-exec cp -a "{}" ${startdir}/pkg/usr/lib/ \;
find bin/ -type l -name "libapt-pkg*.so.*" \
-exec cp -a "{}" ${startdir}/pkg/usr/lib/ \;

cp bin/methods/* ${startdir}/pkg/usr/lib/apt/methods/

cp scripts/dselect/* ${startdir}/pkg/usr/lib/dpkg/methods/apt/
cp -r locale ${startdir}/pkg/usr/share/

cp debian/bugscript ${startdir}/pkg/usr/share/bug/apt/script
cp debian/apt.logrotate ${startdir}/pkg/etc/logrotate.d/apt

cp share/debian-archive.gpg ${startdir}/pkg/usr/share/apt
cp debian/apt.conf.autoremove ${startdir}/pkg/etc/apt/apt.conf.d/01autoremove

cp doc/*.1 ${startdir}/pkg/usr/share/man/man1
cp doc/*.5 ${startdir}/pkg/usr/share/man/man5
cp doc/*.8 ${startdir}/pkg/usr/share/man/man8

}makefile-doc,放到apt目录下
代码:# -*- make -*-
BASE=..
SUBDIR=doc

# Bring in the default rules
include ../buildlib/defaults.mak

# Debian Doc SGML Documents
SOURCE = dpkg-tech.sgml design.sgml files.sgml guide.sgml guide.it.sgml \
cache.sgml method.sgml offline.sgml
include $(DEBIANDOC_H)

# XML man pages
SOURCE = apt-cache.8 apt-get.8 apt-cdrom.8 apt.conf.5 sources.list.5 \
apt-config.8 apt_preferences.5 \
apt-sortpkgs.1 apt-ftparchive.1 apt-extracttemplates.1 \
apt-key.8 apt-secure.8 apt-mark.8
INCLUDES = apt.ent
include $(XML_MANPAGE_H)

# Examples
SOURCE = examples/apt.conf examples/sources.list examples/configure-index
TO = $(DOC)
TARGET = binary
include $(COPY_H)

#.PHONY: headers library clean veryclean all binary program doc
doc:

ifdef DOXYGEN
DOXYGEN_SOURCES = $(shell find $(BASE)/apt-pkg -not -name .\\\#* -and \( -name \*.cc -or -name \*.h \) )

clean: doxygen-clean

doxygen-clean:
rm -fr $(BUILD)/doc/doxygen
rm -f $(BUILD)/doc/doxygen-stamp

$(BUILD)/doc/Doxyfile: Doxyfile.in
(cd $(BUILD) && ./config.status doc/Doxyfile)

$(BUILD)/doc/doxygen-stamp: $(DOXYGEN_SOURCES) $(BUILD)/doc/Doxyfile
rm -fr $(BUILD)/doc/doxygen
$(DOXYGEN) $(BUILD)/doc/Doxyfile
touch $(BUILD)/doc/doxygen-stamp

doc: $(BUILD)/doc/doxygen-stamp

endif3、扫尾

安装完dpkg、apt后,基本工作就做完了,下面来解决apt的gpg验证等
首先编辑一个附近debian镜像用的sources.list
sudo vi /etc/apt/sources.list
PHP 代码: deb http://ftp.sjtu.edu.cn/debian sid main non-free contrib
deb-src http://ftp.sjtu.edu.cn/debian sid main non-free contrib
其次,touch下apt要用的lock文件
PHP 代码: sudo touch /var/lib/apt/lists/lock /var/cache/apt/archives/lock
最后来解决下gpg验证,为了保险起见,下载debian-archive-keyring中的gpg文件到/usr/share/keyrings下面:
PHP 代码: wget -c http://ftp.de.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2008.04.16+nmu1.tar.gz
tar xvf debian-archive-keyring_2008.04.16+nmu1.tar.gz
su
mkdir -p /usr/share/keyrings
mv debian-archive-keyring-2008.04.16+nmu1/keyrings/*.gpg /usr/share/keyrings/
导入gpg,附带导入你选择镜像站点的gpg,apt-get update时会提示的,我选的这个是A70DAF536070D3A1
PHP 代码: su
gpg --import /usr/share/keyrings/debian-keyring.gpg
gpg --import /usr/share/apt/debian-archive.gpg
gpg --armor --export A70DAF536070D3A1 |apt-key add -
如此,所需工作都已完成,可以利用apt-get来更新及下载源代码了,比如
PHP 代码: apt-get update
apt-get source nano
PHP 代码: $ sudo apt-get update
密码:
命中 http://ftp.sjtu.edu.cn sid Release.gpg      
忽略 http://ftp.sjtu.edu.cn sid/main Translation-zh_CN
忽略 http://ftp.sjtu.edu.cn sid/non-free Translation-zh_CN
忽略 http://ftp.sjtu.edu.cn sid/contrib Translation-zh_CN
命中 http://ftp.sjtu.edu.cn sid Release
命中 http://ftp.sjtu.edu.cn sid/main Packages/DiffIndex
命中 http://ftp.sjtu.edu.cn sid/non-free Packages/DiffIndex
命中 http://ftp.sjtu.edu.cn sid/contrib Packages/DiffIndex
命中 http://ftp.sjtu.edu.cn sid/main Sources/DiffIndex
命中 http://ftp.sjtu.edu.cn sid/non-free Sources/DiffIndex
命中 http://ftp.sjtu.edu.cn sid/contrib Sources/DiffIndex
正在读取软件包列表... 完成

$ apt-get source nano
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
需要下载 1389kB 的源代码包。
获取:1 http://ftp.sjtu.edu.cn sid/main nano 2.0.7-1 (dsc) [731B]
获取:2 http://ftp.sjtu.edu.cn sid/main nano 2.0.7-1 (tar) [1364kB]
获取:3 http://ftp.sjtu.edu.cn sid/main nano 2.0.7-1 (diff) [24.7kB]                
下载 1389kB,耗时 56s (24.5kB/s)                                                    
gpg: 于 2007年12月24日 星期一 22时45分15秒 CST 创建的签名,使用 DSA,钥匙号 917A225E
gpg: 无法检查签名:找不到公钥
dpkg-source: extracting nano in nano-2.0.7
dpkg-source: info: unpacking nano_2.0.7.orig.tar.gz
dpkg-source: info: applying nano_2.0.7-1.diff.gz

apt-get install foo 会附带把相关依赖搭上,多数情况下加--ignore-missing并不能使其只下载想要的二进制包,这时直接获取包的位置使用wget等来下载就行了,前面加上镜像的地址加上apt获取的即可

PHP 代码: $wget -c http://ftp.sjtu.edu.cn/debian/`apt-cache show nano | grep pool | awk '{print $2}'`
--2008-05-11 20:24:07--  http://ftp.sjtu.edu.cn/debian/pool/main/n/nano/nano_2.0.7-1_i386.deb
正在解析主机 ftp.sjtu.edu.cn... 202.38.97.230
Connecting to ftp.sjtu.edu.cn|202.38.97.230|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:584268 (571K) [application/x-debian-package]
Saving to: `nano_2.0.7-1_i386.deb'
...

常见的小的二进制东东使用是将其下下来,然后dpkg解开来,放到搜索路径下来用,部分so的版本不符时还要做下软连接,所以多数情况最好还是下源码,打包来用
使用二进制的一个例子:
PHP 代码: $wget -c http://debian.cn99.com/debian/`apt-cache show nano | grep pool | awk '{print $2}'`
$ dpkg -x nano_2.0.7-1_i386.deb nano
$ dpkg -e nano_2.0.7-1_i386.deb nano/DEBIAN
$ ./nano/bin/nano
其中,nano/DEBIAN下面是信息、更新与删除的安装脚本和md5等,可以看看

将deb转成pkg.tar.gz也是很容易的事,只是考虑到底层库的问题,还是从源码打包更好,deb包里的信息可以直接转贴到pkgbuild里

你可能感兴趣的:(#archlinux)