summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-06-11 17:37:01 +0000
committerLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-06-11 17:37:01 +0000
commitafcefa6fa131bbcca37337471be260e3f9f22bae (patch)
treef844d3893f32bdc3775482fabcc58bd3ccef66d1
parent11ee19688cab2dbb01d09ce9dcb7ad0a1d16f417 (diff)
downloadmidipix_build-afcefa6fa131bbcca37337471be260e3f9f22bae.tar.bz2
midipix_build-afcefa6fa131bbcca37337471be260e3f9f22bae.tar.xz
Moved tarball creation logic into its own build script; level 9 build
scripts are only invoked when ${ARG_TARBALL} is set (-t.) Allow specification of the compression algorithm to use via -t{.bz2,gz,xz}. (via noninc)
-rwxr-xr-x999.tarballs.build63
-rwxr-xr-xbuild.sh45
-rw-r--r--build.usage8
-rw-r--r--build.vars1
4 files changed, 72 insertions, 45 deletions
diff --git a/999.tarballs.build b/999.tarballs.build
new file mode 100755
index 00000000..11b47e62
--- /dev/null
+++ b/999.tarballs.build
@@ -0,0 +1,63 @@
+#
+# . ./build.vars and set -o errexit are assumed.
+#
+
+if [ ${ARG_TARBALL:-0} -eq 0 ]; then
+ log_msg "Skipping distribution tarball creation.";
+ exit 0;
+else
+ log_msg info "Building distribution tarballs...";
+ update_build_status build_finish tarball_start;
+ cd ${PREFIX};
+ if [ "${TARBALL_SUFFIX}" = "bz2" ]; then
+ TARBALL_COMPRESS_CMD="bzip2";
+ elif [ "${TARBALL_SUFFIX}" = "gz" ]; then
+ TARBALL_COMPRESS_CMD="gzip";
+ elif [ "${TARBALL_SUFFIX}" = "xz" ]; then
+ TARBALL_COMPRESS_CMD="xz";
+ else
+ log_msg failexit "Unknown tarball suffix \`.${TARBALL_SUFFIX}'.";
+ fi;
+ TARBALL_FNAME=${TARBALL_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${TARBALL_SUFFIX};
+ TARBALL_SRC_FNAME=${TARBALL_SRC_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${TARBALL_SUFFIX};
+fi;
+
+
+PREFIX_BASENAME=${PREFIX_NATIVE##*/};
+rm_if_exists -m ${PREFIX_BASENAME}/lib.bak;
+tar -C ${PREFIX_BASENAME}/lib -cpf - . | tar -C ${PREFIX_BASENAME}/lib.bak -xpf -;
+log_msg info "Backed up ${PREFIX_BASENAME}/lib.";
+find native/lib -maxdepth 1 -type l \
+ -exec sh -c '[ -f "${DEST:=native/lib/$(readlink -- "${0}")}" ] && \
+ rm -f -- "${0}" && ln -f -- "${DEST}" "${0}"' {} \;;
+log_msg info "Converted symbolic links in ${PREFIX_BASENAME}/lib to hard links.";
+
+tar -cpf - $(find_with_no_paths "${TARBALL_EXCLUDE_PATHS} native/lib.bak" . \
+ -mindepth 1 -maxdepth 2 -type d -not -path ./native) \
+ "Create \`Midipix mintty shell' shortcut.vbs" midipix.sh |\
+${TARBALL_COMPRESS_CMD} -c > ${TARBALL_FNAME};
+log_msg info "Finished building binary distribution tarball.";
+if [ -x "$(which gpg 2>/dev/null)" -a -n "${TARBALL_SIGN_GPG_KEY}" ] &&\
+ gpg --list-keys "${TARBALL_SIGN_GPG_KEY}" >/dev/null 2>&1; then
+ gpg --armor --passphrase-file /dev/null \
+ --local-user "${TARBALL_SIGN_GPG_KEY}" --sign ${TARBALL_FNAME};
+ log_msg info "Signed binary distribution tarball.";
+fi;
+rm -rf ${PREFIX_BASENAME}/lib; mv ${PREFIX_BASENAME}/lib.bak ${PREFIX_BASENAME}/lib;
+log_msg info "Restored ${PREFIX_BASENAME}/lib.";
+
+
+log_msg info "Building source tarball...";
+tar -cpf - $(find tmp -mindepth 1 -maxdepth 1 -type d) |\
+${TARBALL_COMPRESS_CMD} -c > ${TARBALL_SRC_FNAME};
+log_msg info "Finished building source tarball.";
+if [ -x "$(which gpg 2>/dev/null)" -a -n "${TARBALL_SRC_SIGN_GPG_KEY}" ] &&\
+ gpg --list-keys "${TARBALL_SRC_SIGN_GPG_KEY}" >/dev/null 2>&1; then
+ gpg --armor --passphrase-file /dev/null \
+ --local-user "${TARBALL_SRC_SIGN_GPG_KEY}" --sign ${TARBALL_SRC_FNAME};
+ log_msg info "Signed source tarball.";
+fi;
+
+update_build_status tarball_finish;
+
+# vim:filetype=sh
diff --git a/build.sh b/build.sh
index db677fd0..f7f5a5b6 100755
--- a/build.sh
+++ b/build.sh
@@ -14,7 +14,8 @@ case ${1} in
&& { ARG_RESTART_SCRIPT="${2%%:*}"; ARG_RESTART_SCRIPT_AT="${2##*:}"; } \
|| { ARG_RESTART_SCRIPT="${2}"; ARG_RESTART_SCRIPT_AT=ALL; };
shift; ;;
--t) [ ${ARG_TARBALL:-0} -eq 1 ] && exec cat build.usage || ARG_TARBALL=1; ;;
+-t*) [ ${ARG_TARBALL:-0} -eq 1 ] && exec cat build.usage || ARG_TARBALL=1;
+ [ "${1#-t.}" != "${1}" ] && TARBALL_SUFFIX=${1#-t.}; ;;
-x) set -o xtrace; ;;
-X) set -o xtrace; ARG_DEBUG_TARBALL=1; ;;
*=*) set_var_unsafe "$(get_prefix_lrg "${1}" =)" \
@@ -41,7 +42,7 @@ if [ -d ${PREFIX_NATIVE}/usr -o -f ${PREFIX_NATIVE}/usr -o -L ${PREFIX_NATIVE}/u
fi;
ln -sf . ${PREFIX_NATIVE}/usr;
BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}};
-for BUILD_LVL in 0 1 2 3; do
+for BUILD_LVL in 0 1 2 3 ${ARG_TARBALL:+9}; do
for BUILD_SCRIPT_FNAME in ${BUILD_LVL}[0-9][0-9].*.build; do
if [ -n "${ARG_RESTART_SCRIPT}" ] \
&& [ "${ARG_RESTART_SCRIPT}" != "ALL" ] \
@@ -103,46 +104,6 @@ for BUILD_LVL in 0 1 2 3; do
done;
log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s).";
build_times_get; log_msg info "Build time: ${BUILD_TIMES_HOURS} hour(s), ${BUILD_TIMES_MINUTES} minute(s), and ${BUILD_TIMES_SECS} second(s).";
-if [ $(( ${BUILD_NFINI} + ${BUILD_NSKIP} )) -ge 0 ] \
-&& [ ${BUILD_NFAIL} -eq 0 ] \
-&& [ ${ARG_TARBALL:-0} -eq 1 ]; then
- update_build_status build_finish tarball_start;
- log_msg info "Building distribution tarball...";
- cd ${PREFIX}; PREFIX_BASENAME=${PREFIX_NATIVE##*/};
- rm_if_exists -m ${PREFIX_BASENAME}/lib.bak;
- tar -C ${PREFIX_BASENAME}/lib -cpf - . | tar -C ${PREFIX_BASENAME}/lib.bak -xpf -;
- log_msg info "Backed up ${PREFIX_BASENAME}/lib.";
- find native/lib -maxdepth 1 -type l \
- -exec sh -c '[ -f "${DEST:=native/lib/$(readlink -- "${0}")}" ] && \
- rm -f -- "${0}" && ln -f -- "${DEST}" "${0}"' {} \;;
- log_msg info "Converted symbolic links in ${PREFIX_BASENAME}/lib to hard links.";
-
- tar -cJpf ${TARBALL_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.xz\
- $(find_with_no_paths "${TARBALL_EXCLUDE_PATHS} native/lib.bak" . \
- -mindepth 1 -maxdepth 2 -type d -not -path ./native) \
- "Create \`Midipix mintty shell' shortcut.vbs" midipix.sh;
- log_msg info "Finished building distribution tarball.";
- if [ -x "$(which gpg 2>/dev/null)" -a -n "${TARBALL_SRC_SIGN_GPG_KEY}" ] &&\
- gpg --list-keys "${TARBALL_SRC_SIGN_GPG_KEY}" >/dev/null 2>&1; then
- gpg --armor --passphrase-file /dev/null \
- --local-user "${TARBALL_SRC_SIGN_GPG_KEY}" --sign \
- ${TARBALL_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.xz;
- fi;
- rm -rf ${PREFIX_BASENAME}/lib; mv ${PREFIX_BASENAME}/lib.bak ${PREFIX_BASENAME}/lib;
- log_msg info "Restored ${PREFIX_BASENAME}/lib.";
- log_msg info "Building source tarball...";
- tar -cJpf ${TARBALL_SRC_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.xz\
- $(find tmp -mindepth 1 -maxdepth 1 -type d);
- log_msg info "Finished building source tarball.";
- if [ -x "$(which gpg 2>/dev/null)" -a -n "${TARBALL_SIGN_GPG_KEY}" ] &&\
- gpg --list-keys "${TARBALL_SIGN_GPG_KEY}" >/dev/null 2>&1; then
- gpg --armor --passphrase-file /dev/null \
- --local-user "${TARBALL_SIGN_GPG_KEY}" --sign \
- ${TARBALL_SRC_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.xz;
- fi;
- cd ${OLDPWD};
- update_build_status tarball_finish;
-fi;
update_build_status finish; clean_build_status;
exit ${BUILD_SCRIPT_RC})} 2>&1 | tee ${PREFIX}/${BUILD_LOG_FNAME:=build-$(date ${TIMESTAMP_FMT_STATUS_FILES}).log} &
trap "kill -INT $!" HUP INT TERM USR1 USR2; wait;
diff --git a/build.usage b/build.usage
index 5beef932..a4f8cb7d 100644
--- a/build.usage
+++ b/build.usage
@@ -10,9 +10,11 @@ usage: ./build.sh [-c] [-nd] [-r ALL|name[:step]] [-h] [-t]
or at the optionally specified build step. Currently defined
build steps are: fetch extract build_dir patch configure clean
build install configure1 configure2 build1 build2 install1 install2.
- -t Produce a distribution tarball containing $PREFIX
- sans $WORKDIR and $PREFIX/src/midipix_build at the end of a
- build with zero failures.
+ -t[.gz|.bz2|.xz] Produce binary distribution and source tarballs containing $PREFIX
+ sans $WORKDIR and $PREFIX/src/midipix_build and $WORKDIR sans top-
+ level regular files at the end of a build with zero failures. The
+ tarballs will be compressed with either gzip, bzip2, or xz and signed
+ with GPG; the default compression is xz.
-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
diff --git a/build.vars b/build.vars
index ae6cf1b4..b2fcecd0 100644
--- a/build.vars
+++ b/build.vars
@@ -39,6 +39,7 @@ fi;
: ${TARBALL_SRC_FNAME_PREFIX:=midipix-${ARCH}.src.};
: ${TARBALL_EXCLUDE_PATHS:="src tmp"};
: ${TARBALL_SRC_SIGN_GPG_KEY=};
+: ${TARBALL_SUFFIX:=xz};
: ${PREFIX_NATIVE:=${PREFIX}/native};
: ${PREFIX_TARGET:=${PREFIX}/${TARGET}};
: ${PREFIX_LVL0:=${PREFIX_TARGET}};