Debian旧版本源同步脚本

最近 `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` 源设置

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

同步脚本代码

#!/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

参考链接


Debian系统启动非常耗时,屏幕显示“A start job is running for /dev/disk/by-uuid/...a71b-4040-9b53-e92525f6803e”,错误“Timed out waiting for device /dev/disk/by-uuid/197c3d31-a71b-4040-9b53-e92525f6803e”

最近`Debian` 系统启动非常耗时,每次启动都要等待1分30秒的任务超时才能启动,屏幕显示“`A start job is running for /dev/disk/by-uuid/...a71b-4040-9b53-e92525f6803e`”,如下图:

继续阅读Debian系统启动非常耗时,屏幕显示“A start job is running for /dev/disk/by-uuid/...a71b-4040-9b53-e92525f6803e”,错误“Timed out waiting for device /dev/disk/by-uuid/197c3d31-a71b-4040-9b53-e92525f6803e”