source: hybrid/branches/releng-9/nanobsd/tools/package-build.sh@ 12217

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

Inline updating does not work, that is beeing taken care as workaround by portmaster wrapper before calling this scripts these days.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 4.2 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 p_warn "${PACKAGE} outdated, please update"
99 #XXX: Better way to detect whether a package needs updating
100 # An older version of lang/python26 is already installed (python26-2.6.2)
101 #XXX: Broken updatin, please fix
102 #p_warn "re-run package-build.sh to check for unmet ones done using:"
103 #p_warn "$0"
104 #MAKE_OPTION='deinstall reinstall'
105 MAKE_OPTION=''
106 elif [ -n "${VERSION}" ]; then
107 VERSION=`echo ${VERSION} | sed 's/^.*-//g'`
108 p_info ${PACKAGE} already installed at ${VERSION}
109 MAKE_OPTION=''
110 else
111 p_info ${PACKAGE} not installed, installing...
112 MAKE_OPTION='install'
113 fi
114
115 if [ -n "${MAKE_OPTION}" ]; then
116 p_info Buildlog: $LOGFILE
117 ${MAKE} ${MAKE_OPTION} 2>>$LOGFILE 1>> $LOGFILE
118 if [ $? -ne 0 ]; then
119 p_err building ${PACKAGE} FAILED, logging at $LOGFILE
120 exit 1
121 fi
122 fi
123 ${MAKE} package-links
124 PKGNAME=`${MAKE} extract-message | awk '{print $NF}'`
125 pkg_create -b $PKGNAME ${NANO_PACKAGE_DIR}/${PKGNAME}.tbz || exit 1
126
127 p_info Checking dependencies
128 for PKG in $PKGDEP_PKGS; do
129 echo "${BUILD_LIST}" | grep -q "$PKG"
130 if [ $? -eq 0 ]; then
131 # Already packaged
132 p_info ${PKG} Already packaged
133 else
134 echo $@ | grep -q "${PKG}"
135 if [ $? -eq 0 ]; then
136 p_info ${PKG} Already planned
137 else
138 set $@ ${PKG}
139 fi
140 fi
141 done
142 p_info Packaging $PACKAGE succesfull
143done
144
145p_info `echo ${BUILD_LIST} | wc -w` packages build succesfully
146
147if [ ${DEBUG} -eq 0 ]; then
148 rm -R ${LOGDIR}
149else
150 p_info Debugging enabled ${LOGDIR} saved
151fi
152
Note: See TracBrowser for help on using the repository browser.