3 # Copyright 2012, Ansgar Burchardt <ansgar@debian.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 echo "usage: $0 <source> <target>"
25 echo "Update a minimalistic mirror for buildd archives."
36 if [ ! -d "${source}/dists" -o ! -d "${source}/pool" ]; then
37 echo "${source}: does not look like a Debian archive" >&2
41 if [ ! -d "${dest}" ]; then
42 echo "${dest}: destination does not exist or is not a directory" >&2
46 # Make sure ${dest}/pool exists
47 if [ ! -e "${dest}/pool" ]; then
48 # Files are only removed from the build queues once they are no longer
49 # referenced. Having a symlink should thus not cause problems.
50 ln -s "${source}/pool" "${dest}/pool"
53 for subdir in dists zzz-dists; do
54 if [ ! -d "${source}/${subdir}" ]; then
58 # Make sure ${dest}/${subdir} exists to avoid a special case later
59 if [ ! -d "${dest}/${subdir}" ]; then
60 mkdir "${dest}/${subdir}"
62 for olddir in ${subdir}.new ${subdir}.old; do
63 if [ -e "${dest}/${olddir}" ]; then
64 echo "Removing old ${olddir}..."
65 rm -r "${dest}/${olddir}"
69 # Finally copy ${subdir}/ to ${subdir}.new/, rename it and remove old version
70 cp -a "${source}/${subdir}" "${dest}/${subdir}.new"
71 mv "${dest}/${subdir}" "${dest}/${subdir}.old"
72 mv "${dest}/${subdir}.new" "${dest}/${subdir}"
73 rm -r "${dest}/${subdir}.old"