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