]> git.decadent.org.uk Git - dak.git/blobdiff - config/debian/cron.dinstall
make mkfilesindices a function
[dak.git] / config / debian / cron.dinstall
index 200c7a646986cbf7b189a1d28a7c2dee3be5773a..195b47fb153fbba856b01defe98ab8d91945788d 100755 (executable)
@@ -74,20 +74,6 @@ function onerror() {
 # the actual dinstall functions follow                                 #
 ########################################################################
 
-# Setup the notice file to tell bad mirrors they used the wrong time
-function notice() {
-    rm -f "$NOTICE"
-    cat > "$NOTICE" <<EOF
-Packages are currently being installed and indices rebuilt.
-Maintenance is automatic, starting at 01|07|13|19:52 UTC,
-and ending about an hour later.  This file is then removed.
-
-You should not mirror the archive during this period. If you find this
-file on a Debian mirror please have a nice talk with the admin. They
-are doing something wrong.
-EOF
-}
-
 # pushing merkels QA user, part one
 function merkel1() {
     log "Telling merkels QA user that we start dinstall"
@@ -285,20 +271,194 @@ function buildd_dir() {
     make_buildd_dir
 }
 
+function mklslar() {
+    cd $ftpdir
+
+    FILENAME=ls-lR
+
+    log "Removing any core files ..."
+    find -type f -name core -print0 | xargs -0r rm -v
+
+    log "Checking permissions on files in the FTP tree ..."
+    find -type f \( \! -perm -444 -o -perm +002 \) -ls
+    find -type d \( \! -perm -555 -o -perm +002 \) -ls
+
+    log "Checking symlinks ..."
+    symlinks -rd .
+
+    log "Creating recursive directory listing ... "
+    rm -f .${FILENAME}.new
+    TZ=UTC ls -lR > .${FILENAME}.new
+
+    if [ -r ${FILENAME}.gz ] ; then
+        mv -f ${FILENAME}.gz ${FILENAME}.old.gz
+        mv -f .${FILENAME}.new ${FILENAME}
+        rm -f ${FILENAME}.patch.gz
+        zcat ${FILENAME}.old.gz | diff -u - ${FILENAME} | gzip --rsyncable -9cfn - >${FILENAME}.patch.gz
+        rm -f ${FILENAME}.old.gz
+    else
+        mv -f .${FILENAME}.new ${FILENAME}
+    fi
+
+    gzip --rsyncable -9cfN ${FILENAME} >${FILENAME}.gz
+    rm -f ${FILENAME}
+}
+
+function mkmaintainers() {
+    log -n 'Creating Maintainers index ... '
+
+    cd $indices
+    dak make-maintainers ${scriptdir}/masterfiles/pseudo-packages.maintainers | \
+        sed -e "s/~[^  ]*\([   ]\)/\1/"  | awk '{printf "%-20s ", $1; for (i=2; i<=NF; i++) printf "%s ", $i; printf "\n";}' > .new-maintainers
+
+    set +e
+    cmp .new-maintainers Maintainers >/dev/null
+    rc=$?
+    set -e
+    if [ $rc = 1 ] || [ ! -f Maintainers ] ; then
+           log -n "installing Maintainers ... "
+           mv -f .new-maintainers Maintainers
+           gzip --rsyncable -9v <Maintainers >.new-maintainers.gz
+           mv -f .new-maintainers.gz Maintainers.gz
+    elif [ $rc = 0 ] ; then
+           log '(same as before)'
+           rm -f .new-maintainers
+    else
+           log cmp returned $rc
+           false
+    fi
+}
+
+function copyoverrides() {
+    log 'Copying override files into public view ...'
+
+    for f in $copyoverrides ; do
+           cd $overridedir
+           chmod g+w override.$f
+
+           cd $indices
+           rm -f .newover-$f.gz
+           pc="`gzip 2>&1 -9nv <$overridedir/override.$f >.newover-$f.gz`"
+           set +e
+           nf=override.$f.gz
+           cmp -s .newover-$f.gz $nf
+           rc=$?
+           set -e
+        if [ $rc = 0 ]; then
+                   rm -f .newover-$f.gz
+           elif [ $rc = 1 -o ! -f $nf ]; then
+                   echo "   installing new $nf $pc"
+                   mv -f .newover-$f.gz $nf
+                   chmod g+w $nf
+           else
+                   echo $? $pc
+                   exit 1
+           fi
+    done
+}
+
+function mkfilesindices() {
+    umask 002
+    cd $base/ftp/indices/files/components
+
+    ARCHLIST=$(tempfile)
+
+    echo "Querying projectb..."
+    echo 'SELECT l.path, f.filename, a.arch_string FROM location l JOIN files f ON (f.location = l.id) LEFT OUTER JOIN (binaries b JOIN architecture a ON (b.architecture = a.id)) ON (f.id = b.file)' | psql projectb -At | sed 's/|//;s,^/srv/ftp.debian.org/ftp,.,' | sort >$ARCHLIST
+
+    includedirs () {
+        perl -ne 'print; while (m,/[^/]+$,) { $_=$`; print $_ . "\n" unless $d{$_}++; }'
+    }
+    poolfirst () {
+        perl -e '@nonpool=(); while (<>) { if (m,^\./pool/,) { print; } else { push @nonpool, $_; } } print for (@nonpool);'
+    }
+
+    echo "Generating sources list..."
+    (
+        sed -n 's/|$//p' $ARCHLIST
+        cd $base/ftp
+        find ./dists -maxdepth 1 \! -type d
+        find ./dists \! -type d | grep "/source/"
+    ) | sort -u | gzip --rsyncable -9 > source.list.gz
+
+    echo "Generating arch lists..."
+
+    ARCHES=$( (<$ARCHLIST sed -n 's/^.*|//p'; echo amd64) | grep . | grep -v all | sort -u)
+    for a in $ARCHES; do
+        (sed -n "s/|$a$//p" $ARCHLIST
+            sed -n 's/|all$//p' $ARCHLIST
+
+            cd $base/ftp
+            find ./dists -maxdepth 1 \! -type d
+            find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)"
+        ) | sort -u | gzip --rsyncable -9 > arch-$a.list.gz
+    done
+
+    echo "Generating suite lists..."
+
+    suite_list () {
+        printf 'SELECT DISTINCT l.path, f.filename FROM (SELECT sa.source AS source FROM src_associations sa WHERE sa.suite = %d UNION SELECT b.source AS source FROM bin_associations ba JOIN binaries b ON (ba.bin = b.id) WHERE ba.suite = %d) s JOIN dsc_files df ON (s.source = df.source) JOIN files f ON (df.file = f.id) JOIN location l ON (f.location = l.id)\n' $1 $1 | psql -F' ' -A -t projectb
+
+        printf 'SELECT l.path, f.filename FROM bin_associations ba JOIN binaries b ON (ba.bin = b.id) JOIN files f ON (b.file = f.id) JOIN location l ON (f.location = l.id) WHERE ba.suite = %d\n' $1 | psql -F' ' -A -t projectb
+    }
+
+    printf 'SELECT id, suite_name FROM suite\n' | psql -F' ' -At projectb |
+    while read id suite; do
+        [ -e $base/ftp/dists/$suite ] || continue
+        (
+            (cd $base/ftp
+                distname=$(cd dists; readlink $suite || echo $suite)
+                find ./dists/$distname \! -type d
+                for distdir in ./dists/*; do
+                    [ "$(readlink $distdir)" != "$distname" ] || echo $distdir
+                done
+            )
+            suite_list $id | tr -d ' ' | sed 's,^/srv/ftp.debian.org/ftp,.,'
+        ) | sort -u | gzip --rsyncable -9 > suite-${suite}.list.gz
+    done
+
+    echo "Finding everything on the ftp site to generate sundries $(date +"%X")..."
+
+    (cd $base/ftp; find . \! -type d \! -name 'Archive_Maintenance_In_Progress' | sort) >$ARCHLIST
+
+    rm -f sundries.list
+    zcat *.list.gz | cat - *.list | sort -u |
+    diff - $ARCHLIST | sed -n 's/^> //p' > sundries.list
+
+    echo "Generating files list $(date +"%X")..."
+
+    for a in $ARCHES; do
+        (echo ./project/trace; zcat arch-$a.list.gz source.list.gz) |
+        cat - sundries.list dists.list project.list docs.list indices.list |
+        sort -u | poolfirst > ../arch-$a.files
+    done
+
+    (cd $base/ftp/
+           for dist in sid squeeze; do
+                   find ./dists/$dist/main/i18n/ \! -type d | sort -u | gzip --rsyncable -9 > $base/ftp/indices/files/components/translation-$dist.list.gz
+           done
+    )
+
+    (cat ../arch-i386.files ../arch-amd64.files; zcat suite-oldstable.list.gz suite-proposed-updates.list.gz ; zcat translation-sid.list.gz ; zcat translation-squeeze.list.gz) |
+    sort -u | poolfirst > ../typical.files
+
+    rm -f $ARCHLIST
+    echo "Done!"
+}
 function scripts() {
     log "Running various scripts from $scriptsdir"
     cd $scriptsdir
-    ./mkmaintainers
-    ./copyoverrides
-    ./mklslar
-    ./mkfilesindices
+    mkmaintainers
+    copyoverrides
+    mklslar
+    mkfilesindices
     ./mkchecksums
 }
 
 function mirror() {
     echo "Regenerating \"public\" mirror/ hardlink fun"
     cd ${mirrordir}
-    rsync -aH --link-dest ${ftpdir} --exclude Archive_Maintenance_In_Progress --delete --delete-after --ignore-errors ${ftpdir}/. .
+    rsync -aH --link-dest ${ftpdir} --delete --delete-after --ignore-errors ${ftpdir}/. .
 }
 
 function wb() {
@@ -521,6 +681,9 @@ function stage() {
     # Make sure we are always at the same place.
     cd ${configdir}
 
+    # We always use the same umask. If a function wants to do different, fine, but we reset.
+    umask 022
+
     touch "${STAGEFILE}"
 
     if [ -n "${TIME}" ]; then
@@ -563,6 +726,13 @@ else
     MAILTO=${MAILTO:-"ftpmaster@debian.org"}
 fi
 
+# Make sure we start out with a sane umask setting
+umask 022
+
+# And use one locale, no matter what the caller has set
+export LANG=C
+export LC_ALL=C
+
 # How many logfiles to keep
 LOGROTATE=${LOGROTATE:-400}
 
@@ -574,9 +744,6 @@ DINSTALLEND="${lockdir}/dinstallend"
 touch "${DINSTALLSTART}"
 ts "startup"
 
-# Tell everyone we are doing some work
-NOTICE="$ftpdir/Archive_Maintenance_In_Progress"
-
 # lock cron.unchecked (it immediately exits when this exists)
 LOCK_DAILY="$lockdir/daily.lock"
 
@@ -800,7 +967,6 @@ GO=(
 )
 stage $GO &
 
-rm -f "${NOTICE}"
 rm -f "${LOCK_DAILY}"
 
 ts "locked part finished"