summaryrefslogtreecommitdiffhomepage
path: root/build.sh
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-02-12 12:43:29 +0100
committerLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-02-12 16:10:21 +0100
commit1d0876af1f6b526a930d39d9b6a3e053d218e981 (patch)
treec732473dd87dfcb5ec93f3a4354d528cdabe4bec /build.sh
parentf16d357f6f9528a4fac2e14f7b882f5a455faea2 (diff)
downloadmidipix_build-1d0876af1f6b526a930d39d9b6a3e053d218e981.tar.bz2
midipix_build-1d0876af1f6b526a930d39d9b6a3e053d218e981.tar.xz
- Major cleanup in general.
- Added --{build-{scripts,steps},help,tarball}. Variables can now be overriden on the command-line. - Integrated bzip2, dash, less, ncurses, popt, rsync, tar, util-linux, which, and xz; as there are no patches in portage/ for util-linux just yet, this presently requires integrated local patches. Git is included in build.vars only as it requires OpenSSL. - Include ntapi.local.patch and psxscl.local.patch in the repository.
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh85
1 files changed, 47 insertions, 38 deletions
diff --git a/build.sh b/build.sh
index eb219701..4f0dbfc6 100755
--- a/build.sh
+++ b/build.sh
@@ -1,73 +1,82 @@
#!/bin/sh
-
+#
{
-#clear_env_with_except HOME PATH SHELL TERM USER;
-unset AR ARFLAGS CC CFLAGS CXX CXXFLAGS LD LDFLAGS;
-. ./build.vars; . ./build.subr;
+. ./build.subr;
+parse_args_into_vars "${0}" build-scripts,build-steps,help,tarball "${@}";
+[ -n "${ARG_HELP}" ] && { exec cat build.usage; } || . ./build.vars;
+clear_env_with_except HOME PATH SHELL TERM USER;
check_path_vars PREFIX PREFIX_NATIVE WORKDIR;
-check_prereqs git make openssl sed sort tar tr wget;
-set_env_vars "" LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS \
-LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL;
+check_prereqs git make mktemp openssl sed sort tar tr wget;
log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE:=$(date %Y-%m-%d-%H-%M-%S)}.";
-#trap
-(set -o errexit; mkdir -p ${PREFIX} ${WORKDIR});
+log_env_vars ${LOG_ENV_VARS};
+(mkdir -p ${PREFIX} ${PREFIX_NATIVE} ${PREFIX_TARGET} ${WORKDIR};
BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}};
for BUILD_LVL in 0 1 2 3; do
for BUILD_SCRIPT_FNAME in ${BUILD_LVL}[0-9][0-9].*.build; do
- if [ -n "${DEBUG_SCRIPT}" ]\
- && [ "x${DEBUG_SCRIPT}" != "x${BUILD_SCRIPT_FNAME}" ]; then
+ if [ -n "${ARG_BUILD_SCRIPTS}" ]\
+ && [ "${ARG_BUILD_SCRIPTS}" != "ALL" ]\
+ && ! match_list "${ARG_BUILD_SCRIPTS}" \
+ , "${BUILD_SCRIPT_FNAME}"; then
+ log_msg info "Skipped build script \`${BUILD_SCRIPT_FNAME}' (--build-scripts policy.)";
continue;
elif [ ! -f ${BUILD_SCRIPT_FNAME} ]; then
+ log_msg info "Build script \`${BUILD_SCRIPT_FNAME}' non-existent or not a file.";
continue;
else
unset BUILD_SCRIPT_RC; : $((BUILD_NBUILT+=1));
- log_msg info "Invoking build script \`${BUILD_SCRIPT_FNAME}'";
- (set -o errexit -- $(split . ${BUILD_SCRIPT_FNAME%.build}); \
- SCRIPT_FNAME=${BUILD_SCRIPT_FNAME}; _pwd=$(pwd); \
+ if [ "x${ARG_BUILD_SCRIPTS}" != "xALL" ]\
+ && is_build_script_done finish "${BUILD_SCRIPT_FNAME%.build}"; then
+ log_msg info "Skipped build script \`${BUILD_SCRIPT_FNAME}' (already built.)";
+ : $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue;
+ fi;
+ log_msg info "Invoking build script${ARG_BUILD_SCRIPTS:+ (forcibly)} \`${BUILD_SCRIPT_FNAME}'${ARG_BUILD_STEPS:+ at build step(s) ${ARG_BUILD_STEPS}}.";
+ (set -o errexit -- $(split . ${BUILD_SCRIPT_FNAME%%.build*}); \
+ SCRIPT_FNAME=${BUILD_SCRIPT_FNAME}; \
+ SCRIPT_NAME=${SCRIPT_FNAME%%.build*}; \
export CFLAGS="$(eval echo \${CFLAGS_LVL${BUILD_LVL}})"; \
export PREFIX_LVL="$(eval echo \${PREFIX_LVL${BUILD_LVL}})"; \
- cd ${WORKDIR}; . ${_pwd}/build.subr; \
- [ -f ${_pwd}/${SCRIPT_FNAME%.build}.vars ] && \
- . ${_pwd}/${SCRIPT_FNAME%.build}.vars; \
- . ${_pwd}/${BUILD_SCRIPT_FNAME});
+ _PWD=$(pwd); cd ${WORKDIR}; \
+ for SCRIPT_SOURCE in build.subr ${SCRIPT_NAME}.vars \
+ ${BUILD_SCRIPT_FNAME}; do \
+ [ -r ${_PWD}/${SCRIPT_SOURCE} ] && \
+ . ${_PWD}/${SCRIPT_SOURCE}; \
+ done);
case ${BUILD_SCRIPT_RC:=${?}} in
0) log_msg succ "Finished build script \`${BUILD_SCRIPT_FNAME}'.";
: $((BUILD_NFINI+=1)); continue; ;;
- 212) log_msg info "Skipped build script \`${BUILD_SCRIPT_FNAME}' (already built.)";
- : $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue; ;;
*) log_msg fail "Build failed in build script \`${BUILD_SCRIPT_FNAME}' (last return code ${BUILD_SCRIPT_RC}.).";
: $((BUILD_NFAIL+=1)); break; ;;
esac;
fi;
done;
- if [ ${BUILD_SCRIPT_RC:-0} != 0 ]; then
+ if [ ${BUILD_SCRIPT_RC:-0} -ne 0 ]; then
break;
fi;
done;
log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s).";
if [ $(( ${BUILD_NFINI} + ${BUILD_NSKIP} )) -ge 0 ]\
-&& [ ${BUILD_NFAIL} -eq 0 ]; then
+&& [ ${BUILD_NFAIL} -eq 0 ]\
+&& [ ${ARG_TARBALL:-0} -eq 1 ]; then
log_msg info "Building distribution tarball.";
(cd ${PREFIX};
DISTRIB_FNAME=midipix.${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE}.tar.bz2;
- rm_if_exists -m ${PREFIX_NATIVE##*/}/lib.bak; rm_if_exists ${DISTRIB_FNAME};
- tar -C ${PREFIX_NATIVE##*/}/lib -cpf - . |\
- tar -C ${PREFIX_NATIVE##*/}/lib.bak -xpf -;
+ PREFIX_BASENAME=${PREFIX_NATIVE##*/}; WORKDIR_BASENAME=${WORKDIR##*/};
+ rm_if_exists -m ${PREFIX_BASENAME}/lib.bak; rm_if_exists ${DISTRIB_FNAME};
+ tar -C ${PREFIX_BASENAME}/lib -cpf - . | tar -C ${PREFIX_BASENAME}/lib.bak -xpf -;
(cd native/lib &&
find . -maxdepth 1 -type l \
- -exec sh -c 'dest=$(readlink -- "$0") && rm -- "$0" && ln -- "$dest" "$0"' {} \;);
- wait;
- find . -maxdepth 2 -type d \
- -not -path . \
- -not -path ./${WORKDIR##*/} \
- -not -path ./${WORKDIR##*/}/\* \
- -not -path ./${PREFIX_NATIVE##*/} \
- -not -path ./${PREFIX_NATIVE##*/}/lib.bak |\
- tar -T - -cpf - | bzip2 -9c - > ${DISTRIB_FNAME}
- rm -rf ${PREFIX_NATIVE##*/}/lib;
- mv ${PREFIX_NATIVE##*/}/lib.bak ${PREFIX_NATIVE##*/}/lib); wait;
+ -exec sh -c 'dest=$(readlink -- "$0") && rm -- "$0" && ln -- "$dest" "$0"' {} \;);
+ wait;
+ find . -maxdepth 2 -type d \
+ -not -path . \
+ -not -path ./${WORKDIR_BASENAME} \
+ -not -path ./${WORKDIR_BASENAME}/\* \
+ -not -path ./${PREFIX_BASENAME} \
+ -not -path ./${PREFIX_BASENAME}/lib.bak |\
+ tar -T - -cpf - | bzip2 -9c - > ${DISTRIB_FNAME}
+ rm -rf ${PREFIX_BASENAME}/lib;
+ mv ${PREFIX_BASENAME}/lib.bak ${PREFIX_BASENAME}/lib); wait;
fi;
-exit ${BUILD_SCRIPT_RC};
-} 2>&1 | tee build.log;
+exit ${BUILD_SCRIPT_RC})} 2>&1 | tee build.log;
# vim:filetype=sh