source: hybrid/branches/releng-9.0/nanobsd/tools/package-build.sh@ 10181

Last change on this file since 10181 was 10181, checked in by richardvm, 13 years ago

begone

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 4.7 KB
Line 
1#!/bin/sh
2# Install all required packages
3# XXX: Welcome to port hell, if /usr/ports has been updated, you actually want
4# to delete all installed packages and start over again, hence why people used
5# to run this stuff in jails, etc.
6
7. $(dirname $0)/package-build.inc.sh
8
9DEBUG=${DEBUG:-0}
10DEP_CHECK_ONLY=${DEP_CHECK_ONLY:-0}
11
12# make options, for package building
13LOGDIR=`mktemp -d "/tmp/$(basename $0 .sh)-$(date +%Y%m%d-%H:%M:%S).X"`
14TARGET="`cd $(dirname $0);pwd -P`/../pkg/"
15
16# Package target
17MAKE_ARGS="$MAKE_ARGS PACKAGES=$TARGET"
18MAKE_ARGS="$MAKE_ARGS BATCH=yes PACKAGE_BUILDING=yes"
19
20# www/py-cherrypy
21MAKE_ARGS="${MAKE_ARGS} WITH_APACHE=yes"
22# net-mgmt/net-snmp
23MAKE_ARGS="${MAKE_ARGS} WITHOUT_PERL=yes"
24# net-mgmt/nagios-plugins
25MAKE_ARGS="${MAKE_ARGS} WITH_FPING=yes"
26# threads is broken in the version (atleast up to 9.0 - 20120213)
27# Should be fix in current version in linux, but for some reason
28# Not yet in BSD. We don't need threads
29MAKE_ARGS="${MAKE_ARGS} WITHOUT_THREADS=yes"
30
31p_info Log directory ${LOGDIR}
32p_info Make options are:
33p_info $(p_list ${MAKE_ARGS})
34
35p_info Checking whether there are currently unmet dependencies
36RETVAL=0
37PKGS=`pkg_info | awk '{print $1}'`
38for PKG in ${PKGS} ; do
39 PKG_DEP_FAIL=""
40 for PKGDEP in `pkg_info -qr ${PKG} | awk '{print $2}'`; do
41 pkg_info -e ${PKGDEP}
42 if [ $? -eq 1 ]; then
43 PKG_DEP_FAIL="${PKG_DEP_FAIL} ${PKGDEP}"
44 fi
45 done
46 if [ -n "${PKG_DEP_FAIL}" ]; then
47 p_err Unmet dependencies found at $PKG, please fix manually:
48 p_err $(p_list ${PKG_DEP_FAIL})
49 RETVAL=1
50 fi
51done
52if [ $RETVAL -eq 1 ]; then
53 exit 1
54fi
55p_info Dependecy check ok
56
57if [ ${DEP_CHECK_ONLY} -eq 1 ]; then
58 exit 0
59fi
60echo ""
61
62
63if [ -d "${TARGET}/All" ]; then
64 p_warn "Deleted all (old) packages at ${TARGET}"
65 rm -R $TARGET/*
66fi
67p_info Created target dir ${TARGET}/All
68mkdir -p ${TARGET}/All
69
70PORTSDIR='/usr/ports'
71WL_PORTSDIR="`cd $(dirname $0);pwd -P`/../ports/"
72
73PACKAGE_LIST=`cat <<EOF | sed 's/#.*$//g'
74$PORTSDIR/dns/dnsmasq
75$PORTSDIR/www/thttpd
76$PORTSDIR/editors/vim-lite
77$PORTSDIR/lang/python
78$PORTSDIR/net-mgmt/net-snmp
79$PORTSDIR/benchmarks/iperf
80$PORTSDIR/net/pen
81$PORTSDIR/devel/py-yaml
82$PORTSDIR/sysutils/ucspi-tcp
83$PORTSDIR/www/tinyproxy
84$PORTSDIR/editors/vim-lite
85$PORTSDIR/security/nmap
86$PORTSDIR/ftp/curl
87$PORTSDIR/security/openvpn
88$PORTSDIR/net/sixxs-aiccu
89$WL_PORTSDIR/net/lvrouted
90
91`
92
93MAKE="make ${MAKE_ARGS}"
94
95BUILD_LIST=''
96# Build required packages
97set ${PACKAGE_LIST}
98while [ "$1" ]; do
99 PACKAGE=$1; shift
100 BUILD_LIST="${BUILD_LIST} ${PACKAGE}"
101
102 # Build new one
103 LOGFILE="$LOGDIR/build$(echo $PACKAGE | tr '/' '_').log"
104 echo ""
105 p_info Packaging $PACKAGE
106 cd ${PACKAGE}
107
108
109 # Check for build dependencies
110 BUILDDEP_PKG=`${MAKE} build-depends-list | awk -F: '{print $2}'`
111 if [ -n "${BUILDDEP_PKG}" ]; then
112 p_info Build dependencies needed are:
113 p_info $(p_list ${BUILDDEP_PKG})
114 fi
115
116 # Check for run dependencies
117 PKGDEP_PKGS=`${MAKE} package-depends-list | awk '{print $2}'`
118 if [ -n "${PKGDEP_PKGS}" ]; then
119 p_info Package dependencies also packaged are:
120 p_info $(p_list ${PKGDEP_PKGS})
121 fi
122
123 # Check if package is already installed
124 VERSION=`${MAKE} clean generate-plist check-already-installed | awk '/is already/ {print $2}'`
125 if [ -n "${VERSION}" ]; then
126 VERSION=`echo ${VERSION} | sed 's/^.*-//g'`
127 p_info ${PACKAGE} already installed at ${VERSION}
128 MAKE_OPTION=''
129 elif [ "${VERSION}" = "An" ]; then
130 #XXX: Better way to detect whether a package needs updating
131 # An older version of lang/python26 is already installed (python26-2.6.2)
132 p_warn ${PACKAGE} outdated, updating...
133 p_warn re-run package-build.sh to check for unmet ones done using:
134 p_warn $0
135 MAKE_OPTION='deinstall reinstall'
136 else
137 p_info ${PACKAGE} not installed, installing...
138 MAKE_OPTION='install'
139 fi
140
141 if [ -n "${MAKE_OPTION}" ]; then
142 p_info Buildlog: $LOGFILE
143 ${MAKE} ${MAKE_OPTION} 2>>$LOGFILE 1>> $LOGFILE
144 if [ $? -ne 0 ]; then
145 p_err building ${PACKAGE} FAILED, logging at $LOGFILE
146 exit 1
147 fi
148 fi
149 ${MAKE} package-links
150 PKGNAME=`make extract-message | awk '{print $NF}'`
151 pkg_create -b $PKGNAME $TARGET/All/${PKGNAME}.tbz
152
153 p_info Checking dependencies
154 for PKG in $PKGDEP_PKGS; do
155 echo "${BUILD_LIST}" | grep -q "$PKG"
156 if [ $? -eq 0 ]; then
157 # Already packaged
158 p_info ${PKG} Already packaged
159 else
160 echo $@ | grep -q "${PKG}"
161 if [ $? -eq 0 ]; then
162 p_info ${PKG} Already planned
163 else
164 set $@ ${PKG}
165 fi
166 fi
167 done
168 p_info Packaging $PACKAGE succesfull
169done
170
171p_info $(echo ${BUILD_LIST} | wc -w) packages build succesfully
172
173if [ ${DEBUG} -eq 0 ]; then
174 rm -R ${LOGDIR}
175else
176 p_info Debugging enabled ${LOGDIR} saved
177fi
178
Note: See TracBrowser for help on using the repository browser.