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