diff options
author | Mark Ferrell <major@homeonderanged.org> | 2014-04-09 10:22:22 -0700 |
---|---|---|
committer | Mark Ferrell <major@homeonderanged.org> | 2014-04-09 10:22:22 -0700 |
commit | 2fa93efb7bfad54607ce911d5f846148ac5442fc (patch) | |
tree | f2616d0af319e4e636ddb36c62cc2779bafa4411 | |
parent | b734ab196ccf534f2ab8e50f26686c3eaa3a790d (diff) |
Make the prep and compile subcommands callable from the CLI
-rwxr-xr-x | libexec/build-help | 12 | ||||
-rwxr-xr-x | libexec/build-make-compile | 95 | ||||
-rwxr-xr-x | libexec/build-make-package | 152 | ||||
-rwxr-xr-x | libexec/build-make-prep | 95 | ||||
-rwxr-xr-x | libexec/build-makedeps | 12 |
5 files changed, 212 insertions, 154 deletions
diff --git a/libexec/build-help b/libexec/build-help index 49def0c..926cd5c 100755 --- a/libexec/build-help +++ b/libexec/build-help @@ -96,9 +96,15 @@ Commands them into the sources/ top-level directory. This is done automatically for all commands which depend on it. - package Prep, compile and construct a binary "artifact" file for a - given package. This command is performed automatically for all - commands which depend on it. + prep Prepare a package for compilation. This command is performed + automatically for all commands which depend on it. + + compile Compile a package. This command is performed automatically for + all commands which depend on it. + + package Construct a binary "artifact" file from a compiled package. + This command is performed automatically for all commands which + depend on it. install Install a binary artifact into the sysroot. This action is performed automatically for any packages which the current diff --git a/libexec/build-make-compile b/libexec/build-make-compile new file mode 100755 index 0000000..605fc4c --- /dev/null +++ b/libexec/build-make-compile @@ -0,0 +1,95 @@ +#!/usr/bin/env build + +exit_cleanup() +{ + ret=$? + + if [ ${ret} -ne 0 ]; then + echo "error: compile failed for ${CATEGORY}/${NAME}" >&2 + echo "logfile: '${PKG_LOGFILE}'" >&2 + exit ${ret} + fi + exit 0 +} +trap exit_cleanup EXIT + +build_compile() +{ + if [ -f "configure" ]; then + ./configure --host="${CHOST}" \ + --prefix="/usr" --mandir=/usr/share/man \ + --docdir=/usr/share/doc \ + --sysconfdir=/etc \ + ${CONFIG_OPTS} + fi + + make ${MAKE_OPTS} + make DESTDIR="${D}" install +} +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 + done + wait +done +wait +find * -depth \( ! -type d \) -print0 > "${binpkg_list}" +mv "${binpkg_list}" "${D}/var/db/binpkgs/${CATEGORY}/${NAME}" + +# vim: filetype=sh diff --git a/libexec/build-make-package b/libexec/build-make-package index fe501c7..40b9756 100755 --- a/libexec/build-make-package +++ b/libexec/build-make-package @@ -7,7 +7,7 @@ exit_cleanup() ret=$? if [ ${ret} -ne 0 ]; then - echo "error: packaging failed for ${CATEGORY}/${NAME}" >&2 + echo "error: archiving failed for ${CATEGORY}/${NAME}" >&2 echo "logfile: '${PKG_LOGFILE}'" >&2 exit ${ret} fi @@ -21,156 +21,8 @@ exit_cleanup() } trap exit_cleanup EXIT -build_prep() { return; } -pkg_prep() { build_prep; } - -build_compile() -{ - if [ -f "configure" ]; then - ./configure --host="${CHOST}" \ - --prefix="/usr" --mandir=/usr/share/man \ - --docdir=/usr/share/doc \ - --sysconfdir=/etc \ - ${CONFIG_OPTS} - fi - - make ${MAKE_OPTS} - make DESTDIR="${D}" install -} -pkg_compile() { build_compile; } - -load_rules "${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}/prep.log" - -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 -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 - - -# 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 - done - wait -done -wait -find * -depth \( ! -type d \) -print0 > "${binpkg_list}" -mv "${binpkg_list}" "${D}/var/db/binpkgs/${CATEGORY}/${NAME}" - echo "archiving: ${1}" +load_rules "${1}" mkenv "archive" PKG_LOGFILE="${L}/archive.log" diff --git a/libexec/build-make-prep b/libexec/build-make-prep new file mode 100755 index 0000000..df4bbe1 --- /dev/null +++ b/libexec/build-make-prep @@ -0,0 +1,95 @@ +#!/usr/bin/env build + +ARCHIVE_TMP1= +ARCHIVE_TMP2= +exit_cleanup() +{ + ret=$? + + if [ ${ret} -ne 0 ]; then + echo "error: prep failed for ${CATEGORY}/${NAME}" >&2 + 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}" + +## 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}/prep.log" + +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 +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 + +# vim: filetype=sh diff --git a/libexec/build-makedeps b/libexec/build-makedeps index 7528ca6..2c9e6de 100755 --- a/libexec/build-makedeps +++ b/libexec/build-makedeps @@ -4,6 +4,8 @@ cat >"${BUILDER_MAKEFILE}" <<EOF # Some generic catchall rules all: all_all_archive all_fetch: all_all_fetch +all_prep: all_all_prep +all_compile: all_all_compile all_archive: all_all_archive all_install: all_all_install all_export: all_all_export @@ -45,6 +47,8 @@ for package in $(echo "${BUILDER_PKGDIR}"/*/*); do fi package_make="$(echo "${package}"|tr '/-' '__')" + package_prep="${W}/.prepped" + package_compile="${W}/.compiled" package_archive="${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" package_install="${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" package_export="${BUILDER_TOPDIR}/exports/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${CHOST%%-*}.rpm" @@ -115,8 +119,14 @@ ${package_make}_clean: @build-make-clean "${CATEGORY}/${NAME}" ${package_make}_distclean: @build-make-distclean "${CATEGORY}/${NAME}" +${package_make}_prep: ${package_prep} +${package_prep}: ${package_sources} ${package_bdeps} + @build-make-prep "${CATEGORY}/${NAME}" && date >> "${package_prep}" +${package_make}_compile: ${package_compile} +${package_compile}: ${package_prep} + @build-make-compile "${CATEGORY}/${NAME}" && date >> "${package_compile}" ${package_make}_package: ${package_archive} -${package_archive}: ${package_sources} ${package_bdeps} +${package_archive}: ${package_compile} @build-make-package "${CATEGORY}/${NAME}" ${package_make}_install: ${package_install} ${package_install}: ${package_archive} ${package_rdeps} |