summaryrefslogtreecommitdiffstats
path: root/scripts/makeworld
blob: 8b3ec17720cd0f5b528cfbedc91d2bc34ef2984f (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
63
64
65
66
67
68
#!/bin/bash

toplevel=`pwd`
version="2.0"

if [ $# -lt 2 -o "$1" = "--help" -o "$1" = "-h" ]; then
	echo "makeworld version $version"
  echo "usage: $0 [options] <destdir> <category> [category] ..."
	echo "options:"
	echo "  -c, --clean   Clean up work files after build"
	echo "  -i, --install Install package after successful build"
	echo "  -h, --help    This help"
	echo
  echo "  where <category> is one or more of base, opt, contrib"
  echo "  eg: makeworld /packages base opt"
  echo
  echo "  this should be run from the toplevel directory of ABS (usually /usr/abs)"
  exit 1
fi

MAKEPKG_OPTS=
if [ "$1" = "-c" -o "$1" = "--clean" ]; then
	shift
	MAKEPKG_OPTS="$MAKEPKG_OPTS -c"
fi
if [ "$1" = "-i" -o "$1" = "--install" ]; then
	shift
	MAKEPKG_OPTS="$MAKEPKG_OPTS -i"
fi

dest=$1
shift

sd=`date +"[%b %d %H:%M]"`

for category in $*; do
  for port in `find $toplevel/$category -type d -maxdepth 1 -mindepth 1 | sort`; do
    cd $port
    if [ -f PKGBUILD ]; then
      . PKGBUILD
      buildstatus=0
      if [ ! -f $dest/$pkgname-$pkgver-$pkgrel.pkg.tar.gz ]; then
        makepkg $MAKEPKG_OPTS 2>>$toplevel/makepkg.log
        if [ $? -gt 0 ]; then
          buildstatus=2
        else
          rm -rf pkg src
          # some packages (mozilla) have been split into multiple packages
          mv -v $pkgname-*.pkg.tar.gz $dest/
          buildstatus=1
        fi
      fi
      d=`date +"[%b %d %H:%M]"`
      echo -n "$d  " >>$toplevel/build.log
      case $buildstatus in
        0) echo "$pkgname already built -- skipping" >>$toplevel/build.log ;;
        1) echo "$pkgname was built successfully" >>$toplevel/build.log ;;
        2) echo "$pkgname build failed" >>$toplevel/build.log ;;
      esac
    fi
  done
done
ed=`date +"[%b %d %H:%M]"`

echo "makeworld complete." >>$toplevel/build.log
echo "  started:  $sd" >>$toplevel/build.log
echo "  finished: $ed" >>$toplevel/build.log