aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Ferrell <major@homeonderanged.org>2014-04-14 09:52:10 -0700
committerMark Ferrell <major@homeonderanged.org>2014-04-14 09:52:10 -0700
commita97985cc5fc9fc3c56f66187e4a0fe0c67a6fb9b (patch)
tree536026d97b0ed853c45f22d82f6422aad5b62931
parent737163bef8f1ca026d543d7159153cb6691f0bcc (diff)
Make various sub-commands proper builder libraries
* Have fixed up various sub-commands so that they can now be used via import() as well as executed as a command.
-rwxr-xr-xlibexec/build-fetch-git18
-rwxr-xr-xlibexec/build-fetch-svn19
-rwxr-xr-xlibexec/build-make186
-rwxr-xr-xlibexec/build-make-clean46
-rwxr-xr-xlibexec/build-make-compile129
-rwxr-xr-xlibexec/build-make-distclean45
-rwxr-xr-xlibexec/build-make-export165
-rwxr-xr-xlibexec/build-make-fetch42
-rwxr-xr-xlibexec/build-make-install70
-rwxr-xr-xlibexec/build-make-package87
-rwxr-xr-xlibexec/build-make-prep143
-rwxr-xr-xlibexec/build-make-source135
-rwxr-xr-xlibexec/build-make-test24
-rwxr-xr-xlibexec/build-makedeps6
-rwxr-xr-xlibexec/build-query4
15 files changed, 513 insertions, 606 deletions
diff --git a/libexec/build-fetch-git b/libexec/build-fetch-git
index e8cd5ec..bb96a45 100755
--- a/libexec/build-fetch-git
+++ b/libexec/build-fetch-git
@@ -92,23 +92,7 @@ build_fetch_git()
}
if test "${BUILDER_CALL_STACK}" = '__main__'; then
- build_fetch_git_usage() { printf 'usage: build-fetch-git <url>\n'; }
-
- for arg; do
- case "${arg}" in
- (-h|-help|--help) build_fetch_git_usage;;
- esac
- done
-
- while test "$#" -gt '0'; do
- case "$1" in
- (-*) error "unknown argument '${1}'"
- echo "try 'build fetch-git --help'" >&2
- exit 1;;
- (--) shift 1; break;;
- (*) break;;
- esac
- done
+ usage 'fetch-git' '<url>'
build_fetch_git "${1}"
fi
diff --git a/libexec/build-fetch-svn b/libexec/build-fetch-svn
index 5a6d32e..9719b6c 100755
--- a/libexec/build-fetch-svn
+++ b/libexec/build-fetch-svn
@@ -45,24 +45,7 @@ build_fetch_svn()
}
if test "${BUILDER_CALL_STACK}" = '__main__'; then
- build_fetch_svn_usage() { printf 'usage: build-fetch-svn <url>\n'; }
-
- for arg; do
- case "${arg}" in
- (-h|-help|--help) build_fetch_svn_usage;;
- esac
- done
-
- while test "$#" -gt '0'; do
- case "$1" in
- (-*) error "unknown argument '${1}'"
- echo "try 'build fetch-svn --help'" >&2
- exit 1;;
- (--) shift 1; break;;
- (*) break;;
- esac
- done
-
+ usage 'fetch-svn' '<url>'
build_fetch_svn "${1}"
fi
diff --git a/libexec/build-make b/libexec/build-make
index 3b07545..01afbee 100755
--- a/libexec/build-make
+++ b/libexec/build-make
@@ -1,113 +1,113 @@
#!/usr/bin/env build
-while test "$#" -gt '0'; do
- case "${1}" in
- (-h|-help|--help) usage; exit 0;;
- (--) shift; break;;
- (-*) error "unknown optopn '${1}'"
+build_make()
+{
+ if test "$#" -eq '0'; then
+ error 'no make action specified'
echo "try 'build help make'" >&2
- exit 1;;
- (*) break;;
- esac
-done
-
-if test "$#" -eq '0'; then
- error 'no make action specified'
- echo "try 'build help make'" >&2
- exit 1
-fi
+ exit 1
+ fi
-BUILDER_MAKE_ACTION="${1}"
-shift
+ BUILDER_MAKE_ACTION="${1}"
+ shift
-# This allows 'build install --help' to work.
-for arg; do
- case "${arg}" in
- (-h|-help|--help) exec build make-"${BUILDER_MAKE_ACTION}" --help;;
- esac
-done
+ # This allows 'build <command> --help' to work.
+ for arg; do
+ case "${arg}" in
+ (-h|-help|--help) exec build make-"${BUILDER_MAKE_ACTION}" --help;;
+ esac
+ done
-# If no target is given, then base our target on the current working directory,
-# falling back to "${PROJECT}/all" as our default.
-if test "$#" -eq '0'; then
- case "${BUILDER_MAKE_ACTION}" in
- (*clean) NAME='all/all';;
- (*) NAME="${TARGET}";;
- esac
+ # If no target is given, then base our target on the current working
+ # directory, falling back to "${PROJECT}/all" as our default.
+ if test "$#" -eq '0'; then
+ case "${BUILDER_MAKE_ACTION}" in
+ (*clean) NAME='all/all';;
+ (*) NAME="${TARGET}";;
+ esac
- # Are we somewhere within the pkg structure. If this test succeeds
- # then we are at least in a category directory within the pkgdir. Just
- # being in pkgdir is not enough to change our default argument list
- # handling.
- if [ "${PWD##${BUILDER_PKGDIR}/}" != "${PWD}" ]; then
- category="${PWD##${BUILDER_PKGDIR}/}"
- if [ "${category%%/*}" != "${category}" ]; then
- name="${category#*/}"
- category="${category%%/*}"
- NAME="${category}/${name%%/*}"
- else
- NAME="${category}/all"
+ # Are we somewhere within the pkg structure. If this test
+ # succeeds then we are at least in a category directory within
+ # the pkgdir. Just being in pkgdir is not enough to change our
+ # default argument list handling.
+ if [ "${PWD##${BUILDER_PKGDIR}/}" != "${PWD}" ]; then
+ category="${PWD##${BUILDER_PKGDIR}/}"
+ if [ "${category%%/*}" != "${category}" ]; then
+ name="${category#*/}"
+ category="${category%%/*}"
+ NAME="${category}/${name%%/*}"
+ else
+ NAME="${category}/all"
+ fi
+ unset category
+ unset name
fi
- unset category
- unset name
+ set -- "${NAME}"
fi
- set -- "${NAME}"
-fi
-# FIXME move this to a sub-command to be used by other tools.
-for package in "$@"; do
- # If all is specified anywhere in the argument list than just discard
- # everything else.
- case "${package}" in
- (-*|*/all|all) continue;;
- esac
+ # FIXME move this to a sub-command to be used by other tools.
+ for package in "$@"; do
+ # If all is specified anywhere in the argument list than just
+ # discard everything else.
+ case "${package}" in
+ (-*|*/all|all) continue;;
+ esac
- CATEGORY="${package%%/*}"
- if [ "${CATEGORY}" != 'all' ]; then
- if [ ! -d "${BUILDER_PKGDIR}/${CATEGORY}" ]; then
- die "invalid package category '${CATEGORY}'"
- fi
- if ! build-query --exists "${package}"; then
- exit 1
+ CATEGORY="${package%%/*}"
+ if [ "${CATEGORY}" != 'all' ]; then
+ if [ ! -d "${BUILDER_PKGDIR}/${CATEGORY}" ]; then
+ die "invalid package category '${CATEGORY}'"
+ fi
+ if ! build-query --exists "${package}"; then
+ exit 1
+ fi
fi
+ done
+
+ # sort/uniq the argument list
+ # FIXME need a way to "resolve" the package list instead of possibly
+ # clobbering it.
+ set -- $(for package in "$@"; do echo "${package}" ; done | sort | uniq)
+
+ # build the Makefile
+ trap cleanup EXIT
+ test -d "${BUILDER_TMPDIR}" || mkdir -p "${BUILDER_TMPDIR}"
+ BUILDER_MAKEFILE="$(mktemp "${BUILDER_TMPDIR}/builder_makefile.XXXXXXXX")"
+ if [ ! -f "${BUILDER_MAKEFILE}" ]; then
+ die "failed to generate build dependencies"
fi
-done
+ export BUILDER_MAKEFILE
+ "${BUILDER_LIBDIR}/build-makedeps" || die "failed generate build dependencies"
+
+ packages=
+ for package in "$@"; do
+ case "${package}" in
+ (all|*/all);;
+ (*) package="$(build-query --pkgname "${package}")";;
+ esac
+ package="$(echo "${package}"|tr '/-' '__')"
+ packages="${packages} ${package}_${BUILDER_MAKE_ACTION}"
+ done
+ set -- ${packages}
+ unset packages
-# sort/uniq the argument list
-# FIXME need a way to "resolve" the package list instead of possibly clobbering
-# it.
-set -- $(for package in "$@"; do echo "${package}" ; done | sort | uniq)
+ # The 'tee' command will discard the exit status from 'make', so we
+ # have to jump through a few hoops to capture the exit status in a
+ # portable fashion.
+ BUILDER_PIPE="`mktemp "${BUILDER_TMPDIR}/builder_pipe.XXXXXXXX"`"
+ test -f "${BUILDER_PIPE}" || die 'failed to generate log-pipe placeholder'
+ rm -f "${BUILDER_PIPE}" && mkfifo "${BUILDER_PIPE}" || die 'failed to create log-pipe'
+ tee "${BUILDER_TMPDIR}/builder.log" < "${BUILDER_PIPE}" &
+ BUILDER_LOGGER="$!"
+ make -r -f "${BUILDER_MAKEFILE}" "${@}" > "${BUILDER_PIPE}" 2>&1
+ exit $?
+}
-# build the Makefile
-trap cleanup EXIT
-test -d "${BUILDER_TMPDIR}" || mkdir -p "${BUILDER_TMPDIR}"
-BUILDER_MAKEFILE="$(mktemp "${BUILDER_TMPDIR}/builder_makefile.XXXXXXXX")"
-if [ ! -f "${BUILDER_MAKEFILE}" ]; then
- die "failed to generate build dependencies"
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'make' '<action> [all|[<category>/]<package|all>]' "$@"
+ build_make "${@}"
fi
-export BUILDER_MAKEFILE
-"${BUILDER_LIBDIR}/build-makedeps" || die "failed generate build dependencies"
-packages=
-for package in "$@"; do
- case "${package}" in
- (all|*/all);;
- (*) package="$(build-query --pkgname "${package}")";;
- esac
- package="$(echo "${package}"|tr '/-' '__')"
- packages="${packages} ${package}_${BUILDER_MAKE_ACTION}"
-done
-set -- ${packages}
-unset packages
-# The 'tee' command will discard the exit status from 'make', so we have to
-# jump through a few hoops to capture the exit status in a portable fashion.
-BUILDER_PIPE="`mktemp "${BUILDER_TMPDIR}/builder_pipe.XXXXXXXX"`"
-test -f "${BUILDER_PIPE}" || die 'failed to generate log-pipe placeholder'
-rm -f "${BUILDER_PIPE}" && mkfifo "${BUILDER_PIPE}" || die 'failed to create log-pipe'
-tee "${BUILDER_TMPDIR}/builder.log" < "${BUILDER_PIPE}" &
-BUILDER_LOGGER="$!"
-make -r -f "${BUILDER_MAKEFILE}" "${@}" > "${BUILDER_PIPE}" 2>&1
-exit $?
# vim: filetype=sh
diff --git a/libexec/build-make-clean b/libexec/build-make-clean
index b7c0927..6ccc730 100755
--- a/libexec/build-make-clean
+++ b/libexec/build-make-clean
@@ -1,28 +1,36 @@
#!/usr/bin/env build
-eval $(build-query --environ "${1}")
+build_make_clean()
+{
+ eval $(build-query --environ "${1}")
-if [ -z "${NOCLEAN}" ]; then
- echo "cleaning: ${1}"
- if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then
- rm "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" &
- fi
- if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
- cd "${SYSROOT}"
- # FIXME: we are failing to handle file collisions produce in
- # this file.
- cat "var/db/binpkgs/${CATEGORY}/${NAME}" | xargs -0 rm -f &
- fi
- if [ -d "${W}" ]; then
- rm -rf "${W}" &
- fi
+ if [ -z "${NOCLEAN}" ]; then
+ echo "cleaning: ${1}"
+ if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then
+ rm "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" &
+ fi
+ if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
+ cd "${SYSROOT}"
+ # FIXME: we are failing to handle file collisions produce in
+ # this file.
+ cat "var/db/binpkgs/${CATEGORY}/${NAME}" | xargs -0 rm -f &
+ fi
+ if [ -d "${W}" ]; then
+ rm -rf "${W}" &
+ fi
- wait
+ wait
- # Clobber our package marker.
- if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
- rm "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}"
+ # Clobber our package marker.
+ if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
+ rm "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}"
+ fi
fi
+}
+
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'clean' '[all|[<category>/]<package|all>]' "$@"
+ build_make_clean "${@}"
fi
# vim: filetype=sh
diff --git a/libexec/build-make-compile b/libexec/build-make-compile
index 605fc4c..5245e63 100755
--- a/libexec/build-make-compile
+++ b/libexec/build-make-compile
@@ -28,68 +28,75 @@ build_compile()
}
pkg_compile() { build_compile; }
-load_rules "${1}"
-
-# Declare compilation variables before loading the rules as the package may
-# potentially overwrite this data, in particular the toolchain data is usually
-# rewritten within the toolchain/buildtools rule.
-echo "compiling: ${1}"
-eval "$(build-query --toolchain "${CHOST}")"
-mkenv "compile"
-PKG_LOGFILE="${L}/compile.log"
-
-# pkgconfig can be a right pita...
-PKG_CONFIG_LIBDIR="${SYSROOT}/usr/share/pkgconfig:${SYSROOT}/usr/lib/pkgconfig"
-PKG_CONFIG_SYSROOT_DIR="${SYSROOT}"
-export PKG_CONFIG_LIBDIR PKG_CONFIG_PATH
-export PKG_CONFIG_SYSROOT_DIR
-
-# Don't pass along the builder jobcontrol data to child processes
-unset MAKEFLAGS
-
-load_rules "${1}"
-
-## Prep the build environment
-# Technically much of this should have been done in build-prep, and this sort
-# of duplication of work may be useful to make a function within the top-level
-# build script. Perhaps builder_mkenv [prep|compile|archive|etc..]
-
-## Build the source and install it into the DESTDIR
-# Ironically this is the heart of what the build-engine does, and yet it has
-# been reduced to the simplest component of the entire system.
-cd "${S}"
-pkg_compile >> "${PKG_LOGFILE}" 2>&1
-
-## Save Space!
-# At this point everything important should be installed into ${D}, and any
-# form of reruning the build will remove ${S} before prepping it for build, so
-# we might as well gut it now. About the best option we could do would be to
-# avoid gutting this when being run in --debug mode.
-find "${S}" -delete &
-
-##
-# Generate the file index. This is done as a 0 delimited file stored within
-# the destination filesystem. This allows for easy checking of the installed
-# data as well as easy removal of individual binary packages from the sysroot.
-mkdir -p "${D}/var/db/binpkgs/${CATEGORY}"
-binpkg_list="$(mktemp "${T}/binpkg.XXXXXXXX")"
-if [ ! -e "${binpkg_list}" ]; then
- die "failed to create package inventory"
-fi
-cd "${D}"
-for dir in man usr/man usr/share/man; do
- test -d "${dir}" || continue
- for file in `find "${dir}" -regex '.*[1-9]$'`; do
- if test -f "${file}"; then
- gzip -c -9 "${file}" > "${file}.gz" && rm "${file}"
- elif test -h "${file}"; then
- mv "${file}" "${file}.gz"
- fi
+build_make_compile()
+{
+ load_rules "${1}"
+
+ # Declare compilation variables before loading the rules as the package
+ # may potentially overwrite this data, in particular the toolchain data
+ # is usually rewritten within the toolchain/buildtools rule.
+ echo "compiling: ${1}"
+ eval "$(build-query --toolchain "${CHOST}")"
+ mkenv "compile"
+ PKG_LOGFILE="${L}/compile.log"
+
+ # pkgconfig can be a right pita...
+ PKG_CONFIG_LIBDIR="${SYSROOT}/usr/share/pkgconfig:${SYSROOT}/usr/lib/pkgconfig"
+ PKG_CONFIG_SYSROOT_DIR="${SYSROOT}"
+ export PKG_CONFIG_LIBDIR PKG_CONFIG_PATH
+ export PKG_CONFIG_SYSROOT_DIR
+
+ # Don't pass along the builder jobcontrol data to child processes
+ unset MAKEFLAGS
+
+ load_rules "${1}"
+
+ ## Build the source and install it into the DESTDIR
+ # Ironically this is the heart of what the build-engine does, and yet it has
+ # been reduced to the simplest component of the entire system.
+ cd "${S}"
+ pkg_compile >> "${PKG_LOGFILE}" 2>&1
+
+ ## Save Space!
+ # At this point everything important should be installed into ${D}, and
+ # any form of reruning the build will remove ${S} before prepping it
+ # for build, so we might as well gut it now. About the best option we
+ # could do would be to avoid gutting this when being run in --debug
+ # mode.
+ find "${S}" -delete &
+
+ ##
+ # Generate the file index. This is done as a 0 delimited file stored
+ # within the destination filesystem. This allows for easy checking of
+ # the installed data as well as easy removal of individual binary
+ # packages from the sysroot.
+ mkdir -p "${D}/var/db/binpkgs/${CATEGORY}"
+ binpkg_list="$(mktemp "${T}/binpkg.XXXXXXXX")"
+ if [ ! -e "${binpkg_list}" ]; then
+ die "failed to create package inventory"
+ fi
+ cd "${D}"
+ for dir in man usr/man usr/share/man; do
+ test -d "${dir}" || continue
+ for file in `find "${dir}" -regex '.*[1-9]$'`; do
+ if test -f "${file}"; then
+ gzip -c -9 "${file}" > "${file}.gz" && rm "${file}"
+ elif test -h "${file}"; then
+ mv "${file}" "${file}.gz"
+ fi
+ done
+ wait
done
wait
-done
-wait
-find * -depth \( ! -type d \) -print0 > "${binpkg_list}"
-mv "${binpkg_list}" "${D}/var/db/binpkgs/${CATEGORY}/${NAME}"
+ find * -depth \( ! -type d \) -print0 > "${binpkg_list}"
+ mv "${binpkg_list}" "${D}/var/db/binpkgs/${CATEGORY}/${NAME}"
+}
+
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'compile' '[all|[<category>/]<package|all>]' "$@"
+ build_make_compile "${@}"
+fi
+
+
# vim: filetype=sh
diff --git a/libexec/build-make-distclean b/libexec/build-make-distclean
index 1b61e4a..689ae80 100755
--- a/libexec/build-make-distclean
+++ b/libexec/build-make-distclean
@@ -1,26 +1,35 @@
#!/usr/bin/env build
-echo "distcleaning: ${1}"
-eval $(build-query --environ "${1}")
+build_make_distclean()
+{
+ echo "distcleaning: ${1}"
+ eval $(build-query --environ "${1}")
-if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then
- rm "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" &
-fi
-if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
- cd "${SYSROOT}"
- # FIXME: we are failing to handle file collisions produce in
- # this file.
- cat "var/db/binpkgs/${CATEGORY}/${NAME}" | xargs -0 rm -f &
-fi
-if [ -d "${W}" ]; then
- rm -rf "${W}" &
-fi
+ if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then
+ rm "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" &
+ fi
+ if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
+ cd "${SYSROOT}"
+ # FIXME: we are failing to handle file collisions produce in
+ # this file.
+ cat "var/db/binpkgs/${CATEGORY}/${NAME}" | xargs -0 rm -f &
+ fi
+ if [ -d "${W}" ]; then
+ rm -rf "${W}" &
+ fi
-wait
+ wait
-# Clobber our package marker.
-if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
- rm "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}"
+ # Clobber our package marker.
+ if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
+ rm "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}"
+ fi
+}
+
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'distclean' '[all|[<category>/]<package|all>]' "$@"
+ build_make_distclean "${@}"
fi
+
# vim: filetype=sh
diff --git a/libexec/build-make-export b/libexec/build-make-export
index a93906d..230245f 100755
--- a/libexec/build-make-export
+++ b/libexec/build-make-export
@@ -1,94 +1,103 @@
#!/usr/bin/env build
-load_rules "${1}"
+build_make_export()
+{
+ load_rules "${1}"
-if test -z "${LICENSE}"; then
- die "no license set in '${1}'"
-fi
+ if test -z "${LICENSE}"; then
+ die "no license set in '${1}'"
+ fi
-echo "exporting ${1}"
+ echo "exporting ${1}"
-for dir in "${S}" "${D}"; do
- if ! test -d "${dir}"; then
- continue
- fi
- mv "${dir}" "${dir}.old"
- find "${dir}.old" -delete &
-done
-unset dir
+ for dir in "${S}" "${D}"; do
+ if ! test -d "${dir}"; then
+ continue
+ fi
+ mv "${dir}" "${dir}.old"
+ find "${dir}.old" -delete &
+ done
+ unset dir
-mkenv 'export'
-EXPORT_LOGFILE="${L}/export.log"
+ mkenv 'export'
+ EXPORT_LOGFILE="${L}/export.log"
-mkdir -p "${T}/${NAME}-${VERSION}.builder"
-cp "${RULESFILE}" "${T}/${NAME}-${VERSION}.builder/"
+ mkdir -p "${T}/${NAME}-${VERSION}.builder"
+ cp "${RULESFILE}" "${T}/${NAME}-${VERSION}.builder/"
-if ! test -z "${PATCHES}"; then
- for patch in ${PATCHES}; do
- cp "${F}/${NAME}-${VERSION}-${patch}.patch" "${T}/${NAME}-${VERSION}.builder/"
- done
-fi
+ if ! test -z "${PATCHES}"; then
+ for patch in ${PATCHES}; do
+ cp "${F}/${NAME}-${VERSION}-${patch}.patch" "${T}/${NAME}-${VERSION}.builder/"
+ done
+ fi
-cd "${T}"
+ cd "${T}"
-for url in ${SOURCE_URI}; do
- file="$(build-url --archive "${url}")"
- test -f "${BUILDER_SRCDIR}/${file}" || die "source does not exist '${file}'"
- cp "${BUILDER_SRCDIR}/${file}" "${NAME}-${VERSION}.builder/"
-done
+ for url in ${SOURCE_URI}; do
+ file="$(build-url --archive "${url}")"
+ test -f "${BUILDER_SRCDIR}/${file}" || die "source does not exist '${file}'"
+ cp "${BUILDER_SRCDIR}/${file}" "${NAME}-${VERSION}.builder/"
+ done
-for dir in SOURCES SPECS RPMS BUILD; do
- mkdir -p "${S}/${dir}" &
-done
-wait
+ for dir in SOURCES SPECS RPMS BUILD; do
+ mkdir -p "${S}/${dir}" &
+ done
+ wait
-if ! tar czf "${S}/SOURCES/${NAME}-${VERSION}.builder.tar.gz" "${NAME}-${VERSION}.builder"; then
- die "Failed to create base rpm tarball."
-fi
+ if ! tar czf "${S}/SOURCES/${NAME}-${VERSION}.builder.tar.gz" "${NAME}-${VERSION}.builder"; then
+ die "Failed to create base rpm tarball."
+ fi
-cat <<EOF > "${S}/SPECS/${NAME}-${VERSION}.spec"
-Summary: ${DESCRIPTION}
-Name: ${NAME}
-Version: ${VERSION}
-Release: ${RELEASE}
-License: ${LICENSE}
-Group: ${CATEGORY}
-Source: ${NAME}-${VERSION}.builder.tar.gz
-Buildroot: ${SYSROOT}
-%description
-${DESCRIPTION}
-
-%prep
-%setup -c
-
-%build
-
-%install
-
-%clean
-
-%files
-EOF
-# FIXME In the long run we should see about producing -dbg and -dev rpms
-tr '\000' '\n' < "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" \
- | sed -e 's,^,/,' \
- | grep -v '^/usr/include' | grep -v 'pkgconfig' | grep -v '^*\.a$' \
- >> "${S}/SPECS/${NAME}-${VERSION}.spec"
-
-#mkdir -p "${D}"
-#cd "${D}"
-#tar xaf "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}"
-
-rpmbuild --quiet --target "${CHOST}" \
- --define "_topdir ${S}" \
- --define "buildroot ${SYSROOT}" \
- --define '_unpackaged_files_terminate_build 0' \
- --define '_missing_doc_files_terminate_build 0' \
- --define "arch ${CHOST%%-*}" \
- -bb "${S}/SPECS/${NAME}-${VERSION}.spec" > "${L}/export.log" 2>&1 || die "Failed to integrate rpm spec file"
-
-mkdir -p "${BUILDER_TOPDIR}/exports"
+ cat <<-EOF > "${S}/SPECS/${NAME}-${VERSION}.spec"
+ Summary: ${DESCRIPTION}
+ Name: ${NAME}
+ Version: ${VERSION}
+ Release: ${RELEASE}
+ License: ${LICENSE}
+ Group: ${CATEGORY}
+ Source: ${NAME}-${VERSION}.builder.tar.gz
+ Buildroot: ${SYSROOT}
+ %description
+ ${DESCRIPTION}
+
+ %prep
+ %setup -c
+
+ %build
+
+ %install
+
+ %clean
+
+ %files
+ EOF
+
+ # FIXME In the long run we should see about producing -dbg and -dev rpms
+ tr '\000' '\n' < "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" \
+ | sed -e 's,^,/,' \
+ | grep -v '^/usr/include' | grep -v 'pkgconfig' | grep -v '^*\.a$' \
+ >> "${S}/SPECS/${NAME}-${VERSION}.spec"
+
+ #mkdir -p "${D}"
+ #cd "${D}"
+ #tar xaf "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}"
+
+ rpmbuild --quiet --target "${CHOST}" \
+ --define "_topdir ${S}" \
+ --define "buildroot ${SYSROOT}" \
+ --define '_unpackaged_files_terminate_build 0' \
+ --define '_missing_doc_files_terminate_build 0' \
+ --define "arch ${CHOST%%-*}" \
+ -bb "${S}/SPECS/${NAME}-${VERSION}.spec" > "${L}/export.log" 2>&1 || die "Failed to integrate rpm spec file"
+
+ mkdir -p "${BUILDER_TOPDIR}/exports"
# FIXME figure out the arch properly
-mv "${S}/RPMS/${CHOST%%-*}/${NAME}-${VERSION}-${RELEASE}.${CHOST%%-*}.rpm" "${BUILDER_TOPDIR}/exports/" || die "Failed to move rpm"
+ mv "${S}/RPMS/${CHOST%%-*}/${NAME}-${VERSION}-${RELEASE}.${CHOST%%-*}.rpm" "${BUILDER_TOPDIR}/exports/" || die "Failed to move rpm"
+}
+
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'export' '[all|[<category>/]<package|all>]' "$@"
+ build_make_export "${@}"
+fi
# vim: filetype=sh
diff --git a/libexec/build-make-fetch b/libexec/build-make-fetch
index 3e318bd..90abfb4 100755
--- a/libexec/build-make-fetch
+++ b/libexec/build-make-fetch
@@ -1,8 +1,6 @@
#!/usr/bin/env build
-build_fetch_usage() { echo 'usage: build-fetch [options] <url>'; }
-
-build_fetch_clean()
+build_make_fetch_cleanup()
{
for arg in ${BUILD_FETCH_CLEAN}; do
if [ -d "${arg}" ]; then
@@ -13,16 +11,10 @@ build_fetch_clean()
done
}
-if ! test -d "${BUILDER_TMPDIR}/fetch"; then
- mkdir -p "${BUILDER_TMPDIR}/fetch"
-fi
-FETCH_LOG="${BUILDER_TMPDIR}/fetch/$(build-url --archive "${1}").log"
-rm -f "${FETCH_LOG}"
-touch "${FETCH_LOG}"
-
-trap build_fetch_clean 0
-build_fetch()
+build_make_fetch()
{
+ trap build_make_fetch_cleanup 0
+
echo "trying: fetch ${1}"
build_fetch_proto="$(build-url --proto "${1}")"
@@ -34,11 +26,25 @@ build_fetch()
"$@"
}
-build_fetch_file="$(build-url --archive "${1}")"
-for mirror in ${MIRRORS}; do
- build_fetch "${mirror}/${build_fetch_file}" && exit
-done
-build_fetch "${1}"
-unset build_fetch_file
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'fetch' '[all|[<category>/]<package|all>]' "$@"
+
+ build_fetch_file="$(build-url --archive "${1}")"
+ for mirror in ${MIRRORS}; do
+ build_fetch "${mirror}/${build_fetch_file}" && exit
+ done
+ build_make_fetch "${1}"
+ unset build_fetch_file
+
+ if ! test -d "${BUILDER_TMPDIR}/fetch"; then
+ mkdir -p "${BUILDER_TMPDIR}/fetch"
+ fi
+ FETCH_LOG="${BUILDER_TMPDIR}/fetch/$(build-url --archive "${1}").log"
+ rm -f "${FETCH_LOG}"
+ touch "${FETCH_LOG}"
+
+ build_make_fetch "${@}"
+fi
+
# vim: filetype=sh
diff --git a/libexec/build-make-install b/libexec/build-make-install
index 08dd4db..fd0a4e9 100755
--- a/libexec/build-make-install
+++ b/libexec/build-make-install
@@ -1,53 +1,41 @@
#!/usr/bin/env build
-usage()
+build_make_install()
{
-cat<<END_OF_USAGE
-END_OF_USAGE
-}
-
-for arg; do
- case "${arg}" in
- (-h|-help|--help) usage; exit 0;;
+ echo "installing: ${1}"
+ eval $(build-query --environ "${1}")
+
+ if [ ! -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then
+ die "archive does not exist for package '${NAME}'"
+ fi
+ if [ ! -d "${SYSROOT}" ]; then
+ mkdir -p "${SYSROOT}" || die "failed to create system root @ '${SYSROOT}'"
+ fi
+
+ # FIXME the builder configs should decide the binpkg archive format.
+ case "${ARCHIVE_FORMAT}" in
+ (tbz2|tar.bz2) ARCHIVE_DECOMPRESSOR="bzip2 -dc";;
+ (tgz|tar.gz) ARCHIVE_DECOMPRESSOR="gzip -dc";;
+ (*) die "unsupported archive format '${ARCHIVE_FORMAT}'";;
esac
-done
-
-while test "$#" -gt '0'; do
- case "$1" in
- (-*) error "unknown argument '${1}'"
- echo "try 'build help install'" >&2
- exit 1;;
- (--) shift; break;;
- (*) break;;
- esac
-done
-
-echo "installing: ${1}"
-eval $(build-query --environ "${1}")
-if [ ! -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then
- die "archive does not exist for package '${NAME}'"
-fi
-if [ ! -d "${SYSROOT}" ]; then
- mkdir -p "${SYSROOT}" || die "failed to create system root @ '${SYSROOT}'"
-fi
+ cd "${SYSROOT}"
-# FIXME the builder configs should decide the binpkg archive format.
-case "${ARCHIVE_FORMAT}" in
-(tbz2|tar.bz2) ARCHIVE_DECOMPRESSOR="bzip2 -dc";;
-(tgz|tar.gz) ARCHIVE_DECOMPRESSOR="gzip -dc";;
-(*) die "unsupported archive format '${ARCHIVE_FORMAT}'";;
-esac
+ if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
+ echo "${NAME}: removing previous version"
+ cat "var/db/binpkgs/${CATEGORY}/${NAME}" | xargs -0 rm -f
+ rm "var/db/binpkgs/${CATEGORY}/${NAME}"
+ fi
-cd "${SYSROOT}"
+ ${ARCHIVE_DECOMPRESSOR} "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" | tar x
+ touch "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}"
+}
-if [ -f "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" ]; then
- echo "${NAME}: removing previous version"
- cat "var/db/binpkgs/${CATEGORY}/${NAME}" | xargs -0 rm -f
- rm "var/db/binpkgs/${CATEGORY}/${NAME}"
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'install' '[all|[<category>/]<package|all>]' "$@"
+ build_make_install "${@}"
fi
-${ARCHIVE_DECOMPRESSOR} "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" | tar x
-touch "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}"
+
# vim: filetype=sh
diff --git a/libexec/build-make-package b/libexec/build-make-package
index 40b9756..6af134d 100755
--- a/libexec/build-make-package
+++ b/libexec/build-make-package
@@ -1,8 +1,8 @@
#!/usr/bin/env build
-ARCHIVE_TMP1=
-ARCHIVE_TMP2=
-exit_cleanup()
+BUILD_MAKE_ARCHIVE_TMP1=
+BUILD_MAKE_ARCHIVE_TMP2=
+build_make_archive_cleanup()
{
ret=$?
@@ -11,51 +11,62 @@ exit_cleanup()
echo "logfile: '${PKG_LOGFILE}'" >&2
exit ${ret}
fi
- if [ -f "${ARCHIVE_TMP1}" ]; then
- rm -f "${ARCHIVE_TMP1}"
+ if [ -f "${BUILD_MAKE_ARCHIVE_TMP1}" ]; then
+ rm -f "${BUILD_MAKE_ARCHIVE_TMP1}"
fi
- if [ -f "${ARCHIVE_TMP2}" ]; then
- rm -f "${ARCHIVE_TMP2}"
+ if [ -f "${BUILD_MAKE_ARCHIVE_TMP2}" ]; then
+ rm -f "${BUILD_MAKE_ARCHIVE_TMP2}"
fi
exit 0
}
-trap exit_cleanup EXIT
-echo "archiving: ${1}"
-load_rules "${1}"
-mkenv "archive"
-PKG_LOGFILE="${L}/archive.log"
+build_make_archive()
+{
+ trap build_make_archive_cleanup EXIT
-ARCHIVE_TMP1="$(mktemp "${BUILDER_TMPDIR}/${NAME}-${VERSION}-${RELEASE}.XXXXXXXX")"
-ARCHIVE_TMP2="$(mktemp "${BUILDER_TMPDIR}/${NAME}-${VERSION}-${RELEASE}.XXXXXXXX")"
+ echo "archiving: ${1}"
+ load_rules "${1}"
+ mkenv "archive"
+ PKG_LOGFILE="${L}/archive.log"
-[ -f "${ARCHIVE_TMP1}" ] || die "failed to create temporary archive for package '${NAME}'"
-[ -f "${ARCHIVE_TMP2}" ] || die "failed to create temporary archive for package '${NAME}'"
+ BUILD_MAKE_ARCHIVE_TMP1="$(mktemp "${BUILDER_TMPDIR}/${NAME}-${VERSION}-${RELEASE}.XXXXXXXX")"
+ [ -f "${BUILD_MAKE_ARCHIVE_TMP1}" ] || die "failed to create temporary archive for package '${NAME}'"
-case "${ARCHIVE_FORMAT}" in
-(tbz2|tar.bz2) ARCHIVE_COMPRESSOR="bzip2 -cv";;
-(tgz|tar.gz) ARCHIVE_COMPRESSOR="gzip -cv";;
-(*) die "unsupported archive format '${ARCHIVE_FORMAT}'";;
-esac
+ BUILD_MAKE_ARCHIVE_TMP2="$(mktemp "${BUILDER_TMPDIR}/${NAME}-${VERSION}-${RELEASE}.XXXXXXXX")"
+ [ -f "${BUILD_MAKE_ARCHIVE_TMP2}" ] || die "failed to create temporary archive for package '${NAME}'"
-if [ ! -d "${BUILDER_ATFDIR}/${CATEGORY}" ]; then
- mkdir -p "${BUILDER_ATFDIR}/${CATEGORY}"
-fi
+ case "${ARCHIVE_FORMAT}" in
+ (tbz2|tar.bz2) ARCHIVE_COMPRESSOR="bzip2 -cv";;
+ (tgz|tar.gz) ARCHIVE_COMPRESSOR="gzip -cv";;
+ (*) die "unsupported archive format '${ARCHIVE_FORMAT}'";;
+ esac
-cd "${D}"
-tar -cvf "${ARCHIVE_TMP1}" . > "${PKG_LOGFILE}" 2>&1
-${ARCHIVE_COMPRESSOR} "${ARCHIVE_TMP1}" > "${ARCHIVE_TMP2}" 2>> "${PKG_LOGFILE}"
-if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then
- rm -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}"
+ if [ ! -d "${BUILDER_ATFDIR}/${CATEGORY}" ]; then
+ mkdir -p "${BUILDER_ATFDIR}/${CATEGORY}"
+ fi
+
+ cd "${D}"
+ tar -cvf "${BUILD_MAKE_ARCHIVE_TMP1}" . > "${PKG_LOGFILE}" 2>&1
+ ${ARCHIVE_COMPRESSOR} "${BUILD_MAKE_ARCHIVE_TMP1}" > "${BUILD_MAKE_ARCHIVE_TMP2}" 2>> "${PKG_LOGFILE}"
+ if [ -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" ]; then
+ rm -f "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}"
+ fi
+ mv -v "${BUILD_MAKE_ARCHIVE_TMP2}" "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" >> "${PKG_LOGFILE}" 2>&1
+ cd "${W}"
+ find "${D}" -delete &
+
+ ##
+ # Technically everything should be done but we did throw a number of
+ # things into the background during execution, so go ahead and wait to
+ # see if anything
+ # is stil going.
+ wait
+}
+
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'package' '[all|[<category>/]<package|all>]' "$@"
+ build_make_archive "${@}"
fi
-mv -v "${ARCHIVE_TMP2}" "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" >> "${PKG_LOGFILE}" 2>&1
-cd "${W}"
-find "${D}" -delete &
-
-##
-# Technically everything should be done but we did throw a number of things
-# into the background during execution, so go ahead and wait to see if anything
-# is stil going.
-wait
+
# vim: filetype=sh
diff --git a/libexec/build-make-prep b/libexec/build-make-prep
index df4bbe1..f87afaf 100755
--- a/libexec/build-make-prep
+++ b/libexec/build-make-prep
@@ -1,8 +1,6 @@
#!/usr/bin/env build
-ARCHIVE_TMP1=
-ARCHIVE_TMP2=
-exit_cleanup()
+build_make_prep_cleanup()
{
ret=$?
@@ -11,85 +9,88 @@ exit_cleanup()
echo "logfile: '${PKG_LOGFILE}'" >&2
exit ${ret}
fi
- if [ -f "${ARCHIVE_TMP1}" ]; then
- rm -f "${ARCHIVE_TMP1}"
- fi
- if [ -f "${ARCHIVE_TMP2}" ]; then
- rm -f "${ARCHIVE_TMP2}"
- fi
exit 0
}
-trap exit_cleanup EXIT
-
-build_prep() { return; }
-pkg_prep() { build_prep; }
-load_rules "${1}"
+build_make_prep()
+{
+ trap build_prep_cleanup EXIT
-## Cleanup the build build environment
-for dir in "${S}" "${D}"; do
- if [ ! -d "${dir}" ]; then
- continue
- fi
- mv "${dir}" "${dir}.old"
- find "${dir}.old" -delete &
-done
-unset dir
+ build_prep() { return; }
+ pkg_prep() { build_prep; }
-mkenv "prep"
-PKG_LOGFILE="${L}/prep.log"
+ load_rules "${1}"
-SOURCE_DIR="${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source"
-if [ -d "${SOURCE_DIR}" -o -L "${SOURCE_DIR}" ]; then
- echo "prepping ${1} from source: '${SOURCE_DIR}"
- if [ "$(command -v rsync)" ]; then
- if ! rsync -rav --delete "${SOURCE_DIR}/" "${S}"; then
- die "failed to sync source to '${S}'"
+ # Cleanup the build build environment
+ for dir in "${S}" "${D}"; do
+ if [ ! -d "${dir}" ]; then
+ continue
fi
- else
- if ! cp -vadpR "${SOURCE_DIR}" "${S}"; then
- die "failed to copy source to '${S}'"
- fi
- fi >> "${PKG_LOGFILE}" 2>&1
-else
- # FIXME this stuff needs a lot of work
- for url in ${SOURCE_URI}; do
- file="$(build-url --archive "${url}")"
- if [ ! -f "${BUILDER_SRCDIR}/${file}" ]; then
- die "source does not exist '${file}'"
- fi
- echo "prepping ${1} from source: '${BUILDER_SRCDIR}/${file}"
-
- case "${file}" in
- (*.tar.Z|*.tar.z|*.tz)
- tar xZf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.tar.gz|*.tgz)
- tar xzf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.tar.bz2|*.tbz2)
- tar xjf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.tar.xz|*.txz)
- tar xJf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.tar.*)
- tar xaf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.zip)
- unzip "${BUILDER_SRCDIR}/${file}" -d "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.jar)
- cp "${BUILDER_SRCDIR}/${file}" "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- esac
+ mv "${dir}" "${dir}.old"
+ find "${dir}.old" -delete &
done
-fi
+ unset dir
-cd "${W}"
-pkg_prep >> "${PKG_LOGFILE}" 2>&1
+ mkenv "prep"
+ PKG_LOGFILE="${L}/prep.log"
-# FIXME wrap up the patch command with something more functional
-if [ ! -z "${PATCHES}" ]; then
- for patch in ${PATCHES}; do
- echo "${NAME}: applying patch '${patch}'" | tee -a "${PKG_LOGFILE}"
- if ! patch -l -t -d "${S}" -p1 < "${F}/${NAME}-${VERSION}-${patch}.patch"; then
- exit 1
+ SOURCE_DIR="${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source"
+ if [ -d "${SOURCE_DIR}" -o -L "${SOURCE_DIR}" ]; then
+ echo "prepping ${1} from source: '${SOURCE_DIR}"
+ if [ "$(command -v rsync)" ]; then
+ if ! rsync -rav --delete "${SOURCE_DIR}/" "${S}"; then
+ die "failed to sync source to '${S}'"
+ fi
+ else
+ if ! cp -vadpR "${SOURCE_DIR}" "${S}"; then
+ die "failed to copy source to '${S}'"
+ fi
fi >> "${PKG_LOGFILE}" 2>&1
- done
+ else
+ # FIXME this stuff needs a lot of work
+ for url in ${SOURCE_URI}; do
+ file="$(build-url --archive "${url}")"
+ if [ ! -f "${BUILDER_SRCDIR}/${file}" ]; then
+ die "source does not exist '${file}'"
+ fi
+ echo "prepping ${1} from source: '${BUILDER_SRCDIR}/${file}"
+
+ case "${file}" in
+ (*.tar.Z|*.tar.z|*.tz)
+ tar xZf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
+ (*.tar.gz|*.tgz)
+ tar xzf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
+ (*.tar.bz2|*.tbz2)
+ tar xjf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
+ (*.tar.xz|*.txz)
+ tar xJf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
+ (*.tar.*)
+ tar xaf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
+ (*.zip)
+ unzip "${BUILDER_SRCDIR}/${file}" -d "${W}" >> "${PKG_LOGFILE}" 2>&1;;
+ (*.jar)
+ cp "${BUILDER_SRCDIR}/${file}" "${W}" >> "${PKG_LOGFILE}" 2>&1;;
+ esac
+ done
+ fi
+
+ cd "${W}"
+ pkg_prep >> "${PKG_LOGFILE}" 2>&1
+
+ # FIXME wrap up the patch command with something more functional
+ if [ ! -z "${PATCHES}" ]; then
+ for patch in ${PATCHES}; do
+ echo "${NAME}: applying patch '${patch}'" | tee -a "${PKG_LOGFILE}"
+ if ! patch -l -t -d "${S}" -p1 < "${F}/${NAME}-${VERSION}-${patch}.patch"; then
+ exit 1
+ fi >> "${PKG_LOGFILE}" 2>&1
+ done
+ fi
+}
+
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'prep' '[all|[<category>/]<package|all>]' "$@"
+ build_make_prep "${@}"
fi
# vim: filetype=sh
diff --git a/libexec/build-make-source b/libexec/build-make-source
index a03c658..92b67af 100755
--- a/libexec/build-make-source
+++ b/libexec/build-make-source
@@ -1,15 +1,6 @@
#!/usr/bin/env build
-echo "building source: ${1}"
-
-pkg_prep()
-{
- return
-}
-
-load_rules "${1}"
-
-build_source_clean()
+build_make_source_cleanup()
{
for arg in ${BUILD_SOURCE_CLEAN}; do
if [ -d "${arg}" ]; then
@@ -20,126 +11,26 @@ build_source_clean()
done
}
-build_source_uri()
-{
- printf '%s' "${1%%\?*}"
-}
-
-build_source_args()
-{
- set -- $(echo "${1##$(build_source_uri "${1}")\?}"|sed -e 's/&/ /')
- printf '%s' "${*}"
-}
-
-
-build_source()
-{
- file="$(build-url --archive "${1}")"
- if [ ! -f "${BUILDER_SRCDIR}/${file}" ]; then
- die "source does not exist '${file}'"
- fi
-
- case "${file}" in
- (*.tar.Z|*.tar.z|*.tz)
- tar xZvf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.tar.gz|*.tgz)
- tar xzvf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.tar.bz2|*.tbz2)
- tar xjvf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.tar.xz|*.txz)
- tar xJvf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.tar.*)
- tar xavf "${BUILDER_SRCDIR}/${file}" -C "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.zip)
- unzip "${BUILDER_SRCDIR}/${file}" -d "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- (*.jar)
- cp "${BUILDER_SRCDIR}/${file}" "${W}" >> "${PKG_LOGFILE}" 2>&1;;
- esac
-}
-
-build_source_git()
+build_make_source()
{
- build_source_git_uri="$(build_source_uri "${1}")"
- build_source_git_uri="${build_source_git_uri#git://}"
- build_source_git_uri="${build_source_git_uri%%\?*}"
- build_source_git_tag=
- for arg in $(build_source_args "${1}"); do
- case "${arg}" in
- (archive=*);; # Ignore the archive directive
- (*) build_source_git_tag="${arg}";;
- esac
- done
+ trap build_make_source_cleanup 0
+ echo "building source: ${1}"
- build_source_git_tmp="$(mktemp -d "${BUILDER_TMPDIR}/builder_git.XXXXXX")"
- BUILD_SOURCE_CLEAN="${BUILD_SOURCE_CLEAN} ${build_source_git_tmp}"
- trap build_source_clean EXIT
-
- case "${build_source_git_uri}" in
- (*:[0-9]*) build_source_git_uri="git://${build_source_git_uri}";;
- (*:*);; # Git over ssh?
- (*) build_source_git_uri="git://${build_source_git_uri}";;
- esac
- if ! git clone "${build_source_git_uri}" "${build_source_git_tmp}"; then
- die "failed to clone git source at '${build_source_git_uri}'"
- fi
- if [ "${build_source_git_tag}" != "${build_source_git_uri}" ]; then
- if ! cd "${build_source_git_tmp}"; then
- die "failed to change working directory to '${build_source_git_tmp}'"
- fi
+ load_rules "${1}"
- if [ ! -z "${build_source_git_tag}" ]; then
- if ! git checkout "${build_source_git_tag}"; then
- die "failed to checkout git branch/tag '${build_source_git_tag}'"
- fi
- fi
+ if [ -d "${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source" ]; then
+ die "source already exists for '${CATEGORY}/${NAME}'"
fi
- mv "${build_source_git_tmp}" "${S}"
+ mkenv "source"
+ PKG_LOGFILE="${L}/source.log"
- unset build_source_git_tmp
- unset build_source_git_uri
- unset build_source_git_tag
+ mv "${S}" "${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source" >> "${PKG_LOGFILE}" 2>&1
}
-## Cleanup the build build environment
-for dir in "${S}" "${D}"; do
- if [ ! -d "${dir}" ]; then
- continue
- fi
- mv "${dir}" "${dir}.old"
- find "${dir}.old" -delete &
-done
-unset dir
-
-mkenv "prep"
-PKG_LOGFILE="${L}/source.log"
-
-if [ -d "${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source" ]; then
- die "source already exists for '${CATEGORY}/${NAME}'"
-fi
-
-# FIXME this stuff needs a lot of work
-for url in ${SOURCE_URI}; do
- case "${url}" in
- (git://*) build_source_git "${url}";;
- (*) build_source "${url}";;
- esac
-done
-
-cd "${W}" && pkg_prep >> "${PKG_LOGFILE}" 2>&1
-
-# FIXME wrap up the patch command with something more functional
-if [ ! -z "${PATCHES}" ]; then
- for patch in ${PATCHES}; do
- echo "${NAME}: applying patch '${patch}'" | tee -a "${PKG_LOGFILE}"
- if ! patch -l -t -d "${S}" -p1 < "${F}/${NAME}-${VERSION}-${patch}.patch"; then
- exit 1
- fi >> "${PKG_LOGFILE}" 2>&1
- done
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'source' '[all|[<category>/]<package|all>]' "$@"
+ build_make_source "${@}"
fi
-mv "${S}" "${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source" >> "${PKG_LOGFILE}" 2>&1
-
-wait
-
# vim: filetype=sh
diff --git a/libexec/build-make-test b/libexec/build-make-test
index 272a808..60c9485 100755
--- a/libexec/build-make-test
+++ b/libexec/build-make-test
@@ -1,6 +1,6 @@
#!/usr/bin/env build
-exit_cleanup()
+build_test_exit_cleanup()
{
ret=$?
@@ -11,16 +11,24 @@ exit_cleanup()
fi
exit 0
}
-trap exit_cleanup EXIT
pkg_test() { echo "test: no test defined"; }
-echo "testing: ${1}"
-load_rules "${1}"
-mkenv "test"
-PKG_LOGFILE="${L}/test"
+build_make_test()
+{
+ trap exit_cleanup EXIT
+ echo "testing: ${1}"
+ load_rules "${1}"
+ mkenv "test"
+ PKG_LOGFILE="${L}/test"
+
+ cd "${W}"
+ pkg_test >> "${PKG_LOGFILE}" 2>&1
+}
-cd "${W}"
-pkg_test >> "${PKG_LOGFILE}" 2>&1
+if test "${BUILDER_CALL_STACK}" = '__main__'; then
+ simple_usage 'test' '[all|[<category>/]<package|all>]' "$@"
+ build_make_test "${@}"
+fi
# vim: filetype=sh
diff --git a/libexec/build-makedeps b/libexec/build-makedeps
index ac29d1c..d442bfd 100755
--- a/libexec/build-makedeps
+++ b/libexec/build-makedeps
@@ -48,6 +48,7 @@ for package in $(echo "${BUILDER_PKGDIR}"/*/*); do
fi
package_make="$(echo "${package}"|tr '/-' '__')"
+ package_source="${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source"
package_prep="${W}/.prepped"
package_compile="${W}/.compiled"
package_archive="${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}"
@@ -117,8 +118,6 @@ cat <<EOF
${package_make}: ${package_archive}
${package_make}_makedeps:
${package_make}_fetch: ${package_sources}
-${package_make}_source: ${package_sources}
- @build-make-source "${CATEGORY}/${NAME}"
${package_make}_clean:
@build-make-clean "${CATEGORY}/${NAME}"
${package_make}_distclean:
@@ -137,6 +136,9 @@ ${package_archive}: ${package_compile}
${package_make}_install: ${package_install}
${package_install}: ${package_archive} ${package_rdeps}
@build-make-install "${CATEGORY}/${NAME}"
+${package_make}_source: ${package_source}
+${package_source}: ${package_prep}
+ @build-make-source "${CATEGORY}/${NAME}"
${package_make}_test: ${package_test}
${package_test}: ${package_tdeps} ${package_install}
@build-make-test "${CATEGORY}/${NAME}"
diff --git a/libexec/build-query b/libexec/build-query
index d500840..5e5b4f7 100755
--- a/libexec/build-query
+++ b/libexec/build-query
@@ -1,6 +1,6 @@
#!/usr/bin/env build
-usage()
+build_query_usage()
{
cat<<END_OF_HELP
usage: build-query [options] <arg>
@@ -115,7 +115,7 @@ recurse_rdeps()
# Look for cries for --help in the cmdline
for arg; do
case "${arg}" in
- (-h|-help|--help) usage; exit 0;;
+ (-h|-help|--help) build_query_usage; exit 0;;
esac
done