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

Last change on this file since 10614 was 10614, checked in by rick, 13 years ago

The list of packages is a full path list and not subs as suggested in r10612.

While here, make sure to die at some other posible fail places as well.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 4.1 KB
Line 
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
13DEBUG=${DEBUG:-'0'}
14DEP_CHECK_ONLY=${DEP_CHECK_ONLY:-'0'}
15
16# make options, for package building
17LOGDIR=`mktemp -d /tmp/$(basename $0 .sh)-$(date '+%Y%m%d-%H:%M:%S')X`
18
19p_info Log directory ${LOGDIR}
20p_info Make options are:
21p_info `p_list ${PKG_MAKE_ARGS}`
22
23# HACK: install our own ports _inside_ the normal ports dir
24cp -fR $WL_PORTSDIR/* $PORTSDIR || exit 1
25
26# Pre-req dependency fixing
27p_info Checking whether there are currently unmet dependencies
28RETVAL=0
29PKGS=`pkg_info | awk '{print $1}'`
30for PKG in ${PKGS} ; do
31 PKG_DEP_FAIL=""
32 for PKGDEP in `pkg_info -qr ${PKG} | awk '{print $2}'`; do
33 pkg_info -e ${PKGDEP}
34 if [ $? -eq 1 ]; then
35 PKG_DEP_FAIL="${PKG_DEP_FAIL} ${PKGDEP}"
36 fi
37 done
38 if [ -n "${PKG_DEP_FAIL}" ]; then
39 p_err Unmet dependencies found at $PKG, please fix manually:
40 p_err `p_list ${PKG_DEP_FAIL}`
41 RETVAL=1
42 fi
43done
44if [ $RETVAL -eq 1 ]; then
45 exit 1
46fi
47p_info Dependecy check ok
48
49if [ ${DEP_CHECK_ONLY} -eq 1 ]; then
50 exit 0
51fi
52echo ""
53
54
55# Cleanup of old packages
56if [ -d "${NANO_PACKAGE_DIR}" ]; then
57 p_warn "Deleted all (old) packages at ${NANO_PACKAGE_DIR}"
58 rm -R ${NANO_PACKAGE_DIR}/*
59fi
60p_info Created target dir ${NANO_PACKAGE_DIR}
61mkdir -p ${NANO_PACKAGE_DIR}
62
63
64# Build required packages
65MAKE="make ${PKG_MAKE_ARGS}"
66BUILD_LIST=''
67set `echo ${PACKAGE_LIST} | xargs -n1 -I% echo $PORTSDIR/%`
68while [ "$1" ]; do
69 PACKAGE=$1; shift
70 BUILD_LIST="${BUILD_LIST} ${PACKAGE}"
71
72 # Build new one
73 LOGFILE="$LOGDIR/build_`echo $PACKAGE | tr '/' '_'`.log"
74 echo ""
75 p_info Packaging $PACKAGE
76 cd $PACKAGE || exit 1
77
78 # Check for build dependencies
79 BUILDDEP_PKG=`${MAKE} build-depends-list | awk -F: '{print $2}'`
80 if [ -n "${BUILDDEP_PKG}" ]; then
81 p_info Build dependencies needed are:
82 p_info `p_list ${BUILDDEP_PKG}`
83 fi
84
85 # Check for run dependencies
86 PKGDEP_PKGS=`${MAKE} package-depends-list | awk '{print $2}'`
87 if [ -n "${PKGDEP_PKGS}" ]; then
88 p_info Package dependencies also packaged are:
89 p_info `p_list ${PKGDEP_PKGS}`
90 fi
91
92 # Check if package is already installed
93 VERSION=`${MAKE} clean generate-plist check-already-installed | awk '/is already/ {print $2}'`
94 if [ -n "$FORCE_REBUILD" ]; then
95 p_warn "${PACKAGE} forcefullly rebuilding..."
96 MAKE_OPTION='deinstall reinstall'
97 elif [ "${VERSION}" = "An" ]; then
98 #XXX: Better way to detect whether a package needs updating
99 # An older version of lang/python26 is already installed (python26-2.6.2)
100 p_warn "${PACKAGE} outdated, updating..."
101 p_warn "re-run package-build.sh to check for unmet ones done using:"
102 p_warn "$0"
103 MAKE_OPTION='deinstall reinstall'
104 elif [ -n "${VERSION}" ]; then
105 VERSION=`echo ${VERSION} | sed 's/^.*-//g'`
106 p_info ${PACKAGE} already installed at ${VERSION}
107 MAKE_OPTION=''
108 else
109 p_info ${PACKAGE} not installed, installing...
110 MAKE_OPTION='install'
111 fi
112
113 if [ -n "${MAKE_OPTION}" ]; then
114 p_info Buildlog: $LOGFILE
115 ${MAKE} ${MAKE_OPTION} 2>>$LOGFILE 1>> $LOGFILE
116 if [ $? -ne 0 ]; then
117 p_err building ${PACKAGE} FAILED, logging at $LOGFILE
118 exit 1
119 fi
120 fi
121 ${MAKE} package-links
122 PKGNAME=`make extract-message | awk '{print $NF}'`
123 pkg_create -b $PKGNAME ${NANO_PACKAGE_DIR}/${PKGNAME}.tbz || exit 1
124
125 p_info Checking dependencies
126 for PKG in $PKGDEP_PKGS; do
127 echo "${BUILD_LIST}" | grep -q "$PKG"
128 if [ $? -eq 0 ]; then
129 # Already packaged
130 p_info ${PKG} Already packaged
131 else
132 echo $@ | grep -q "${PKG}"
133 if [ $? -eq 0 ]; then
134 p_info ${PKG} Already planned
135 else
136 set $@ ${PKG}
137 fi
138 fi
139 done
140 p_info Packaging $PACKAGE succesfull
141done
142
143p_info `echo ${BUILD_LIST} | wc -w` packages build succesfully
144
145if [ ${DEBUG} -eq 0 ]; then
146 rm -R ${LOGDIR}
147else
148 p_info Debugging enabled ${LOGDIR} saved
149fi
150
Note: See TracBrowser for help on using the repository browser.