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}/dists exists to avoid a special case later
47 if [ ! -d "${dest}/dists" ]; then
50 for olddir in dists.new dists.old; do
51 if [ -e "${dest}/${olddir}" ]; then
52 echo "Removing old ${olddir}..."
53 rm -r "${dest}/${olddir}"
57 # Make sure ${dest}/pool exists
58 if [ ! -e "${dest}/pool" ]; then
59 # Files are only removed from the build queues once they are no longer
60 # referenced. Having a symlink should thus not cause problems.
61 ln -s "${source}/pool" "${dest}/pool"
64 # Finally copy dists/ to dists.new/, rename it and remove old version
65 cp -a "${source}/dists" "${dest}/dists.new"
66 mv "${dest}/dists" "${dest}/dists.old"
67 mv "${dest}/dists.new" "${dest}/dists"
68 rm -r "${dest}/dists.old"