#!/usr/bin/env build # FIXME find this dynamically WIDTH="${WIDTH:-80}" build_usage() { printf 'usage: build [options] [command-opts] [all|/ ...]\n\n'; } build_commands() { BUILDER_COMMANDS= BUILDER_CMD_WIDTH='0' build_usage echo "available builder commands from '${BUILDER_LIBDIR}':" for cmd in $(cd "${BUILDER_LIBDIR}" && echo build-*); do test -e "${BUILDER_LIBDIR}/${cmd}" || continue cmd="${cmd#build-}" BUILDER_COMMANDS="${BUILDER_COMMANDS} ${cmd#make-}" length="$(echo "${cmd#build-}"|wc -c)" if test "${length}" -gt "${BUILDER_CMD_WIDTH}"; then BUILDER_CMD_WIDTH="${length}" fi done BUILDER_COMMANDS="$(for cmd in ${BUILDER_COMMANDS}; do echo "${cmd}"; done|sort|uniq)" length='0' for cmd in ${BUILDER_COMMANDS}; do printf " %-${BUILDER_CMD_WIDTH}s" "${cmd}" length="$((${length} + ${BUILDER_CMD_WIDTH} + 2))" if test "${length}" -gt "${WIDTH}"; then printf '\n' length='0' fi done printf '\n' # Find commands from ${PATH} BUILDER_COMMANDS= BUILDER_CMD_LENGTH='0' IFS=':' set -- ${PATH} for dir; do test -d "${dir}" || continue for cmd in $(cd "${dir}" && echo build-*); do test -e "${dir}/${cmd}" || continue BUILDER_COMMANDS="${BUILDER_COMMANDS} ${cmd#build-}" length="$(echo "${cmd#build-}"|wc -c)" if test "${length}" -gt "${BUILDER_CMD_WIDTH}"; then length="${BUILDER_CMD_WIDTH}" fi done done unset dir BUILDER_COMMANDS="$(for cmd in ${BUILDER_COMMANDS}; do echo "${cmd}"; done|sort|uniq)" test -z "${BUILDER_COMMANDS}" && return echo "available builder commands from '${BUILDER_LIBDIR}':" length='0' for cmd in ${BUILDER_COMMANDS}; do printf " %-${BUILDER_CMD_WIDTH}s" "${cmd}" length="$((${length} + ${BUILDER_CMD_WIDTH} + 2))" if test "${length}" -gt "${WIDTH}"; then printf '\n' length='0' fi done printf '\n' } build_help() { build_usage ## usage # Simply display the builder usage. Though it would be nice if some of this # information was pushed down into the sub-commands. cat<//source. The source/ directory within a package takes precendences over the SOURCE_URI, allowing in-place development of various packages. This is particularly useful if the SOURCE_URI is an SCM. fetch Fetch the sources for a package from the SOURCE_URI and store them into the sources/ top-level directory. This is done 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 target depends on. If necessary produce binary artifacts for all package deps. clean Clean specified package from sysroot and artifacts. distclean Clean up specified package from sysroot, artifacts, and sources. export Export the binary package to an rpm. help Display this help. Try 'help --all' to list all commands'. EOF } if test "${BUILDER_CALL_STACK}" = '__main__'; then while test "$#" -gt '0'; do case "${1}" in (--all) build_commands; exit 0;; (--) shift; break;; (-*) die "unknown option '${1}'";; (*) if test -x "${BUILDER_LIBDIR}/build-make-${1}"; then exec build "make-${1}" --help fi exec build "${1}" --help;; esac done build_help fi # vim: filetype=sh