summaryrefslogtreecommitdiffstats
path: root/scripts/makeworld
blob: ce634071774bf17096e80f057a8c6e897aaf2df7 (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
102
103
104
105
106
#!/bin/bash

toplevel=`pwd`
version="2.4"

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
    --clean)     MAKEPKG_OPTS="$MAKEPKG_OPTS -c" ;;
    --install)   MAKEPKG_OPTS="$MAKEPKG_OPTS -i" ;;
    --syncdeps)  MAKEPKG_OPTS="$MAKEPKG_OPTS -s" ;;
    --builddeps) MAKEPKG_OPTS="$MAKEPKG_OPTS -b" ;;
    --nodeps)    MAKEPKG_OPTS="$MAKEPKG_OPTS -d" ;;
    --force)     MAKEPKG_OPTS="$MAKEPKG_OPTS -f" ;;
    --*)
      usage
      exit 1
      ;;
    -*)
      while getopts "cisbdf-" opt; do
        case $opt in
        c) MAKEPKGS_OPTS="$MAKEPKGS_OPTS -c" ;;
        i) MAKEPKGS_OPTS="$MAKEPKGS_OPTS -i" ;;
        s) MAKEPKGS_OPTS="$MAKEPKGS_OPTS -s" ;;
        b) MAKEPKGS_OPTS="$MAKEPKGS_OPTS -b" ;;
        d) MAKEPKGS_OPTS="$MAKEPKGS_OPTS -d" ;;
        f) MAKEPKGS_OPTS="$MAKEPKGS_OPTS -f" ;;
        -)
          OPTIND=0
          break
          ;;
        esac
      done
      ;;
    *)
      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 -w $dest 2>>$toplevel/makepkg.log
        if [ $? -gt 0 ]; then
          buildstatus=2
        else
          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