| 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 |
|
---|
| 9 | DEBUG=${DEBUG:-0}
|
---|
| 10 | DEP_CHECK_ONLY=${DEP_CHECK_ONLY:-0}
|
---|
| 11 |
|
---|
| 12 | # make options, for package building
|
---|
| 13 | LOGDIR=`mktemp -d "/tmp/$(basename $0 .sh)-$(date +%Y%m%d-%H:%M:%S).X"`
|
---|
| 14 | TARGET="`cd $(dirname $0);pwd -P`/../pkg/"
|
---|
| 15 |
|
---|
| 16 | # Package target
|
---|
| 17 | MAKE_ARGS="$MAKE_ARGS PACKAGES=$TARGET"
|
---|
| 18 | MAKE_ARGS="$MAKE_ARGS BATCH=yes PACKAGE_BUILDING=yes"
|
---|
| 19 |
|
---|
| 20 | # www/py-cherrypy
|
---|
| 21 | MAKE_ARGS="${MAKE_ARGS} WITH_APACHE=yes"
|
---|
| 22 | # net-mgmt/net-snmp
|
---|
| 23 | MAKE_ARGS="${MAKE_ARGS} WITHOUT_PERL=yes"
|
---|
| 24 | # net-mgmt/nagios-plugins
|
---|
| 25 | MAKE_ARGS="${MAKE_ARGS} WITH_FPING=yes"
|
---|
| 26 | # threads is broken in the version (atleast up to 9.0 - 20120213)
|
---|
| 27 | # Should be fix in current version in linux, but for some reason
|
---|
| 28 | # Not yet in BSD. We don't need threads
|
---|
| 29 | MAKE_ARGS="${MAKE_ARGS} WITHOUT_THREADS=yes"
|
---|
| 30 |
|
---|
| 31 | p_info Log directory ${LOGDIR}
|
---|
| 32 | p_info Make options are:
|
---|
| 33 | p_info $(p_list ${MAKE_ARGS})
|
---|
| 34 |
|
---|
| 35 | p_info Checking whether there are currently unmet dependencies
|
---|
| 36 | RETVAL=0
|
---|
| 37 | PKGS=`pkg_info | awk '{print $1}'`
|
---|
| 38 | for PKG in ${PKGS} ; do
|
---|
| 39 | PKG_DEP_FAIL=""
|
---|
| 40 | for PKGDEP in `pkg_info -qr ${PKG} | awk '{print $2}'`; do
|
---|
| 41 | pkg_info -e ${PKGDEP}
|
---|
| 42 | if [ $? -eq 1 ]; then
|
---|
| 43 | PKG_DEP_FAIL="${PKG_DEP_FAIL} ${PKGDEP}"
|
---|
| 44 | fi
|
---|
| 45 | done
|
---|
| 46 | if [ -n "${PKG_DEP_FAIL}" ]; then
|
---|
| 47 | p_err Unmet dependencies found at $PKG, please fix manually:
|
---|
| 48 | p_err $(p_list ${PKG_DEP_FAIL})
|
---|
| 49 | RETVAL=1
|
---|
| 50 | fi
|
---|
| 51 | done
|
---|
| 52 | if [ $RETVAL -eq 1 ]; then
|
---|
| 53 | exit 1
|
---|
| 54 | fi
|
---|
| 55 | p_info Dependecy check ok
|
---|
| 56 |
|
---|
| 57 | if [ ${DEP_CHECK_ONLY} -eq 1 ]; then
|
---|
| 58 | exit 0
|
---|
| 59 | fi
|
---|
| 60 | echo ""
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | if [ -d "${TARGET}/All" ]; then
|
---|
| 64 | p_warn "Deleted all (old) packages at ${TARGET}"
|
---|
| 65 | rm -R $TARGET/*
|
---|
| 66 | fi
|
---|
| 67 | p_info Created target dir ${TARGET}/All
|
---|
| 68 | mkdir -p ${TARGET}/All
|
---|
| 69 |
|
---|
| 70 | PORTSDIR='/usr/ports'
|
---|
| 71 | WL_PORTSDIR="`cd $(dirname $0);pwd -P`/../ports/"
|
---|
| 72 |
|
---|
| 73 | PACKAGE_LIST=`cat <<EOF | sed 's/#.*$//g'
|
---|
| 74 | $PORTSDIR/dns/dnsmasq
|
---|
| 75 | $PORTSDIR/www/thttpd
|
---|
| 76 | $PORTSDIR/editors/vim-lite
|
---|
| 77 | $PORTSDIR/lang/python
|
---|
| 78 | $PORTSDIR/net-mgmt/net-snmp
|
---|
| 79 | $PORTSDIR/benchmarks/iperf
|
---|
| 80 | $PORTSDIR/net/pen
|
---|
| 81 | $PORTSDIR/devel/py-yaml
|
---|
| 82 | $PORTSDIR/sysutils/ucspi-tcp
|
---|
| 83 | $PORTSDIR/dns/maradns
|
---|
| 84 | $PORTSDIR/www/tinyproxy
|
---|
| 85 | $PORTSDIR/editors/vim-lite
|
---|
| 86 | $PORTSDIR/security/nmap
|
---|
| 87 | $PORTSDIR/ftp/curl
|
---|
| 88 | $PORTSDIR/security/openvpn
|
---|
| 89 | $PORTSDIR/net/sixxs-aiccu
|
---|
| 90 | $WL_PORTSDIR/net/lvrouted
|
---|
| 91 |
|
---|
| 92 | `
|
---|
| 93 |
|
---|
| 94 | MAKE="make ${MAKE_ARGS}"
|
---|
| 95 |
|
---|
| 96 | BUILD_LIST=''
|
---|
| 97 | # Build required packages
|
---|
| 98 | set ${PACKAGE_LIST}
|
---|
| 99 | while [ "$1" ]; do
|
---|
| 100 | PACKAGE=$1; shift
|
---|
| 101 | BUILD_LIST="${BUILD_LIST} ${PACKAGE}"
|
---|
| 102 |
|
---|
| 103 | # Build new one
|
---|
| 104 | LOGFILE="$LOGDIR/build$(echo $PACKAGE | tr '/' '_').log"
|
---|
| 105 | echo ""
|
---|
| 106 | p_info Packaging $PACKAGE
|
---|
| 107 | cd ${PACKAGE}
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 | # Check for build dependencies
|
---|
| 111 | BUILDDEP_PKG=`${MAKE} build-depends-list | awk -F: '{print $2}'`
|
---|
| 112 | if [ -n "${BUILDDEP_PKG}" ]; then
|
---|
| 113 | p_info Build dependencies needed are:
|
---|
| 114 | p_info $(p_list ${BUILDDEP_PKG})
|
---|
| 115 | fi
|
---|
| 116 |
|
---|
| 117 | # Check for run dependencies
|
---|
| 118 | PKGDEP_PKGS=`${MAKE} package-depends-list | awk '{print $2}'`
|
---|
| 119 | if [ -n "${PKGDEP_PKGS}" ]; then
|
---|
| 120 | p_info Package dependencies also packaged are:
|
---|
| 121 | p_info $(p_list ${PKGDEP_PKGS})
|
---|
| 122 | fi
|
---|
| 123 |
|
---|
| 124 | # Check if package is already installed
|
---|
| 125 | VERSION=`${MAKE} clean generate-plist check-already-installed | awk '/is already/ {print $2}'`
|
---|
| 126 | if [ -n "${VERSION}" ]; then
|
---|
| 127 | VERSION=`echo ${VERSION} | sed 's/^.*-//g'`
|
---|
| 128 | p_info ${PACKAGE} already installed at ${VERSION}
|
---|
| 129 | MAKE_OPTION=''
|
---|
| 130 | elif [ "${VERSION}" = "An" ]; then
|
---|
| 131 | #XXX: Better way to detect whether a package needs updating
|
---|
| 132 | # An older version of lang/python26 is already installed (python26-2.6.2)
|
---|
| 133 | p_warn ${PACKAGE} outdated, updating...
|
---|
| 134 | p_warn re-run package-build.sh to check for unmet ones done using:
|
---|
| 135 | p_warn $0
|
---|
| 136 | MAKE_OPTION='deinstall reinstall'
|
---|
| 137 | else
|
---|
| 138 | p_info ${PACKAGE} not installed, installing...
|
---|
| 139 | MAKE_OPTION='install'
|
---|
| 140 | fi
|
---|
| 141 |
|
---|
| 142 | if [ -n "${MAKE_OPTION}" ]; then
|
---|
| 143 | p_info Buildlog: $LOGFILE
|
---|
| 144 | ${MAKE} ${MAKE_OPTION} 2>>$LOGFILE 1>> $LOGFILE
|
---|
| 145 | if [ $? -ne 0 ]; then
|
---|
| 146 | p_err building ${PACKAGE} FAILED, logging at $LOGFILE
|
---|
| 147 | exit 1
|
---|
| 148 | fi
|
---|
| 149 | fi
|
---|
| 150 | ${MAKE} package-links
|
---|
| 151 | PKGNAME=`make extract-message | awk '{print $NF}'`
|
---|
| 152 | pkg_create -b $PKGNAME $TARGET/All/${PKGNAME}.tbz
|
---|
| 153 |
|
---|
| 154 | p_info Checking dependencies
|
---|
| 155 | for PKG in $PKGDEP_PKGS; do
|
---|
| 156 | echo "${BUILD_LIST}" | grep -q "$PKG"
|
---|
| 157 | if [ $? -eq 0 ]; then
|
---|
| 158 | # Already packaged
|
---|
| 159 | p_info ${PKG} Already packaged
|
---|
| 160 | else
|
---|
| 161 | echo $@ | grep -q "${PKG}"
|
---|
| 162 | if [ $? -eq 0 ]; then
|
---|
| 163 | p_info ${PKG} Already planned
|
---|
| 164 | else
|
---|
| 165 | set $@ ${PKG}
|
---|
| 166 | fi
|
---|
| 167 | fi
|
---|
| 168 | done
|
---|
| 169 | p_info Packaging $PACKAGE succesfull
|
---|
| 170 | done
|
---|
| 171 |
|
---|
| 172 | p_info $(echo ${BUILD_LIST} | wc -w) packages build succesfully
|
---|
| 173 |
|
---|
| 174 | if [ ${DEBUG} -eq 0 ]; then
|
---|
| 175 | rm -R ${LOGDIR}
|
---|
| 176 | else
|
---|
| 177 | p_info Debugging enabled ${LOGDIR} saved
|
---|
| 178 | fi
|
---|
| 179 |
|
---|