#!/bin/bash # # Build script for # # This build script is meant to be executed from within the source # directory created by extracting the tarball. # # It will create up to 12 log files in the $HOME directory: # # configure.log: All messages output during configure # configure.err: Just the errors output during configure # make.log: All messages output during make # make.err: Just the errors output during make # check.log: All messages output during make check/test # check.err: Just the errors output during make check/test # install.log: All messages output during make install # install.err: Just the errors output during make install # upd.log: Any messages from updating the package list # (usually nothing) # upd.err: Just the errors from updating the package list # (usually nothing) # verupd.log: Any messages from updating the package version # (usually nothing) # verupd.err: Just the errors from updating the package version # (usually nothing) # # After running the script you should check the *.err files to see # if any problems have occurred. If that is the case, use the corresponding # *.log files to see the error messages in context. # # Note: the ":" before the "}" in *_commands() is a no-op that makes sure # that the function remains syntactically valid, even if you remove its # contents (e.g. remove the "configure" line, because there's nothing to # configure for the package). # # Comments throughout the script marked "#*" are places where you may # have to change things for individual package circumstances. ## Version info. ourname=${0##*/} VERSION=1.0 COPYRIGHT="Copyright (C) 2007 - 2010 Steve Youngs " version_str="${ourname}: ${VERSION}\n${COPYRIGHT}" show_version() { echo -e $version_str exit 0 } #* # Set this to 1 (one) if the package's version can be updated # automatically auto_version=0 #* # Set the configure commands/options here. Remove everything except # the braces and colon if the package has no configure. configure_commands() { : ./configure --prefix=/usr \ --infodir=/usr/share/info \ --mandir=/usr/share/man \ --sysconfdir=/etc \ --libexecdir=/usr/lib \ --localstatedir=/var } #* # Set the make commands/options here. make_commands() { : make } #* # Set the test suite commands/options here. Remove everything except # the braces and colon if the package has no test suite check_commands() { : make check } #* # Set the install commands/options here. install_commands() { : make install && # libtool .la files DO NOT need to be executable! (remove if not a # libtool'd package) forall_direntries_from $(whoami) -name \*.la -exec chmod -v 644 {} \; } update_commands() { : sed -i s/"Last_Updated.*"/"Last_Updated: $(date +%c)"/g ${HOME}/.project awk '/^CONTENTS:/ { print; exit; } {print}' ${HOME}/.project > ${HOME}/.projtmp echo "--------" >> ${HOME}/.projtmp list_package $(whoami) >> ${HOME}/.projtmp mv ${HOME}/.projtmp ${HOME}/.project } #* # Set `arg' to command(s) that output just the version number of the # package. version_commands() { : # Commands to update the version string in .project arg='' # replace with something that returns a version number. sed -i "s|\(Version: \).*$|\1${arg}|" ${HOME}/.project } #======================================================================# ### There shouldn't be anything beyond this point to tweak or change ### #======================================================================# test_pipe() { for i in "${PIPESTATUS[@]}"; do test $i != 0 && { echo FAILED! ; exit 1 ; } done echo successful! return 0 } run_configure() { echo -n "Configuring ($(whoami))... " { configure_commands 3>&1 1>&2 2>&3 | tee "$HOME/configure.err" ;} \ &>"$HOME/configure.log" test_pipe [[ ${only} = yes ]] && exit 0 || run_build } run_build() { echo -n "Building ($(whoami))... " { make_commands 3>&1 1>&2 2>&3 | tee "$HOME/make.err" ;} \ &>"$HOME/make.log" test_pipe [[ ${only} = yes ]] && exit 0 || run_check } run_check() { echo -n "Checking ($(whoami))... " { check_commands 3>&1 1>&2 2>&3 | tee "$HOME/check.err" ;} \ &>"$HOME/check.log" test_pipe [[ ${only} = yes ]] && exit 0 || run_install } run_install() { echo -n "Installing ($(whoami))... " { install_commands 3>&1 1>&2 2>&3 | tee "$HOME/install.err" ;} \ &>"$HOME/install.log" test_pipe [[ ${only} = yes ]] && exit 0 || run_update } run_update() { echo -n "Updating package list ($(whoami))... " { update_commands 3>&1 1>&2 2>&3 | tee "$HOME/upd.err" ;} \ &>"$HOME/upd.log" test_pipe # maybe update the version too if [ $auto_version -eq 1 ];then echo -n "Updating package version ($(whoami))... " { version_commands 3>&1 1>&2 2>&3 | tee "$HOME/verupd.err" ;} \ &>"$HOME/verupd.log" test_pipe fi } # Help usage() { # Look for a pager to display the help with. local _cat if [ ${PAGER} ]; then # User has PAGER env var set, use that. _cat=${PAGER} else # No PAGER var set, try most->less->more->cat for pager in most less more cat; do if [ -x "$(which $pager)" ]; then _cat=$pager break else continue fi done fi $_cat<&2 exit 2 ;; esac ;; (c) run_configure ;; (C) only=yes; run_configure ;; (b) run_build ;; (B) only=yes; run_build ;; (k) run_check ;; (K) only=yes; run_check ;; (i) run_install ;; (I) only=yes; run_install ;; (h) usage ;; (u) run_update ;; (V) show_version ;; (*) echo $ourname: error: bad option: -$OPTARG >&2 exit 2 ;; esac done shift $(( $OPTIND - 1 )) else # There were no cmdline args given, just run from configure onwards only=no # this should be "no" already, but make sure run_configure fi ## build ends here