summaryrefslogtreecommitdiffstats
path: root/scripts/makeworld
blob: 9b5e46cd0812c76730d63516642934f3467f94ec (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash

toplevel=`pwd`
version="2.3.2"

usage() {
  echo "makeworld version $version"
  echo "usage: $0 [options] <destdir> <category> [category] ..."
  echo "options:"
  echo "  -c, --clean      Clean up work files after build"
  echo "  -s, --syncdeps   Install missing dependencies with pacman"
  echo "  -b, --builddeps  Build missing dependencies from source"
  echo "  -d, --nodeps     Skip all dependency checks"
  echo "  -i, --install    Install package after successful build"
  echo "  -f, --force      Overwrite existing packages"
  echo "  -h, --help       This help"
  echo
  echo "  where <category> is one or more directory names under the ABS root"
  echo "  eg: makeworld -c /packages base lib editors"
  echo
  echo "  this should be run from the toplevel directory of ABS (usually /usr/abs)"
}

if [ $# -lt 2 -o "$1" = "--help" -o "$1" = "-h" ]; then
  usage
  exit 1
fi

MAKEPKG_OPTS=
for arg in $*; do
  case $arg in
    -c|--clean)
      MAKEPKG_OPTS="$MAKEPKG_OPTS -c"
      ;;
    -i|--install)
      MAKEPKG_OPTS="$MAKEPKG_OPTS -i"
      ;;
    -s|--syncdeps)
		  MAKEPKG_OPTS="$MAKEPKG_OPTS -d"
      ;;
    -b|--builddeps)
      MAKEPKG_OPTS="$MAKEPKG_OPTS -b"
      ;;
    -d|--nodeps)
      MAKEPKG_OPTS="$MAKEPKG_OPTS -n"
      ;;
    -f|--force)
      MAKEPKG_OPTS="$MAKEPKG_OPTS -f"
      ;;
    *)
      dest=$arg
      shift
      break
      ;;
  esac
  shift
  if [ "$dest" != "" ]; then
    break;
  fi
done

if [ "$dest" = "" ]; then
  usage
  exit 1
fi

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