summaryrefslogtreecommitdiff
path: root/bin/apt-rep
blob: 9a5ce1d3a920fe1f2026a950f3ee527e5c13ee7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash

# update redhat/fedora apt repositories
# run this from the toplevel www directory that contains data/
# specify
# - nothing to rebuild all
# - a directory containing *RPMS.* dirs to rebuild for that dir
# the argument is treated as an argument to find, so all dirs in the tree
# below your argument will trigger a regeneration

TMPDIR=`mktemp -d`
BASEDIR=data/pkg

if test ! -d $BASEDIR;
then
  echo "Please run this script from the www directory, containing $BASEDIR"
  exit 1
fi

if test  ! -z $1; then BASEDIR=$1; fi
cd $BASEDIR
BASEDIR=`pwd`

DIRS=`find . -type d -name "*RPMS.*"`;

for dir in $DIRS;
do
  cd $BASEDIR
  #echo -n -e " 0000/0000 Generating repository for $dir\r"
  # if base does not exist one level deep, create it
  if test ! -d $dir/../base; then mkdir $dir/../base; fi
  DIR=`dirname $dir`
  ABSDIR=`cd $dir && pwd`
  EXT=`echo $dir | sed "s@^.*\.@@"`
  TYPE=`echo $dir | sed "s@^.*/@@" | sed "s@\..*@@"`

  if test "x$TYPE" == "xRPMS"; then
    cd $ABSDIR/..
    genbasedir --partial $ABSDIR/.. $EXT
  fi

  # thomas: disable the code here because we're using genbasedir now
  # RPMS
  if test "x$TYPE" == "noxRPMS"; then
    mkdir -p $TMPDIR/$DIR
    genpkglist --index $TMPDIR/$DIR/index --bloat --progress $DIR $EXT
    bzip2 -f $DIR/base/pkglist.$EXT
    echo
  fi
                                                                                
  # SRPMS
  # srclist.os gets dumped in the current dir for some reason
  if test "x$TYPE" == "noxSRPMS"; then
    gensrclist --flat --progress $DIR $EXT $TMPDIR/$DIR/index
    mv srclist.$EXT $DIR/base
    bzip2 -f $DIR/base/srclist.$EXT
    echo
  fi

done

rm -rf $TMPDIR