source: hybrid/branches/releng-10/nanobsd/tools/package-build.sh@ 13267

Last change on this file since 13267 was 13170, checked in by rick, 10 years ago

Cleaning before building to avoid duplicating issues

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