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 | DEP_CHECK_ONLY=${DEP_CHECK_ONLY:-'0'}
|
---|
15 |
|
---|
16 | # Find listing of packages to build
|
---|
17 | PKG_TO_BUILD=${PKG_TO_BUILD:-${PACKAGE_LIST}}
|
---|
18 |
|
---|
19 | # make options, for package building
|
---|
20 | LOGDIR=`mktemp -d /tmp/$(basename $0 .sh)-$(date '+%Y%m%d-%H:%M:%S')X`
|
---|
21 |
|
---|
22 | p_info Log directory ${LOGDIR}
|
---|
23 | p_info Make arguments are:
|
---|
24 | p_info `p_list ${PKG_MAKE_ARGS}`
|
---|
25 | p_info Make configuration is:
|
---|
26 | echo "${PKG_MAKE_CONF}" | sed 's/^/## /'
|
---|
27 |
|
---|
28 | # HACK: install our own ports _inside_ the normal ports dir
|
---|
29 | cp -fR $WL_PORTSDIR/* $PORTSDIR || exit 1
|
---|
30 |
|
---|
31 | # Pre-req dependency fixing
|
---|
32 | p_info Checking whether there are currently unmet dependencies
|
---|
33 | RETVAL=0
|
---|
34 | PKGS=`pkg info | awk '{print $1}'`
|
---|
35 | for PKG in ${PKGS} ; do
|
---|
36 | PKG_DEP_FAIL=""
|
---|
37 | for PKGDEP in `pkg info -qr ${PKG} | awk '{print $2}'`; do
|
---|
38 | pkg info -e ${PKGDEP}
|
---|
39 | if [ $? -eq 1 ]; then
|
---|
40 | PKG_DEP_FAIL="${PKG_DEP_FAIL} ${PKGDEP}"
|
---|
41 | fi
|
---|
42 | done
|
---|
43 | if [ -n "${PKG_DEP_FAIL}" ]; then
|
---|
44 | p_err Unmet dependencies found at $PKG, please fix manually:
|
---|
45 | p_err `p_list ${PKG_DEP_FAIL}`
|
---|
46 | RETVAL=1
|
---|
47 | fi
|
---|
48 | done
|
---|
49 | if [ $RETVAL -eq 1 ]; then
|
---|
50 | exit 1
|
---|
51 | fi
|
---|
52 | p_info Dependecy check ok
|
---|
53 |
|
---|
54 | if [ ${DEP_CHECK_ONLY} -eq 1 ]; then
|
---|
55 | exit 0
|
---|
56 | fi
|
---|
57 | echo ""
|
---|
58 |
|
---|
59 |
|
---|
60 | # Cleanup of old packages
|
---|
61 | if [ -d "${NANO_PACKAGE_DIR}" ]; then
|
---|
62 | p_warn "Deleted all (old) packages at ${NANO_PACKAGE_DIR}"
|
---|
63 | rm -R ${NANO_PACKAGE_DIR}/*
|
---|
64 | fi
|
---|
65 | p_info Created target dir ${NANO_PACKAGE_DIR}
|
---|
66 | mkdir -p ${NANO_PACKAGE_DIR}
|
---|
67 |
|
---|
68 | # Build required packages
|
---|
69 | MAKE_CONF=`mktemp -t $(basename $0)`
|
---|
70 | echo "${PKG_MAKE_CONF}" > $MAKE_CONF
|
---|
71 | MAKE="make __MAKE_CONF=$MAKE_CONF ${PKG_MAKE_ARGS}"
|
---|
72 | BUILD_LIST=''
|
---|
73 | set `echo ${PKG_TO_BUILD} | xargs -n1 -I% echo $PORTSDIR/%`
|
---|
74 | while [ "$1" ]; do
|
---|
75 | PACKAGE=$1; shift
|
---|
76 | BUILD_LIST="${BUILD_LIST} ${PACKAGE}"
|
---|
77 |
|
---|
78 | # Build new one
|
---|
79 | LOGFILE="$LOGDIR/build_`echo $PACKAGE | tr '/' '_'`.log"
|
---|
80 | echo ""
|
---|
81 | p_info Packaging $PACKAGE
|
---|
82 | cd $PACKAGE || exit 1
|
---|
83 |
|
---|
84 | # Check for build dependencies
|
---|
85 | BUILDDEP_PKG=`${MAKE} build-depends-list | awk -F: '{print $2}'`
|
---|
86 | if [ -n "${BUILDDEP_PKG}" ]; then
|
---|
87 | p_info Build dependencies needed are:
|
---|
88 | p_info `p_list ${BUILDDEP_PKG}`
|
---|
89 | fi
|
---|
90 |
|
---|
91 | # Check for run dependencies
|
---|
92 | PKGDEP_PKGS=`${MAKE} package-depends-list | awk '{print $2}'`
|
---|
93 | if [ -n "${PKGDEP_PKGS}" ]; then
|
---|
94 | p_info Package dependencies also packaged are:
|
---|
95 | p_info `p_list ${PKGDEP_PKGS}`
|
---|
96 | fi
|
---|
97 |
|
---|
98 | PKGNAME=`${MAKE} extract-message | awk '{print $NF}'`
|
---|
99 | PKGBUILDLOG=/tmp/build.$$.`basename $PACKAGE`.log
|
---|
100 | p_info Packaging $PACKAGE ... details at $PKGBUILDLOG
|
---|
101 | ${MAKE} PACKAGES=/root/nanobsd/pkg package do-package 2>&1 >$PKGBUILDLOG
|
---|
102 | if [ $? -ne 0 ]; then
|
---|
103 | p_err "Failed to create $PKGNAME"
|
---|
104 | exit 1
|
---|
105 | fi
|
---|
106 |
|
---|
107 | p_info Checking dependencies
|
---|
108 | for PKG in $PKGDEP_PKGS; do
|
---|
109 | echo "${BUILD_LIST}" | grep -q "$PKG"
|
---|
110 | if [ $? -eq 0 ]; then
|
---|
111 | # Already packaged
|
---|
112 | p_info ${PKG} Already packaged
|
---|
113 | else
|
---|
114 | echo $@ | grep -q "${PKG}"
|
---|
115 | if [ $? -eq 0 ]; then
|
---|
116 | p_info ${PKG} Already planned
|
---|
117 | else
|
---|
118 | set $@ ${PKG}
|
---|
119 | fi
|
---|
120 | fi
|
---|
121 | done
|
---|
122 | p_info Packaging $PACKAGE succesfull
|
---|
123 | done
|
---|
124 |
|
---|
125 | p_info `echo ${BUILD_LIST} | wc -w` packages build succesfully
|
---|
126 |
|
---|
127 | if [ ${DEBUG} -eq 0 ]; then
|
---|
128 | rm -R ${LOGDIR}
|
---|
129 | else
|
---|
130 | p_info Debugging enabled ${LOGDIR} saved
|
---|
131 | fi
|
---|
132 |
|
---|
133 | # House keeping
|
---|
134 | rm $MAKE_CONF
|
---|
135 |
|
---|