1 | #!/bin/sh
|
---|
2 | # Install all required packages
|
---|
3 | #
|
---|
4 | # XXX: Welcome to port hell, if /usr/ports has been updated, you actually want
|
---|
5 | # to delete all installed packages and start over again, hence why people used
|
---|
6 | # to run this stuff in jails, etc.
|
---|
7 | #
|
---|
8 | # Rick van der Zwet <rick@wirelessleiden.nl>
|
---|
9 | #
|
---|
10 |
|
---|
11 | . `dirname $0`/package-build.inc.sh
|
---|
12 |
|
---|
13 | DEBUG=${DEBUG:-'0'}
|
---|
14 |
|
---|
15 | # Find listing of packages to build
|
---|
16 | PKG_TO_BUILD=${PKG_TO_BUILD:-${PACKAGE_LIST}}
|
---|
17 |
|
---|
18 | # make options, for package building
|
---|
19 | LOGDIR=`mktemp -d /tmp/$(basename $0 .sh)-$(date '+%Y%m%d-%H:%M:%S')X`
|
---|
20 |
|
---|
21 | p_info Log directory ${LOGDIR}
|
---|
22 | p_info Make arguments are:
|
---|
23 | p_info `p_list ${PKG_MAKE_ARGS}`
|
---|
24 | p_info Make configuration is:
|
---|
25 | echo "${PKG_MAKE_CONF}" | sed 's/^/## /'
|
---|
26 |
|
---|
27 | # HACK: install our own ports _inside_ the normal ports dir
|
---|
28 | cp -fR $WL_PORTSDIR/* $PORTSDIR || exit 1
|
---|
29 |
|
---|
30 | # Cleanup of old packages
|
---|
31 | if [ -d "${NANO_PACKAGE_DIR}" ]; then
|
---|
32 | p_warn "Deleted all (old) packages at ${NANO_PACKAGE_DIR}"
|
---|
33 | rm -R ${NANO_PACKAGE_DIR}/*
|
---|
34 | fi
|
---|
35 | p_info Created target dir ${NANO_PACKAGE_DIR}
|
---|
36 | mkdir -p ${NANO_PACKAGE_DIR}
|
---|
37 |
|
---|
38 | # Build required packages
|
---|
39 | MAKE_CONF=`mktemp -t $(basename $0)`
|
---|
40 | echo "${PKG_MAKE_CONF}" > $MAKE_CONF
|
---|
41 | MAKE="make __MAKE_CONF=$MAKE_CONF ${PKG_MAKE_ARGS}"
|
---|
42 | BUILD_LIST=''
|
---|
43 | set `echo ${PKG_TO_BUILD} | xargs -n1 -I% echo $PORTSDIR/%`
|
---|
44 | while [ "$1" ]; do
|
---|
45 | PACKAGE=$1; shift
|
---|
46 | BUILD_LIST="${BUILD_LIST} ${PACKAGE}"
|
---|
47 |
|
---|
48 | # Build new one
|
---|
49 | LOGFILE="$LOGDIR/build_`echo $PACKAGE | tr '/' '_'`.log"
|
---|
50 | echo ""
|
---|
51 | p_info Packaging $PACKAGE
|
---|
52 | cd $PACKAGE || exit 1
|
---|
53 |
|
---|
54 | # Check for build dependencies
|
---|
55 | BUILDDEP_PKG=`${MAKE} build-depends-list | awk -F: '{print $2}'`
|
---|
56 | if [ -n "${BUILDDEP_PKG}" ]; then
|
---|
57 | p_info Build dependencies needed are:
|
---|
58 | p_info `p_list ${BUILDDEP_PKG}`
|
---|
59 | fi
|
---|
60 |
|
---|
61 | # Check for run dependencies
|
---|
62 | PKGDEP_PKGS=`${MAKE} package-depends-list | awk '{print $2}'`
|
---|
63 | if [ -n "${PKGDEP_PKGS}" ]; then
|
---|
64 | p_info Package dependencies also packaged are:
|
---|
65 | p_info `p_list ${PKGDEP_PKGS}`
|
---|
66 | fi
|
---|
67 |
|
---|
68 | PKGNAME=`${MAKE} extract-message | awk '{print $NF}'`
|
---|
69 | PKGBUILDLOG=/tmp/build.$$.`basename $PACKAGE`.log
|
---|
70 | p_info Packaging $PACKAGE ... details at $PKGBUILDLOG
|
---|
71 | ${MAKE} PACKAGES=/root/nanobsd/pkg package do-package 2>&1 >$PKGBUILDLOG
|
---|
72 | if [ $? -ne 0 ]; then
|
---|
73 | p_err "Failed to create $PKGNAME"
|
---|
74 | exit 1
|
---|
75 | fi
|
---|
76 |
|
---|
77 | p_info Checking dependencies
|
---|
78 | for PKG in $PKGDEP_PKGS; do
|
---|
79 | echo "${BUILD_LIST}" | grep -q "$PKG"
|
---|
80 | if [ $? -eq 0 ]; then
|
---|
81 | # Already packaged
|
---|
82 | p_info ${PKG} Already packaged
|
---|
83 | else
|
---|
84 | echo $@ | grep -q "${PKG}"
|
---|
85 | if [ $? -eq 0 ]; then
|
---|
86 | p_info ${PKG} Already planned
|
---|
87 | else
|
---|
88 | set $@ ${PKG}
|
---|
89 | fi
|
---|
90 | fi
|
---|
91 | done
|
---|
92 | p_info Packaging $PACKAGE succesfull
|
---|
93 | done
|
---|
94 |
|
---|
95 | p_info `echo ${BUILD_LIST} | wc -w` packages build succesfully
|
---|
96 |
|
---|
97 | if [ ${DEBUG} -eq 0 ]; then
|
---|
98 | rm -R ${LOGDIR}
|
---|
99 | else
|
---|
100 | p_info Debugging enabled ${LOGDIR} saved
|
---|
101 | fi
|
---|
102 |
|
---|
103 | # House keeping
|
---|
104 | rm $MAKE_CONF
|
---|
105 |
|
---|