summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--006.musl.full.build4
-rw-r--r--007.gcc.full.build3
-rw-r--r--100.perk.build1
-rw-r--r--104.libelf.vars19
-rw-r--r--LICENCE (renamed from LICENSE)0
-rwxr-xr-xbuild.sh70
-rw-r--r--build.subr66
-rw-r--r--build.usage10
-rw-r--r--build.vars13
-rw-r--r--pkg.build2
10 files changed, 121 insertions, 67 deletions
diff --git a/006.musl.full.build b/006.musl.full.build
index bb31c227..72871ad8 100644
--- a/006.musl.full.build
+++ b/006.musl.full.build
@@ -11,10 +11,10 @@ if [ "${3}" = no-complex ]; then
_install=install_no_complex;
set_build_dir musl-${PKG_MUSL_VERSION}-${3} cross;
if ! is_build_script_done fetch; then
- rm_if_exists musl-${PKG_MUSL_VERSION}.tar.gz;
fetch http://www.musl-libc.org/releases/musl-${PKG_MUSL_VERSION}.tar.gz \
${PKG_MUSL_SHA256SUM};
- rm_if_exists mmglue;
+ [ ${ARG_NO_DOWNLOAD:-0} -eq 0 ] &&\
+ rm_if_exists mmglue;
fetch_git mmglue ${GITROOT}/mmglue;
set_build_script_done fetch -extract;
fi;
diff --git a/007.gcc.full.build b/007.gcc.full.build
index d3f58b40..a5f94393 100644
--- a/007.gcc.full.build
+++ b/007.gcc.full.build
@@ -41,9 +41,8 @@ else
if [ "${3}" = stage1 ]; then
# GCC, stage1.
if ! is_build_script_done fetch; then
- rm_if_exists cbb-gcc-${PKG_GCC_VERSION};
fetch_git cbb-gcc-${PKG_GCC_VERSION} \
- ${GITROOT}/cbb/cbb-gcc-${PKG_GCC_VERSION};
+ ${GITROOT}/cbb/cbb-gcc-${PKG_GCC_VERSION};
set_build_script_done fetch -configure;
fi;
set_build_dir cbb-gcc-${PKG_GCC_VERSION} cross;
diff --git a/100.perk.build b/100.perk.build
index b7ad3583..969f75d0 100644
--- a/100.perk.build
+++ b/100.perk.build
@@ -3,7 +3,6 @@
#
if ! is_build_script_done fetch; then
- rm_if_exists perk;
fetch_git perk ${GITROOT}/perk;
set_build_script_done fetch -configure1;
fi;
diff --git a/104.libelf.vars b/104.libelf.vars
index 4b654137..7a0f9e3d 100644
--- a/104.libelf.vars
+++ b/104.libelf.vars
@@ -3,17 +3,14 @@
#
pkg_libelf_install_post() {
- if ! is_build_script_done install2; then
- rm -f lib/libelf.def;
- echo EXPORTS > lib/libelf.def;
- perk -e lib/libelf.so >> lib/libelf.def;
- ${HOST_NATIVE}-dlltool \
- --output-lib lib/libelf.lib.a \
- --dllname libelf.so \
- --input-def lib/libelf.def;
- cp lib/libelf.lib.a ${PREFIX}/lib;
- set_build_script_done install2 -finish;
- fi;
+ rm -f lib/libelf.def;
+ echo EXPORTS > lib/libelf.def;
+ perk -e lib/libelf.so >> lib/libelf.def;
+ ${HOST_NATIVE}-dlltool \
+ --output-lib lib/libelf.lib.a \
+ --dllname libelf.so \
+ --input-def lib/libelf.def;
+ cp lib/libelf.lib.a ${PREFIX}/lib;
};
# vim:filetype=sh
diff --git a/LICENSE b/LICENCE
index 3d401651..3d401651 100644
--- a/LICENSE
+++ b/LICENCE
diff --git a/build.sh b/build.sh
index da66b497..9cc4aafe 100755
--- a/build.sh
+++ b/build.sh
@@ -1,30 +1,34 @@
#!/bin/sh
+# Copyright (c) 2016 Lucio Andrés Illanes Albornoz <l.illanes@gmx.de>
#
-{
. ./build.subr;
+
while [ ${#} -gt 0 ]; do
case ${1} in
+-c) ARG_CLEAN=1; ;;
+-nd) ARG_NO_DOWNLOAD=1; ;;
-r) [ -n "${ARG_RESTART_SCRIPT}" ] && exec cat build.usage;
match_any "${2}" : \
&& { 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; ;;
*=*) set_var_unsafe "$(get_prefix_lrg "${1}" =)" \
"$(get_postfix "${1}" =)"; ;;
*) exec cat build.usage; ;;
-esac; shift; done; . ./build.vars;
+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;
-log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE:=$(date %Y-%m-%d-%H-%M-%S)}.";
-log_env_vars ${LOG_ENV_VARS};
(mkdir -p ${PREFIX} ${PREFIX_NATIVE} ${PREFIX_TARGET} ${WORKDIR};
-touch ${PREFIX}/BUILD_IN_PROGRESS ${BUILD_PROGRESS_FNAME:=${PREFIX}/BUILD_STARTED_AT_${BUILD_DATE}};
+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;
BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}};
-BUILD_SECS=$(command date +%s);
for BUILD_LVL in 0 1 2 3; do
for BUILD_SCRIPT_FNAME in ${BUILD_LVL}[0-9][0-9].*.build; do
if [ -n "${ARG_RESTART_SCRIPT}" ] \
@@ -68,44 +72,30 @@ for BUILD_LVL in 0 1 2 3; do
fi;
done;
log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s).";
-: $((BUILD_SECS=$(command date +%s)-${BUILD_SECS}));
-: $((BUILD_HOURS=${BUILD_SECS}/3600));
-: $((BUILD_MINUTES=(${BUILD_SECS}%3600)/60));
-: $((BUILD_SECS=(${BUILD_SECS}%3600)%60));
-log_msg info "Build time: ${BUILD_HOURS} hour(s), ${BUILD_MINUTES} minute(s), and ${BUILD_SECS} second(s).";
-[ -f ${BUILD_PROGRESS_FNAME} ] && rm -f ${BUILD_PROGRESS_FNAME};
-touch ${BUILD_FINISH_FNAME:=${PREFIX}/BUILD_FINISHED_AT_$(date %Y-%m-%d-%H-%M-%S)} \
- ${TARBALL_PROGRESS_FNAME:=${PREFIX}/TARBALL_STARTED_AT_$(date %Y-%m-%d-%H-%M-%S)};
-ln -sf ${BUILD_FINISH_FNAME} ${PREFIX}/BUILD_FINISHED_AT;
-# rotate BUILD_FINISH_FNAME files
+build_times_get; log_msg info "Build time: ${BUILD_TIMES_HOURS} hour(s), ${BUILD_TIMES_MINUTES} minute(s), and ${BUILD_TIMES_SECS} second(s).";
+update_build_status build_finish tarball_start;
if [ $(( ${BUILD_NFINI} + ${BUILD_NSKIP} )) -ge 0 ] \
-&& [ ${BUILD_NFAIL} -eq 0 ]\
+&& [ ${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;
- PREFIX_BASENAME=${PREFIX_NATIVE##*/}; WORKDIR_BASENAME=${WORKDIR##*/};
- rm_if_exists -m ${PREFIX_BASENAME}/lib.bak; rm_if_exists ${DISTRIB_FNAME};
+ 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.";
(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 ./src/midipix_build \
- -not -path ./src/midipix_build/\* \
- -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;
- # rotate tarballs
+ -exec sh -c 'DEST=$(readlink -- "${0}") && \
+ rm -f -- "${0}" && ln -- "${DEST}" "${0}"' {} \;); wait;
+ log_msg info "Converted symbolic links in ${PREFIX_BASENAME}/lib to hard links.";
+ tar -cpf - $(find . \
+ -mindepth 1 -maxdepth 1 -type d \
+ $(echo ${TARBALL_EXCLUDE_PATHS} lib | sed 's/\(^\| \)/ -not -path /g')) |\
+ bzip2 -9c - > ${TARBALL_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}${TARBALL_FNAME_SUFFIX};
+ rm -rf ${PREFIX_BASENAME}/lib; mv ${PREFIX_BASENAME}/lib.bak ${PREFIX_BASENAME}/lib);
+ wait; log_msg info "Finished building distribution tarball.";
+ update_build_status tarball_finish;
fi;
-[ -f ${TARBALL_PROGRESS_FNAME} ] && rm -f ${TARBALL_PROGRESS_FNAME};
-[ -f BUILD_IN_PROGRESS ] && rm -f BUILD_IN_PROGRESS;
+update_build_status finish;
exit ${BUILD_SCRIPT_RC})} 2>&1 | tee build.log;
# vim:filetype=sh
diff --git a/build.subr b/build.subr
index 9f7f540e..b696a285 100644
--- a/build.subr
+++ b/build.subr
@@ -4,7 +4,6 @@
#
date() { command date +"${1:-${TIMESTAMP_FMT}}"; };
-fetch_git() { [ -d ${1} ] && (cd ${1} && git pull origin main) || git clone ${3} ${2} ${1}; };
get_basename() { set -- $(get_name_without_slash ${1}); echo "${1##*/}"; };
get_var_dyn() { ${1}; };
get_var_unsafe() { eval echo \${${1}}; };
@@ -24,6 +23,22 @@ test_cmd() { command -v "${1}" >/dev/null; };
unsplit() { push_IFS "${1}"; shift; set -- "${@}"; echo "${*}"; pop_IFS; };
+build_times_init() { BUILD_TIMES_SECS=$(command date +%s); };
+build_times_get() {
+ : $((BUILD_TIMES_SECS=$(command date +%s)-${BUILD_TIMES_SECS}));
+ : $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600));
+ : $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60));
+ : $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60));
+};
+
+clean_prefix() {
+ log_msg info "-c specified, cleaning prefix...";
+ set -- bin include lib lib64 libexec native share x86_64-nt64-midipix;
+ while [ ${#} -gt 0 ]; do rm -rf ${PREFIX}/${1}; shift; done;
+ find ${PREFIX}/tmp -mindepth 1 -maxdepth 1 -not -iname \*.tar\* -exec rm -rf {} \;
+ find ${PREFIX}/tmp -mindepth 1 -maxdepth 1 -type f -iname .\* -exec rm -rf {} \;
+};
+
export_vars_subst() {
_evs_pfx=${1}; _evs_pfx_new=${2}; shift 2;
while [ ${#} -gt 0 ]; do
@@ -33,6 +48,12 @@ export_vars_subst() {
done; unset _evs_pfx _evs_pfx_new;
};
+fetch_git() {
+ rm_if_exists ${1};
+ [ -d ${1} ] && (cd ${1} && git pull origin main)\
+ || git clone ${3} ${2} ${1};
+};
+
rm_if_exists() {
[ -z "${1#-m}" ] && { _rie_arg_m=1; shift; };
[ -z "${1#-c}" ] && { _rie_arg_c=1; shift; };
@@ -42,6 +63,14 @@ rm_if_exists() {
return 0;
};
+rotate_files() {
+ set -- $(find ${PREFIX} -mindepth 1 -maxdepth 1 -type f -iname "${1}" |\
+ sort | sed -n $((${2}+1)),\$p);
+ while [ ${#} -gt 0 ]; do
+ rm -f "${1}"; shift;
+ done;
+};
+
set_env_vars() {
_sev_val_new="${1}"; shift;
while [ ${#} -gt 1 ]; do
@@ -101,6 +130,8 @@ clear_env_with_except() {
};
fetch() {
+ [ ${ARG_NO_DOWNLOAD:-0} -eq 0 ] &&\
+ rm_if_exists $(get_basename ${1});
wget ${WGET_ARGS} ${1};
if [ ${#} -eq 2 ]; then
set -- $(get_basename ${1}) "$(compare_hash $(get_basename ${1}) ${2})" ${2};
@@ -129,7 +160,10 @@ compare_hash_manifest() {
is_build_script_done() {
if [ -n "${ARG_RESTART_SCRIPT_AT}" ]; then
- if [ "${1}" = "finish" ]\
+ if [ "${1}" = clean ]\
+ && [ -z "${ARG_RESTART_SCRIPT_AT#ALL}" ]; then
+ return 0; # Skip
+ elif [ "${1}" = finish ]\
|| [ -z "${ARG_RESTART_SCRIPT_AT#ALL}" ]; then
return 1; # Build
elif ! match_list ${ARG_RESTART_SCRIPT_AT} , ${1}; then
@@ -222,4 +256,32 @@ run_cmd_unsplit() {
unset _rcu_cmd _rcu_cmdline; return ${_rcu_rc};
};
+update_build_status() {
+ while [ ${#} -gt 0 ]; do
+ case ${1} in
+ build_start)
+ touch ${BUILD_STATUS_IN_PROGRESS_FNAME};
+ touch ${BUILD_STATUS_PROGRESS_FNAME:=${PREFIX}/BUILD_STARTED_AT_${BUILD_DATE_START:=$(date %Y-%m-%d-%H-%M-%S)}};
+ ;;
+ build_finish)
+ [ -f ${BUILD_STATUS_PROGRESS_FNAME} ] &&\
+ rm -f ${BUILD_STATUS_PROGRESS_FNAME};
+ touch ${BUILD_STATUS_FINISHED_AT_FNAME:=${PREFIX}/BUILD_FINISHED_AT_$(date ${TIMESTAMP_FMT_STATUS_FILES})};
+ rotate_files BUILD_FINISHED_AT_\* 8;
+ ln -sf ${BUILD_STATUS_FINISHED_AT_FNAME}\
+ ${BUILD_STATUS_FINISHED_AT_CURRENT_FNAME}; ;;
+ tarball_start)
+ rotate_files midipix.\*.tar.bz2 8;
+ touch ${BUILD_STATUS_TARBALL_PROGRESS_FNAME:=${PREFIX}/TARBALL_STARTED_AT_$(date ${TIMESTAMP_FMT_STATUS_FILES})};
+ ;;
+ tarball_finish)
+ [ -f ${BUILD_STATUS_TARBALL_PROGRESS_FNAME} ] &&\
+ rm -f ${BUILD_STATUS_TARBALL_PROGRESS_FNAME}; ;;
+ finish)
+ [ -f ${BUILD_STATUS_IN_PROGRESS_FNAME} ] &&\
+ rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME}; ;;
+ esac; shift;
+ done;
+};
+
# vim:filetype=sh
diff --git a/build.usage b/build.usage
index 00ef1583..c43a5e15 100644
--- a/build.usage
+++ b/build.usage
@@ -1,4 +1,6 @@
-usage: ./build.sh [-r ALL|name[:step]] [-h] [-t]
+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
@@ -13,8 +15,8 @@ usage: ./build.sh [-r ALL|name[:step]] [-h] [-t]
named ${PKG_SUBDIR}.local.patch.
Examples:
- ./build.sh -r psxscl -- GITROOT_HEAD=... PKG_PSXSCL_CFLAGS=-DPSX_INTERNAL_STRACE
+ ./build.sh -r psxscl GITROOT_HEAD=... PKG_PSXSCL_CFLAGS=-DPSX_INTERNAL_STRACE
Build psxscl from the internal repository with strace enabled.
- ./build.sh -r ALL -- GITROOT_HEAD=...
- Forcibly rebuild everything.
+ ./build.sh -c -r ALL GITROOT_HEAD=...
+ Clean $PREFIX and forcibly rebuild everything.
diff --git a/build.vars b/build.vars
index 5614defb..d60829a0 100644
--- a/build.vars
+++ b/build.vars
@@ -8,7 +8,11 @@
# should not be forward slash-terminated.
#
+: ${PREFIX:=${HOME}/midipix};
+
: ${ARCH:=nt64};
+: ${BUILD_STATUS_FINISHED_AT_CURRENT_FNAME:=${PREFIX}/BUILD_FINISHED_AT};
+: ${BUILD_STATUS_IN_PROGRESS_FNAME:=${PREFIX}/BUILD_IN_PROGRESS};
: ${CFLAGS_DEFAULT:=-g3 -O0};
: ${GITROOT:=git://midipix.org};
: ${GITROOT_HEAD:=git://midipix.org};
@@ -18,18 +22,21 @@
: ${LOG_MSG_INFO_COLOUR:=93};
: ${LOG_MSG_SUCC_COLOUR:=92};
: ${MAKEFLAGS_DEFAULT:=-j8};
-: ${PREFIX:=${HOME}/midipix};
-: ${PREFIX_NATIVE:=${PREFIX}/native};
+: ${TARBALL_FNAME_PREFIX:=midipix.};
+: ${TARBALL_FNAME_SUFFIX:=.tar.bz2};
+: ${TARBALL_EXCLUDE_PATHS:="src tmp"};
: ${TARGET:=x86_64-nt64-midipix};
+: ${PREFIX_NATIVE:=${PREFIX}/native};
: ${PREFIX_TARGET:=${PREFIX}/${TARGET}};
: ${PREFIX_LVL0:=${PREFIX_TARGET}};
: ${PREFIX_LVL1:=${PREFIX_NATIVE}};
: ${PREFIX_LVL2:=${PREFIX_NATIVE}};
: ${PREFIX_LVL3:=${PREFIX_NATIVE}};
-: ${WORKDIR:=${PREFIX}/tmp};
export PATH="${PREFIX}/bin${PATH:+:${PATH}}";
: ${TIMESTAMP_FMT:="%Y/%m/%d %H:%M:%S"};
+: ${TIMESTAMP_FMT_STATUS_FILES:=%Y-%m-%d-%H-%M-%S};
: ${WGET_ARGS:="-N --no-check-certificate"};
+: ${WORKDIR:=${PREFIX}/tmp};
: ${PKG_BUILD_NAMES:="apk_tools bash binutils binutils_host bzip2 coreutils dalist dash diffutils findutils gawk git gmp grep gzip less libelf libressl libz make mpc mpfr ncurses ntapi ntcon ntctty openssh patch pemagine popt psxscl psxstub psxtypes rsync sed tar util_linux which xz"};
: ${PKG_BUILD_VARS:="AR_BUILD AR_CONFIGURE BUILD_DIR BUILD_TYPE CC_BUILD CC_CONFIGURE CC_INSTALL CFLAGS_BUILD_EXTRA CFLAGS_CONFIGURE CFLAGS_CONFIGURE_EXTRA CFLAGS_INSTALL_EXTRA CONFIGURE_ARGS CONFIGURE_ARGS_EXTRA ENV_VARS_EXTRA GIT_ARGS_EXTRA INSTALL_TARGET LDFLAGS_BUILD_EXTRA LDFLAGS_CONFIGURE_EXTRA LDFLAGS_INSTALL_EXTRA LIBTOOL_MIDIPIX MAKEFLAGS_BUILD MAKEFLAGS_BUILD_EXTRA MAKEFLAGS_INSTALL MAKEFLAGS_INSTALL_EXTRA NO_CLEAN PATCHES_EXTRA_URL PREFIX_EXTRA RANLIB_INSTALL SHA256SUM SUBDIR URL URL_TYPE VERSION"};
diff --git a/pkg.build b/pkg.build
index 98cb1ae2..dee48376 100644
--- a/pkg.build
+++ b/pkg.build
@@ -5,10 +5,8 @@
parse_with_pkg_name ${SCRIPT_FNAME%[0-9][0-9]*} ${2} ${PKG_BUILD_NAMES};
if ! is_build_script_done fetch; then
if [ "${PKG_URL_TYPE:-wget}" = wget ]; then
- rm_if_exists $(get_basename ${PKG_URL});
fetch ${PKG_URL} ${PKG_SHA256SUM};
else
- rm_if_exists ${PKG_SUBDIR};
fetch_git ${PKG_SUBDIR} ${PKG_URL} "${PKG_GIT_ARGS_EXTRA}";
fi;
set_build_script_done fetch -extract;