aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Ferrell <major@homeonderanged.org>2012-03-14 08:31:18 -0500
committerMark Ferrell <major@homeonderanged.org>2012-03-14 08:31:18 -0500
commit3bc5c9e0116e9d22ca831cad96f467d0688abb7a (patch)
treed41e6eac9038d3505ff59f1cee28bc533aeb0076
parentef85f66f8659e11256aa40cb5b7bf98edef74684 (diff)
Eliminate libbuilder.sh
* The 'build' command is now capable of acting as a script-wrapper for sub-commands. This elininates the libbuilder.sh script and the fairly verbose checking for libbuilder.sh in every sub-command.
-rwxr-xr-xbin/build (renamed from build)95
-rwxr-xr-xbin/builder/build-archive (renamed from scripts/build-archive)11
-rwxr-xr-xbin/builder/build-clean (renamed from scripts/build-clean)11
-rwxr-xr-xbin/builder/build-compile (renamed from scripts/build-compile)11
-rwxr-xr-xbin/builder/build-info (renamed from scripts/build-info)11
-rwxr-xr-xbin/builder/build-install (renamed from scripts/build-install)11
-rwxr-xr-xbin/builder/build-makedeps (renamed from scripts/build-makedeps)11
-rwxr-xr-xbin/builder/build-sync (renamed from scripts/build-sync)11
-rw-r--r--scripts/libbuilder.sh52
9 files changed, 100 insertions, 124 deletions
diff --git a/build b/bin/build
index ef512e5..eeef4e5 100755
--- a/build
+++ b/bin/build
@@ -72,6 +72,57 @@ cleanup()
[ -f "${BUILDER_MAKEFILE}" ] && rm -f "${BUILDER_MAKEFILE}"
}
+## error <message>
+# displays the supplied <message> on stderr
+error()
+{
+ echo "error: $*" >&2
+}
+
+## die <message>
+# display the supplied <message> and exit with an error
+die()
+{
+ error "$*"
+ exit 1
+}
+
+## import <package>
+# import a package into the current program space
+import()
+{
+ [ -d "${BUILDER_PKGDIR}/${1}" ] || die "no such package '${1}'"
+ [ -f "${BUILDER_PKGDIR}/${1}/Buildrules" ] || die "no rule to build package '${1}'"
+
+ # Set the name so it can be used in the Buildrules
+ NAME="${1}"
+
+ # Clear all the pkg variables that we depend on
+ VERSION=
+ DESCRIPTION=
+ SOURCE_URI=
+ PATCHES=
+ BDEPENDS=
+ RDEPENDS=
+
+ . "${BUILDER_PKGDIR}/${NAME}/Buildrules"
+
+ [ "${NAME}" = "${1}" ] || die "Buildrules can not set the package name"
+ [ -z "${VERSION}" ] && die "missing version in '${NAME}'"
+ [ -z "${DESCRIPTION}" ] && die "missing description in '${NAME}'"
+
+ if [ ! -d "${BUILDER_PKGDIR}/${NAME}/source" ]; then
+ if [ -z "${SOURCE_URI}" ]; then
+ die "SOURCE_URI undefined and no source directory in '${NAME}'"
+ fi
+ fi
+
+ D="${BUILDER_PKGDIR}/${NAME}/install"
+ S="${BUILDER_PKGDIR}/${NAME}/build/${NAME}-${VERSION}"
+ F="${BUILDER_PKGDIR}/${NAME}/files"
+ L="${BUILDER_PKGDIR}/${NAME}/log"
+}
+
##
# Argument parsing
if [ "$#" -eq "0" ]; then
@@ -80,6 +131,23 @@ if [ "$#" -eq "0" ]; then
exit 1
fi
+##
+# Check to see if we are wrapping a sub-command
+BUILD_COMMAND=
+if [ -f "${1}" ]; then
+ case "${1}" in
+ (*build-*)
+ BUILD_COMMAND="${1}"
+ shift
+ . "${BUILD_COMMAND}"
+ # exit with the exit status of the last command from within the
+ # sub-script. This is normal shell behavior, we are just
+ # making it explicit.
+ exit $?
+ ;;
+ esac
+fi
+
for arg in "$@"; do
case "${arg}" in
(-h|-help|--help) usage; exit 0;;
@@ -138,7 +206,7 @@ CFGDIR=
PKGDIR=
SRCDIR=
ATFDIR=
-BINDIR=
+LIBDIR=
# grab the default and target settings if available, let the target settings
# override the user-defined defaults.
[ -f "${BUILDER_CFGDIR}/default" ] && . "${BUILDER_CFGDIR}/default"
@@ -154,7 +222,7 @@ BUILDER_CFGDIR="${BUILDER_CFGDIR:-${BUILDER_TOPDIR}/.builder}"
BUILDER_PKGDIR="${BUILDER_PKGDIR:-${BUILDER_TOPDIR}/packages}"
BUILDER_SRCDIR="${BUILDER_SRCDIR:-${BUILDER_TOPDIR}/sources}"
BUILDER_ATFDIR="${BUILDER_ATFDIR:-${BUILDER_TOPDIR}/artifacts}"
-BUILDER_BINDIR="${BUILDER_BINDIR:-${BUILDER_TOPDIR}/scripts}"
+BUILDER_LIBDIR="${BUILDER_LIBDIR:-${BUILDER_TOPDIR}/bin/builder}"
BUILDER_SYSROOT="${BUILDER_SYSROOT:-${BUILDER_TOPDIR}/root}"
# set the builder variables based on what was available, either defaults or
@@ -164,25 +232,17 @@ BUILDER_CFGDIR="${CFGDIR:-${BUILDER_CFGDIR}}"
BUILDER_PKGDIR="${PKGDIR:-${BUILDER_PKGDIR}}"
BUILDER_SRCDIR="${SRCDIR:-${BUILDER_SRCDIR}}"
BUILDER_ATFDIR="${ATFDIR:-${BUILDER_ATFDIR}}"
-BUILDER_BINDIR="${BINDIR:-${BUILDER_BINDIR}}"
+BUILDER_LIBDIR="${LIBDIR:-${BUILDER_LIBDIR}}"
BUILDER_SYSROOT="${SYSROOT:-${BUILDER_SYSROOT}}"
export BUILDER_CFGDIR BUILDER_PKGDIR BUILDER_SRCDIR BUILDER_ATFDIR
-export BUILDER_BINDIR BUILDER_TOPDIR BUILDER_SYSROOT
+export BUILDER_LIBDIR BUILDER_TOPDIR BUILDER_SYSROOT
ARCHIVE_FORMAT="${ARCHIVE_FORMAT:-tar.bz2}"
export ARCHIVE_FORMAT
-PATH="${BUILDER_BINDIR}:${PATH}"
+PATH="${BUILDER_LIBDIR}:${PATH}"
export PATH
-# We can finally use our shared library routines
-if [ ! -f "${BUILDER_BINDIR}/libbuilder.sh" ]; then
- echo "error: cannot locate builder library" >&2
- exit 1
-fi
-
-. "${BUILDER_BINDIR}/libbuilder.sh"
-
# Do some basic checking regarding the target package
if [ "$#" -eq "0" ]; then
error "no package specified"
@@ -204,7 +264,7 @@ if [ "$#" -gt "0" ]; then
shift 1
fi
-if [ ! -x "${BUILDER_BINDIR}/build-${ACTION}" ]; then
+if [ ! -x "${BUILDER_LIBDIR}/build-${ACTION}" ]; then
error "unknown action '${ACTION}'"
echo "try '${0} --help'" >&2
exit 1
@@ -212,7 +272,7 @@ fi
# info is a special case
if [ "${ACTION}" = "info" ]; then
- exec "${BUILDER_BINDIR}/build-info" "${NAME}" "${@}"
+ exec "${BUILDER_LIBDIR}/build-info" "${NAME}" "${@}"
fi
# build the Makefile
@@ -222,8 +282,11 @@ if [ ! -f "${BUILDER_MAKEFILE}" ]; then
die "failed to generate build dependencies"
fi
export BUILDER_MAKEFILE
-build-makedeps || die "failed generate build dependencies"
+"${BUILDER_LIBDIR}/build-makedeps" || die "failed generate build dependencies"
+# FIXME not the right way to handle this, we should be only setting this if the
+# target leaves it empty, and we should stick with the norm of setting it to
+# num_cpus+1
MAKE_OPTS="-j8"
export MAKE_OPTS
diff --git a/scripts/build-archive b/bin/builder/build-archive
index e8d6dfb..34ed116 100755
--- a/scripts/build-archive
+++ b/bin/builder/build-archive
@@ -1,11 +1,4 @@
-#!/bin/sh
-
-if [ ! -f "${BUILDER_BINDIR}/libbuilder.sh" ]; then
- echo "error: cannot locate builder library" >&2
- exit 1
-fi
-
-. "${BUILDER_BINDIR}/libbuilder.sh"
+#!/usr/bin/env build
import "${1}"
@@ -28,3 +21,5 @@ case "${ARCHIVE_FORMAT}" in
esac
cd "${D}" && tar c . | ${ARCHIVE_COMPRESSOR} > "${ARCHIVE_TMP}" && mv "${ARCHIVE_TMP}" "${BUILDER_ATFDIR}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}"
+
+# vim: filetype=sh
diff --git a/scripts/build-clean b/bin/builder/build-clean
index f76ea1d..1e81d7f 100755
--- a/scripts/build-clean
+++ b/bin/builder/build-clean
@@ -1,11 +1,4 @@
-#!/bin/sh
-
-if [ ! -f "${BUILDER_BINDIR}/libbuilder.sh" ]; then
- echo "error: cannot locate builder library" >&2
- exit 1
-fi
-
-. "${BUILDER_BINDIR}/libbuilder.sh"
+#!/usr/bin/env build
import "${1}"
@@ -20,3 +13,5 @@ fi
if [ -d "${BUILDER_PKGDIR}/${NAME}/install" ]; then
rm -rf "${BUILDER_PKGDIR}/${NAME}/install"
fi
+
+# vim: filetype=sh
diff --git a/scripts/build-compile b/bin/builder/build-compile
index 18f94fd..4b11102 100755
--- a/scripts/build-compile
+++ b/bin/builder/build-compile
@@ -1,11 +1,4 @@
-#!/bin/sh
-
-if [ ! -f "${BUILDER_BINDIR}/libbuilder.sh" ]; then
- echo "error: cannot locate builder library" >&2
- exit 1
-fi
-
-. "${BUILDER_BINDIR}/libbuilder.sh"
+#!/usr/bin/env build
pkg_compile()
{
@@ -31,3 +24,5 @@ fi
touch "${L}/compile.log"
(cd "${S}" && pkg_compile > "${L}/compile.log" 2>&1 && date --utc > ${L}/.compiled)
+
+# vim: filetype=sh
diff --git a/scripts/build-info b/bin/builder/build-info
index ed8e046..4ab3f48 100755
--- a/scripts/build-info
+++ b/bin/builder/build-info
@@ -1,11 +1,4 @@
-#!/bin/sh
-
-if [ ! -f "${BUILDER_BINDIR}/libbuilder.sh" ]; then
- echo "error: cannot locate builder library" >&2
- exit 1
-fi
-
-. "${BUILDER_BINDIR}/libbuilder.sh"
+#!/usr/bin/env build
import "${1}"
shift
@@ -58,3 +51,5 @@ case "${1}" in
exit 1
;;
esac
+
+# vim: filetype=sh
diff --git a/scripts/build-install b/bin/builder/build-install
index 802b2d8..a08d57c 100755
--- a/scripts/build-install
+++ b/bin/builder/build-install
@@ -1,11 +1,4 @@
-#!/bin/sh
-
-if [ ! -f "${BUILDER_BINDIR}/libbuilder.sh" ]; then
- echo "error: cannot locate builder library" >&2
- exit 1
-fi
-
-. "${BUILDER_BINDIR}/libbuilder.sh"
+#!/usr/bin/env build
import "${1}"
@@ -24,3 +17,5 @@ esac
cd "${BUILDER_SYSROOT}" && ${ARCHIVE_DECOMPRESSOR} "${BUILDER_ATFDIR}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" | tar x
date --utc > "${L}/.installed"
+
+# vim: filetype=sh
diff --git a/scripts/build-makedeps b/bin/builder/build-makedeps
index f6bbf1b..328454f 100755
--- a/scripts/build-makedeps
+++ b/bin/builder/build-makedeps
@@ -1,11 +1,4 @@
-#!/bin/sh
-
-if [ ! -f "${BUILDER_BINDIR}/libbuilder.sh" ]; then
- echo "error: cannot locate builder library" >&2
- exit 1
-fi
-
-. "${BUILDER_BINDIR}/libbuilder.sh"
+#!/usr/bin/env build
PACKAGES=
PACKAGES_SYNC=
@@ -85,3 +78,5 @@ ${package_sync}: ${package_rule}
EOF
done >> "${BUILDER_MAKEFILE}"
+
+# vim: filetype=sh
diff --git a/scripts/build-sync b/bin/builder/build-sync
index 7118ab6..5b9c7bc 100755
--- a/scripts/build-sync
+++ b/bin/builder/build-sync
@@ -1,11 +1,4 @@
-#!/bin/sh
-
-if [ ! -f "${BUILDER_BINDIR}/libbuilder.sh" ]; then
- echo "error: cannot locate builder library" >&2
- exit 1
-fi
-
-. "${BUILDER_BINDIR}/libbuilder.sh"
+#!/usr/bin/env build
import "${1}"
@@ -108,3 +101,5 @@ if [ ! -z "${PATCHES}" ]; then
fi
date --utc > "${L}/.synced"
+
+# vim: filetype=sh
diff --git a/scripts/libbuilder.sh b/scripts/libbuilder.sh
deleted file mode 100644
index 8aab76d..0000000
--- a/scripts/libbuilder.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-## Helper functions
-
-## error <message>
-# displays the supplied <message> on stderr
-error()
-{
- echo "error: $*" >&2
-}
-
-## die <message>
-# display the supplied <message> and exit with an error
-die()
-{
- error "$*"
- exit 1
-}
-
-## import <package>
-# import a package into the current program space
-import()
-{
- [ -d "${BUILDER_PKGDIR}/${1}" ] || die "no such package '${1}'"
- [ -f "${BUILDER_PKGDIR}/${1}/Buildrules" ] || die "no rule to build package '${1}'"
-
- # Set the name so it can be used in the Buildrules
- NAME="${1}"
-
- # Clear all the pkg variables that we depend on
- VERSION=
- DESCRIPTION=
- SOURCE_URI=
- PATCHES=
- BDEPENDS=
- RDEPENDS=
-
- . "${BUILDER_PKGDIR}/${NAME}/Buildrules"
-
- [ "${NAME}" = "${1}" ] || die "Buildrules can not set the package name"
- [ -z "${VERSION}" ] && die "missing version in '${NAME}'"
- [ -z "${DESCRIPTION}" ] && die "missing description in '${NAME}'"
-
- if [ ! -d "${BUILDER_PKGDIR}/${NAME}/source" ]; then
- if [ -z "${SOURCE_URI}" ]; then
- die "SOURCE_URI undefined and no source directory in '${NAME}'"
- fi
- fi
-
- D="${BUILDER_PKGDIR}/${NAME}/install"
- S="${BUILDER_PKGDIR}/${NAME}/build/${NAME}-${VERSION}"
- F="${BUILDER_PKGDIR}/${NAME}/files"
- L="${BUILDER_PKGDIR}/${NAME}/log"
-}