最近 Debian Wheezy/Jessie
源被官方归档了,使得许多来不及更新系统的服务器没源可用,http://archive.debian.org 访问速度太慢, 不得以自己写个脚本同步 Wheezy/Jessie
源。
Debian
官方推荐使用 debmirror
同步源,但是在群晖等设备上不方便使用,因此还是用 rsync
同步通用一些。
主要是自己的 WD MyCloud Gen1
在编译软件的时候,依赖 Wheezy
,Jessie
版本的软件包,又没办法升级系统,只能是自己建立软件源,保存一下,免得日后麻烦。
由于 Debian
源的结构,要单独分版本来同步很不方便,包都集中在 /pool
目录下,故此脚本主要根据索引文件来生成该版本的包列表ARCH_EXCLUDE
用来过滤不同架构的包的dists
用来过滤不同版本的同步完成后,整个 Wheezy/Jessie
源(i386, amd64, arm, source
) 共 96G
Wheezy Archive
源设置
1 2 |
deb http://mirrors.163.com/debian-archive/ wheezy main contrib non-free deb-src http://mirrors.163.com/debian-archive/ wheezy main contrib non-free |
同步脚本代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#!/bin/sh #author: igi #date: 2012-03-28 NAME="debian" SYNC_FILES="$NAME"_files #TO="/tmp/$NAME" TO="./$NAME" FROM="archive.debian.org::debian-archive/debian" #FROM="debian.ethz.ch::debian-archive/debian" #FROM="mirror.1und1.de::debian-archive/debian" #FROM="debian.koyanet.lv::debian-archive/debian" #RUNDIR="/tmp/" RUNDIR="./" ARCH_EXCLUDE="alpha hppa hurd-i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc ppc64el" for ARCH in $ARCH_EXCLUDE; do EXCLUDE=$EXCLUDE"\ --exclude binary-$ARCH/ \ --exclude *_$ARCH.deb \ --exclude *_$ARCH.udeb \ --exclude installer-$ARCH/ \ --exclude Contents-$ARCH* " done #dists='lenny etch' dists='wheezy jessie' for dist in $dists; do DIST_INCLUDE=${DIST_INCLUDE}"\ --include /dists/$dist/ \ --include /dists/$dist/contrib/ \ --include /dists/$dist/main/ \ --include /dists/$dist/non-free/ " DIST_EXCLUDE="${DIST_EXCLUDE}\ --exclude /dists/$dist/* " done #sync index files rsync --progress -av \ --include 'Packages.gz' \ --include 'Sources.gz' \ $DIST_INCLUDE \ --include '/dists/' \ --exclude '/*' \ --exclude '/dists/*' \ $DIST_EXCLUDE \ --exclude 'i18n' \ --exclude 'installer-amd64' \ --exclude 'installer-i386' \ --exclude 'installer-armel' \ --exclude 'installer-arm64' \ --exclude 'installer-armhf' \ --exclude 'installer-ppc64el' \ --exclude 'Release' \ --exclude '*.bz2' \ $EXCLUDE \ "$FROM/" "$TO/" rm -rf "$RUNDIR"/"$SYNC_FILES" find "$TO/dists/" -name 'Packages.gz' -exec zgrep 'Filename: ' {} + | awk '{print $2}' >"$RUNDIR"/"$SYNC_FILES" find "$TO/dists/" -name 'Sources.gz' -exec zcat {} + | awk '/Package:/{dir="";delete files;next};/Directory:/{dir=$2;next};/Files:/{pass=1;next}; pass && /^ / {files[NR]=$NF}; length(files) && dir && / /{for(i in files) print dir"/"files[i];delete files}; /^[^ ]/{pass=0;next};' >>"$RUNDIR"/"$SYNC_FILES" #first stage rsync --progress -v --recursive --times --links --hard-links \ --files-from="$RUNDIR"/"$SYNC_FILES" \ "$FROM/" "$TO/" #second stage rsync --progress -v --recursive --times --links --hard-links \ $DIST_INCLUDE \ --exclude '/dists/*' \ $EXCLUDE \ --exclude '/pool/' \ "$FROM/" "$TO/" |
更多 debian-archive
源,见: http://www.debian.org/distrib/archive