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

Last change on this file since 13414 was 13411, checked in by rick, 9 years ago

New kid in town.

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