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

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

Merge package building into the central config file, to make custom
configurations more easy to maintain also done at iris and proxy.

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