#!/bin/sh
-# $Id: update-archive.sh,v 1.13 2008-10-20 10:24:15 adam Exp $
-if test ! -f apt-ftparchive.conf.in; then
- echo "$0: apt-ftparchive.conf.in must be located in current directory"
+D0=`dirname $0`
+confdir=`cd $D0; pwd`
+
+usage()
+{
+ cat <<EOF
+Usage: update-archive.sh [OPTIONS]
+Options:
+ [--debian=distros]
+ [--ubuntu=distros]
+ [--clear]
+EOF
+ exit $1
+}
+
+do_help=false
+clear=false
+while test $# -gt 0; do
+ case "$1" in
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+ case $1 in
+ --clear)
+ clear=true
+ ;;
+ --debian=*)
+ DEBIAN_DIST=$optarg
+ ;;
+ --ubuntu=*)
+ UBUNTU_DIST=$optarg
+ ;;
+ -*)
+ do_help=true
+ ;;
+ esac
+ shift
+done
+
+if $do_help; then
+ usage 1>&1
+fi
+
+if test ! -f ${confdir}/apt-ftparchive.conf.in; then
+ echo "$0: ${condir}/apt-ftparchive.conf.in not found"
+ exit 1
+fi
+if test ! -f ${confdir}/apt-release.conf.in; then
+ echo "$0: ${condir}/apt-release.conf.in not found"
exit 1
fi
fi
# gpg -a -d -o Release.gpg Release
+
+architectures="i386 amd64"
+
+if test "$DEBIAN_DIST"; then
+ for d in $DEBIAN_DIST; do
+ DISTRIBUTIONS="$DISTRIBUTIONS debian/$d"
+ done
+fi
+if test "$UBUNTU_DIST"; then
+ for d in $UBUNTU_DIST; do
+ DISTRIBUTIONS="$DISTRIBUTIONS ubuntu/$d"
+ done
+fi
-confdir=`pwd`
+# All distributions we know of
+ALLD="ubuntu/lucid ubuntu/natty ubuntu/oneiric ubuntu/precise ubuntu/quantal ubuntu/raring ubuntu/saucy debian/jessie debian/wheezy debian/squeeze debian/lenny"
-architectures="i386 amd64"
+if test -z "$DISTRIBUTIONS"; then
+ DISTRIBUTIONS=$ALLD
+else
+ for d in $DISTRIBUTIONS; do
+ bad=true
+ for y in $ALLD; do
+ if test "$d" = "$y"; then
+ bad=false
+ fi
+ done
+ if $bad; then
+ echo "No such distro $d"
+ exit 1
+ fi
+ done
+fi
-for vdist in ubuntu/gutsy ubuntu/hardy ubuntu/intrepid ubuntu/jaunty ubuntu/karmic debian/squeeze debian/lenny debian/etch; do
+echo "DISTRIBUTIONS=$DISTRIBUTIONS"
+for vdist in $DISTRIBUTIONS ; do
dist=`basename $vdist`
vendor=`dirname $vdist`
ftpdir=/home/ftp/pub/$vendor
cd $ftpdir
test -d tmp || mkdir tmp
# Uncomment to clean the .db (cache)
- # rm tmp/*
+ if $clear; then
+ rm tmp/*
+ fi
+ sections=""
for section in main restricted; do
# Prepare pool
d=pool/dists/$dist/$section
fi
done
# Make symlinks from the regular FTP archive
+ has_packages=false
for pdir in /home/ftp/pub/*; do
use=false
if test -f $pdir/.htaccess -a $section != "main"; then
if $use; then
distdir=$pdir/$vendor/$dist
if test -d $distdir; then
- ln -sf $distdir/*.dsc $d/source
- ln -sf $distdir/*.gz $d/source
+ for f in $distdir/*.dsc $distdir/*.gz; do
+ test -f $f && ln -sf $f $d/source
+ done
for arch in $architectures; do
mkdir -p $d/${arch}
for f in $pdir/.htaccess \
$distdir/*_all.*; do
if test -f $f; then
ln -sf $f $d/${arch}
+ has_packages=true
fi
done
done
fi
fi
done
- # ${confdir}/symclean.sh $d
-
for arch in $architectures; do
- d=dists/$dist/$section/binary-$arch
+ ${confdir}/symclean.sh $d/${arch}
+ done
+
+ rm -f $d/Release
+ if $has_packages; then
+ if test -z "$sections"; then
+ sections="$section"
+ else
+ sections="$sections $section"
+ fi
+ for arch in $architectures; do
+ d=dists/$dist/$section/binary-$arch
+ if test ! -d $d; then mkdir -p $d; fi
+ echo "Archive: $dist" >$d/Release
+ echo "Component: $section" >>$d/Release
+ echo 'Origin: Indexdata' >>$d/Release
+ echo "Architecture: $arch" >>$d/Release
+ done
+ d=dists/$dist/$section/source
if test ! -d $d; then mkdir -p $d; fi
echo "Archive: $dist" >$d/Release
echo "Component: $section" >>$d/Release
echo 'Origin: Indexdata' >>$d/Release
- echo "Architecture: $arch" >>$d/Release
- done
-
- d=dists/$dist/$section/source
- if test ! -d $d; then mkdir -p $d; fi
- echo "Archive: $dist" >$d/Release
- echo "Component: $section" >>$d/Release
- echo 'Origin: Indexdata' >>$d/Release
- echo 'Architecture: source' >>$d/Release
+ echo 'Architecture: source' >>$d/Release
+ fi
done
# generate
- echo "Begin Generate $dist"
+ echo "Begin Generate $dist: $sections"
F=apt-ftparchive.conf
- sed "s/@dist@/$dist/g" <${confdir}/${F}.in |sed "s/@architectures@/${architectures}/g" > $F
+ sed "s/@dist@/$dist/g" <${confdir}/${F}.in | \
+ sed "s/@architectures@/${architectures}/g" | \
+ sed "s/@sections@/${sections}/g" > $F
# Don't know if clean is needed!
# apt-ftparchive clean apt-ftparchive.conf
- apt-ftparchive generate apt-ftparchive.conf
- echo "Done generate $dist"
+ apt-ftparchive generate apt-ftparchive.conf 2>&1
+ echo "Done generate $dist: $sections"
# release
r=dists/$dist/Release
F=apt-release.conf
- sed "s/@dist@/$dist/g" <${confdir}/${F}.in | sed "s/@architectures@/${architectures}/g" >$F
+ sed "s/@dist@/$dist/g" <${confdir}/${F}.in | \
+ sed "s/@architectures@/${architectures}/g" | \
+ sed "s/@sections@/${sections}/g" > $F
# Move Release file away while calling using release
rm $r
apt-ftparchive -c $F release dists/$dist >tmp_Release