summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-02-27 17:33:19 +0000
committerLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-02-27 17:33:19 +0000
commitb947460aacf5861255b5d7f1e521b0daf30b3b11 (patch)
tree74a36d8d05352fbe9f80e68d401a6f49d93bf99d
parent0724e525c8f3144b7fc689e5762ee04202dbd715 (diff)
downloadmidipix_build-b947460aacf5861255b5d7f1e521b0daf30b3b11.tar.bz2
midipix_build-b947460aacf5861255b5d7f1e521b0daf30b3b11.tar.xz
Adds -x (xtrace) and -X (xtrace and create debug tarball.)
-rwxr-xr-xbuild.sh31
-rw-r--r--build.subr8
-rw-r--r--build.usage25
-rw-r--r--build.vars3
4 files changed, 50 insertions, 17 deletions
diff --git a/build.sh b/build.sh
index 9cc4aafe..0f8af1d6 100755
--- a/build.sh
+++ b/build.sh
@@ -14,17 +14,20 @@ case ${1} in
|| { ARG_RESTART_SCRIPT="${2}"; ARG_RESTART_SCRIPT_AT=ALL; };
shift; ;;
-t) [ ${ARG_TARBALL:-0} -eq 1 ] && exec cat build.usage || ARG_TARBALL=1; ;;
+-x) set -o xtrace; ;;
+-X) set -o xtrace; ARG_DEBUG_TARBALL=1; ;;
*=*) set_var_unsafe "$(get_prefix_lrg "${1}" =)" \
"$(get_postfix "${1}" =)"; ;;
*) exec cat build.usage; ;;
esac; shift; done;
-{
. ./build.vars;
-clear_env_with_except HOME PATH SHELL TERM USER;
-check_path_vars PREFIX PREFIX_NATIVE WORKDIR;
-check_prereqs git make mktemp openssl patch sed sort tar tr wget;
-(mkdir -p ${PREFIX} ${PREFIX_NATIVE} ${PREFIX_TARGET} ${WORKDIR};
+clear_env_with_except ${CLEAR_ENV_VARS_EXCEPT};
+check_path_vars ${CHECK_PATH_VARS}; check_prereqs ${PREREQ_CMDS};
+mkdir -p ${PREFIX} ${PREFIX_NATIVE} ${PREFIX_TARGET} ${WORKDIR};
+trap clean_build_status HUP INT TERM USR1 USR2;
+
+{(
update_build_status build_start; build_times_init;
log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}.";
log_env_vars ${LOG_ENV_VARS}; [ ${ARG_CLEAN:-0} -eq 1 ] && clean_prefix;
@@ -63,6 +66,22 @@ for BUILD_LVL in 0 1 2 3; do
0) log_msg succ "Finished build script \`${BUILD_SCRIPT_FNAME}'.";
: $((BUILD_NFINI+=1)); continue; ;;
*) log_msg fail "Build failed in build script \`${BUILD_SCRIPT_FNAME}' (last return code ${BUILD_SCRIPT_RC}.).";
+ if [ ${ARG_DEBUG_TARBALL:-0} -eq 1 ]; then
+ log_msg info "-X specified, creating debug tarball.";
+ SCRIPT_NAME=${BUILD_SCRIPT_FNAME%%.build};
+ SCRIPT_NAME=${SCRIPT_NAME#*.};
+ SCRIPT_NAME=$(echo "${SCRIPT_NAME}" | tr a-z A-Z);
+ if [ -z ${PKG_SUBDIR=$(get_var_unsafe PKG_${SCRIPT_NAME}_SUBDIR)} ]; then
+ PKG_URL=$(get_var_unsafe PKG_${SCRIPT_NAME}_URL);
+ PKG_FNAME=${PKG_URL##*/};
+ PKG_SUBDIR=${PKG_FNAME%%.tar*};
+ fi;
+ BUILD_DEBUG_TARBALL_FNAME=${PREFIX}/midipix-debug-${BUILD_USER}@${BUILD_HNAME}_$(date %Y-%m-%d-%H-%M-%S);
+ tar -C ${PREFIX} -cpf - build.log ${WORKDIR#${PREFIX}/}/${PKG_SUBDIR} |\
+ bzip2 -c - > ${BUILD_DEBUG_TARBALL_FNAME};
+ log_msg info "Please upload ${BUILD_DEBUG_TARBALL_FNAME} and provide an URL to it in <irc://irc.freenode.net/midipix>.";
+ exit 1;
+ fi;
: $((BUILD_NFAIL+=1)); break; ;;
esac;
fi;
@@ -96,6 +115,6 @@ if [ $(( ${BUILD_NFINI} + ${BUILD_NSKIP} )) -ge 0 ] \
update_build_status tarball_finish;
fi;
update_build_status finish;
-exit ${BUILD_SCRIPT_RC})} 2>&1 | tee build.log;
+exit ${BUILD_SCRIPT_RC})} 2>&1 | tee ${PREFIX}/build.log;
# vim:filetype=sh
diff --git a/build.subr b/build.subr
index b696a285..46fc61bd 100644
--- a/build.subr
+++ b/build.subr
@@ -39,6 +39,14 @@ clean_prefix() {
find ${PREFIX}/tmp -mindepth 1 -maxdepth 1 -type f -iname .\* -exec rm -rf {} \;
};
+clean_build_status() {
+ set -- BUILD_STATUS_IN_PROGRESS_FNAME BUILD_STATUS_PROGRESS_FNAME BUILD_STATUS_TARBALL_PROGRESS_FNAME;
+ while [ ${#} -gt 0 ]; do
+ unset ${1}; shift;
+ done; touch ${PREFIX}/BUILD_ABORTED_AT_$(date %Y-%m-%d-%H-%M-%S);
+ log_msg fail "Build aborted at $(date %Y-%m-%d-%H-%M-%S).";
+};
+
export_vars_subst() {
_evs_pfx=${1}; _evs_pfx_new=${2}; shift 2;
while [ ${#} -gt 0 ]; do
diff --git a/build.usage b/build.usage
index c43a5e15..ea24535e 100644
--- a/build.usage
+++ b/build.usage
@@ -1,15 +1,18 @@
usage: ./build.sh [-c] [-nd] [-r ALL|name[:step]] [-h] [-t]
- -c Clean $PREFIX before processing build scripts.
- -nd Don't rm(1) and re-download tarballs when not required.
- -r ALL|name[:step] Restart all or the specified build script(s) completely
- or at the optionally specified build step. Currently defined
- build steps are: fetch extract patch configure clean build
- install configure1 configure2 build1 build2 install1 install2
- install3.
- -h Show this screen.
- -t Produce a distribution tarball containing $PREFIX
- sans $WORKDIR and $PREFIX/src/midipix_build at the end of a
- build with zero failures.
+ -c Clean $PREFIX before processing build scripts.
+ -nd Don't rm(1) and re-download tarballs when not required.
+ -r ALL|name[:step] Restart all or the specified build script(s) completely
+ or at the optionally specified build step. Currently defined
+ build steps are: fetch extract patch configure clean build
+ install configure1 configure2 build1 build2 install1 install2.
+ -h Show this screen.
+ -t Produce a distribution tarball containing $PREFIX
+ sans $WORKDIR and $PREFIX/src/midipix_build at the end of a
+ build with zero failures.
+ -x Set the xtrace sh(1)ell option for debugging purposes.
+ -X Set the xtrace sh(1)ell option and compile a tarball containing
+ build.log and $PKG_SUBDIR. Use this option if something goes
+ wrong and provide an URL to the tarball in <irc://irc.freenode.net/midipix>.
Packages that are built by pkg.build will apply local patches in $WORKDIR
named ${PKG_SUBDIR}.local.patch.
diff --git a/build.vars b/build.vars
index d60829a0..72be013f 100644
--- a/build.vars
+++ b/build.vars
@@ -14,6 +14,9 @@
: ${BUILD_STATUS_FINISHED_AT_CURRENT_FNAME:=${PREFIX}/BUILD_FINISHED_AT};
: ${BUILD_STATUS_IN_PROGRESS_FNAME:=${PREFIX}/BUILD_IN_PROGRESS};
: ${CFLAGS_DEFAULT:=-g3 -O0};
+: ${CHECK_PREREQ_CMDS:="flex git make mktemp openssl patch sed sort tar tee tr wget"};
+: ${CHECK_PATH_VARS:="PREFIX PREFIX_NATIVE WORKDIR"};
+: ${CLEAR_ENV_VARS_EXCEPT:="HOME PATH SHELL TERM USER"};
: ${GITROOT:=git://midipix.org};
: ${GITROOT_HEAD:=git://midipix.org};
: ${HOST_NATIVE:=x86_64-nt64-midipix};