debian-useful-minimal: Depend on iproute.
[apt-repository.git] / rebuild
1 #!/bin/sh
2
3 # The location of the sources
4 SOURCES=sources/equivs
5 # The codename of the archive to import into
6 CODENAME=stderr
7
8 # Save the root of the repository
9 cd `dirname $0`
10 REPO_ROOT=`pwd`
11
12 # Create our output dir
13 OUT_DIR=`mktemp -d` || exit 1
14 cd $OUT_DIR
15
16 for i in $REPO_ROOT/$SOURCES/*; do 
17         BASE=`basename "$i"`
18         if [ -d "$i" ]; then
19                 echo "Skipping directory '$BASE'"
20                 continue;
21         fi
22         if [ ! -f "$i" ]; then
23                 echo "Skipping special file file '$BASE'"
24                 continue;
25         fi
26         if [ ! -r "$i" ]; then
27                 echo "Skipping non-readable file '$BASE'"
28                 continue;
29         fi
30
31         VERSION=`cat $i | grep "^Version:" | sed "s/^Version: //"`
32         PACKAGE=`cat $i | grep "^Package:" | sed "s/^Package: //"`
33
34         if [ -z "${PACKAGE}" -o -z "${VERSION}" ]; then
35                 echo "Skipping non-equivs file '$BASE'"
36                 continue;
37         fi
38
39         # Find out what the current repostory version is. We simply take the
40         # first of the architectures in the output, since these are
41         # architecture all packages and should have the same version on all
42         # archs.
43         REPO_VERSION=`$REPO_ROOT/reprepro list "${CODENAME}" "${PACKAGE}" | head -1 | cut -d' ' -f 3`
44         if dpkg --compare-versions "${REPO_VERSION}" ge "${VERSION}"; then
45                 echo "Not building version $VERSION of $PACKAGE, version $REPO_VERSION already in repository"
46                 continue
47         fi
48
49         echo "Building version $VERSION of $PACKAGE"
50         equivs-build $i || exit 1
51         
52         # Import the produced deb
53         $REPO_ROOT/reprepro includedeb "${CODENAME}" "${PACKAGE}_${VERSION}_all.deb" || exit 1
54 done
55
56 # Conservatively delete our temporary directory (To prevent issues when
57 # $OUT_DIR got set to / for some reason or something like that)
58 cd /
59 rm -f $OUT_DIR/*.deb
60 rmdir $OUT_DIR