d30b8f - Replaced non-portable cp -a command lines w/ tar (1) invocations.

Authored and Committed by Lucio Andrés Illanes Albornoz (arab, vxp) 9 years ago
    - Replaced non-portable cp -a command lines w/ tar (1) invocations.
    - Provide CFLAGS for each build level and script consistently.
    - Create compressed distribution tarball at the end of a finished build.
    - Fix bug that prevented gzip and libz from being installed.
    - Followup to c497546f591a3cc128abda42d0026c46ffdd6c36.
    
        
file modified
+1 -3
101.gmp.build CHANGED
@@ -1,6 +1,4 @@
1
1
parse_with_pkg_name ${2} gmp mpfr mpc libelf binutils;
2
- [ -n "${_pkg_CC}" ] && export CC="${_pkg_CC}";
3
- [ -n "${_pkg_CFLAGS}" ] && export CFLAGS="${_pkg_CFLAGS}";
4
2
if is_build_script_done finished; then
5
3
exit 212;
6
4
else
@@ -16,7 +14,7 @@ if ! is_build_script_done patched; then
16
14
patch -d ${_pkg_subdir} -p1 \
17
15
< portage/${_pkg_subdir}.midipix.patch;
18
16
if [ ${_pkg_no_libtool_midipix:-0} -eq 0 ]; then
19
- cp -a portage/libtool.midipix ${_pkg_subdir}/;
17
+ cp portage/libtool.midipix ${_pkg_subdir}/;
20
18
fi;
21
19
set_build_script_done patched -configured;
22
20
fi;
file modified
+1 -2
200.coreutils.build CHANGED
@@ -1,4 +1,3 @@
1
- export CFLAGS="${CFLAGS_PACKAGES}";
2
1
parse_with_pkg_name ${2} \
3
2
coreutils diffutils findutils patch \
4
3
gawk bash make grep sed binutils;
@@ -30,7 +29,7 @@ fi;
30
29
if ! is_build_script_done configured; then
31
30
rm_if_exists -m -c ${_build_dir};
32
31
[ ${_no_config_cache:-0} -eq 0 ] &&\
33
- cp -a ../portage/config.cache .;
32
+ cp ../portage/config.cache .;
34
33
../${_pkg_subdir}/configure \
35
34
${_configure_args} --target=${TARGET};
36
35
set_build_script_done configured -built;
file modified
+11 -20
207.libz.build CHANGED
@@ -1,27 +1,18 @@
1
+ parse_with_pkg_name ${2} libz gzip;
1
2
if is_build_script_done finished; then
2
3
exit 212;
3
- elif [ "x${2}" = "xlibz" ]; then
4
- _pkg_url=https://sortix.org/libz/release/libz-${PKG_LIBZ_VERSION}.tar.gz;
4
+ else
5
+ fetch ${_pkg_url} ${_pkg_sha256sum};
5
- _pkg_fname=${_pkg_url##*/};
6
- _pkg_sha256sum=${PKG_LIBZ_SHA256SUM};
7
- _pkg_subdir=${2}-${PKG_LIBZ_VERSION};
8
- elif [ "x${2}" = "xgzip" ]; then
9
- _pkg_url=https://ftp.gnu.org/gnu/gzip/gzip-${PKG_GZIP_VERSION}.tar.gz;
10
- _pkg_fname=${_pkg_url##*/};
11
- _pkg_sha256sum=${PKG_GZIP_SHA256SUM};
12
- _pkg_subdir=${2}-${PKG_GZIP_VERSION};
13
6
fi;
14
- fetch ${_pkg_url} ${_pkg_sha256sum};
15
7
if ! is_build_script_done extracted; then
16
8
rm_if_exists ${_pkg_fname%%.tar*};
17
9
tar -axf ${_pkg_fname};
18
- set_build_script_done extracted -patched;
10
+ set_build_script_done extracted -configured;
19
11
fi;
20
12
if ! is_build_script_done configured; then
21
13
set_build_dir ${_pkg_fname%%-*} native;
22
14
rm_if_exists -c -m ${_build_dir};
23
- cp -a ../portage/config.cache .;
15
+ cp ../portage/config.cache .;
24
- CFLAGS="${CFLAGS_PACKAGES}" \
25
16
../${_pkg_subdir}/configure \
26
17
--host=${HOST_NATIVE} \
27
18
--prefix= \
@@ -31,19 +22,19 @@ else
31
22
cd ${_build_dir};
32
23
fi;
33
24
if ! is_build_script_done built; then
34
- if [ "x${3}" = "xlibz" ]; then
25
+ if [ "x${2}" = "xlibz" ]; then
35
26
make -j18;
36
- elif [ "x${3}" = "xgzip" ]; then
27
+ elif [ "x${2}" = "xgzip" ]; then
37
28
make clean;
38
- make CFLAGS="-g3 -O0 -I${PREFIX_NATIVE}/include" LDFLAGS=--sysroot=${PREFIX_NATIVE};
29
+ make;
39
30
fi;
40
31
set_build_script_done built -installed;
41
32
fi;
42
33
if ! is_build_script_done installed; then
43
- if [ "x${3}" = "xlibz" ]; then
34
+ if [ "x${2}" = "xlibz" ]; then
44
35
make -j18 DESTDIR=${PREFIX_NATIVE} install;
45
- elif [ "x${3}" = "xgzip" ]; then
46
- cp -a gunzip gzip zcat ${PREFIX_NATIVE}/bin;
36
+ elif [ "x${2}" = "xgzip" ]; then
37
+ cp gunzip gzip zcat ${PREFIX_NATIVE}/bin;
47
38
fi;
48
39
set_build_script_done installed finished;
49
40
fi;
file modified
+25 -1
build.sh CHANGED
@@ -3,8 +3,9 @@
3
3
{
4
4
unset AR ARFLAGS CC CFLAGS CXX CXXFLAGS LD LDFLAGS;
5
5
. ./build.vars; . ./build.subr;
6
+ check_path_vars PREFIX PREFIX_NATIVE WORKDIR;
6
7
check_prereqs git make openssl sed tar tr wget;
7
- log_msg info "Build started by ${USER}@$(hostname).";
8
+ log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE:=$(date %Y-%m-%d-%H-%M-%S)}.";
8
9
#trap
9
10
(set -o errexit; mkdir -p ${PREFIX} ${WORKDIR});
10
11
BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${_nbuild:=0}}};
@@ -20,6 +21,7 @@ for BUILD_LVL in 0 1 2; do
20
21
log_msg info "Invoking build script \`${BUILD_SCRIPT_FNAME}'";
21
22
(set -o errexit -- $(split . ${BUILD_SCRIPT_FNAME%.build}); \
22
23
SCRIPT_FNAME=${BUILD_SCRIPT_FNAME}; _pwd=$(pwd); \
24
+ export CFLAGS="$(eval echo \${CFLAGS_LVL${BUILD_LVL}})"; \
23
25
cd ${WORKDIR}; . ${_pwd}/build.subr; \
24
26
. ${_pwd}/${BUILD_SCRIPT_FNAME});
25
27
case ${BUILD_SCRIPT_RC:=${?}} in
@@ -37,6 +39,28 @@ for BUILD_LVL in 0 1 2; do
37
39
fi;
38
40
done;
39
41
log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${_nbuild} build script(s).";
42
+ if [ $(( ${BUILD_NFINI} + ${BUILD_NSKIP} )) -ge 0 ]\
43
+ && [ ${BUILD_NFAIL} -eq 0 ]; then
44
+ log_msg info "Building distribution tarball.";
45
+ (cd ${PREFIX};
46
+ DISTRIB_FNAME=midipix.${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE}.tar.bz2;
47
+ rm_if_exists -m ${PREFIX_NATIVE##*/}/lib.bak; rm_if_exists ${DISTRIB_FNAME};
48
+ tar -C ${PREFIX_NATIVE##*/}/lib -cpf - . |\
49
+ tar -C ${PREFIX_NATIVE##*/}/lib.bak -xpf -;
50
+ (cd native/lib &&
51
+ find . -maxdepth 1 -type l \
52
+ -exec sh -c 'dest=$(readlink -- "$0") && rm -- "$0" && ln -- "$dest" "$0"' {} \;);
53
+ wait;
54
+ find . -maxdepth 2 -type d \
55
+ -not -path . \
56
+ -not -path ./${WORKDIR##*/} \
57
+ -not -path ./${WORKDIR##*/}/\* \
58
+ -not -path ./${PREFIX_NATIVE##*/} \
59
+ -not -path ./${PREFIX_NATIVE##*/}/lib.bak |\
60
+ tar -T - -cpf - | bzip2 -9c - > ${DISTRIB_FNAME}
61
+ rm -rf ${PREFIX_NATIVE##*/}/lib;
62
+ mv ${PREFIX_NATIVE##*/}/lib.bak ${PREFIX_NATIVE##*/}/lib);
63
+ fi;
40
64
exit ${BUILD_SCRIPT_RC};
41
65
} 2>&1 | tee build.log;
42
66
file modified
+30 -14
build.subr CHANGED
@@ -4,17 +4,31 @@
4
4
5
5
TIMESTAMP_FMT="${TIMESTAMP_FMT:-"%Y/%m/%d %H:%M:%S"}";
6
6
7
+ check_path_vars() {
8
+ while [ $# -gt 0 ]; do
9
+ if [ -z "${_val:=$(eval echo \${${1}})}" ]; then
10
+ log_msg fail "Error: variable \`${1}' is empty or unset.";
11
+ exit 1;
12
+ elif [ "x${_val#* }" != "x${_val}" ]; then
13
+ log_msg fail "Error: variable \`${1}' contains one or more whitespace characters.";
14
+ exit 1;
15
+ else
16
+ shift;
17
+ fi;
18
+ done; unset _val;
19
+ };
20
+
7
21
check_prereqs() {
8
22
for _cmd in "$@"; do
9
23
if ! command -v ${_cmd} >/dev/null; then
10
- log_msg fail "Error: missing prerequisite command \`${_cmd}";
24
+ log_msg fail "Error: missing prerequisite command \`${_cmd}.";
11
25
exit 1;
12
26
fi;
13
27
done; unset _cmd;
14
28
};
15
29
16
30
date() {
17
- command date +"${TIMESTAMP_FMT}";
31
+ command date +"${1:-${TIMESTAMP_FMT}}";
18
32
};
19
33
20
34
fetch() {
@@ -71,9 +85,9 @@ log_msg() {
71
85
succ) printf "\033[${LOG_MSG_SUCC_COLOUR}m"; ;;
72
86
esac;
73
87
if [ $# -gt 1 ]; then
74
- printf "==> %s %s %s\033[0m\n" "$(date +"${TIMESTAMP_FMT}")" "${1}" "$*";
88
+ printf "==> %s %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}" "$*";
75
89
else
76
- printf "==> %s %s\033[0m\n" "$(date +"${TIMESTAMP_FMT}")" "${1}";
90
+ printf "==> %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}";
77
91
fi;
78
92
unset _lvl;
79
93
};
@@ -83,16 +97,18 @@ parse_with_pkg_name() {
83
97
while [ $# -ge 0 ]; do
84
98
if [ "x${_pkg_name}" = "x${1}" ]; then
85
99
_pkg_NAME=$(echo "${_pkg_name}" | tr a-z A-Z);
86
- eval _pkg_configure_extra_args=\"\${PKG_${_pkg_NAME}_CONFIGURE_EXTRA_ARGS}\"\
87
- _pkg_no_libtool_midipix=\${PKG_${_pkg_NAME}_NO_LIBTOOL_MIDIPIX}\
88
- _pkg_prefix=\${PKG_${_pkg_NAME}_PREFIX}\
89
- _pkg_prefix_extra=\${PKG_${_pkg_NAME}_PREFIX_EXTRA}\
90
- _pkg_sha256sum=\${PKG_${_pkg_NAME}_SHA256SUM}\
91
- _pkg_url=\${PKG_${_pkg_NAME}_URL}\
92
- _pkg_version=\${PKG_${_pkg_NAME}_VERSION}\
93
- _pkg_CC=\${PKG_${_pkg_NAME}_CC}\
94
- _pkg_CFLAGS=\${PKG_${_pkg_NAME}_CFLAGS}\
95
- _pkg_DESTDIR=\${PKG_${_pkg_NAME}_DESTDIR};
100
+ for _vname in \
101
+ configure_extra_args no_libtool_midipix \
102
+ prefix prefix_extra sha256sum url version \
103
+ CC CFLAGS LDFLAGS DESTDIR; do
104
+ _vNAME=$(echo "${_vname}" | tr a-z A-Z);
105
+ if [ -n "${_vval:=$(eval echo \${PKG_${_pkg_NAME}_${_vNAME}})}" ]; then
106
+ export _pkg_${_vname}="${_vval}";
107
+ if [ "x${_vname#[A-Z]}" != "x${_vname}" ]; then
108
+ export ${_vname}="${_vval}";
109
+ fi;
110
+ fi; unset _vval;
111
+ done; unset _pkg_NAME _vname _vNAME;
96
112
_pkg_fname=${_pkg_url##*/};
97
113
_pkg_subdir=${_pkg_fname%%.tar*};
98
114
return 0;
file modified
+12 -4
build.vars CHANGED
@@ -3,9 +3,15 @@
3
3
# characters in any of the variables below save for MAKEFLAGS,
4
4
# PATH, and TIMESTAMP_FMT.
5
5
#
6
+ # $PREFIX_{NATIVE,TARGET} and $WORKDIR must be immediately
7
+ # beneath $PREFIX. $PREFIX must be o+rwx. The variables mentioned
8
+ # should not be forward slash-terminated.
9
+ #
6
10
7
11
: ${ARCH:=nt64};
8
- : ${CFLAGS_PACKAGES:=-g3 -O0};
12
+ : ${CFLAGS_LVL0:=-O0};
13
+ : ${CFLAGS_LVL1:=-g3 -O0};
14
+ : ${CFLAGS_LVL2:=-g3 -O0};
9
15
: ${GITROOT:=git://midipix.org};
10
16
: ${HOST_NATIVE:=x86_64-nt64-midipix};
11
17
: ${LOG_MSG_FAIL_COLOUR:=91};
@@ -24,18 +30,17 @@ TIMESTAMP_FMT="%Y/%m/%d %H:%M:%S";
24
30
: ${PKG_BASH_SHA256SUM:=afc687a28e0e24dc21b988fa159ff9dbcf6b7caa92ade8645cc6d5605cd024d4};
25
31
: ${PKG_BASH_VERSION:=4.3};
26
32
: ${PKG_BASH_URL:=https://ftp.gnu.org/gnu/bash/bash-${PKG_BASH_VERSION}.tar.gz};
33
+ : ${PKG_BINUTILS_CONFIGURE_EXTRA_ARGS:=--with-libelf=${PREFIX_NATIVE} --with-gmp=${PREFIX_NATIVE} --with-mpc=${PREFIX_NATIVE} --with-mpfr=${PREFIX_NATIVE} --with-sysroot=/};
27
34
: ${PKG_BINUTILS_SHA256SUM:=250d3b2925c6b211fb16173b0b25bc091c58829fbcad3eb849645e0af52cf7fa};
28
35
: ${PKG_BINUTILS_VERSION:=2.24.51};
29
36
: ${PKG_BINUTILS_URL:=ftp://sourceware.org/pub/binutils/snapshots/binutils-${PKG_BINUTILS_VERSION}.tar.bz2};
30
- : ${PKG_CBB_CONFIGURE_EXTRA_ARGS:=--with-libelf=${PREFIX_NATIVE} --with-gmp=${PREFIX_NATIVE} --with-mpc=${PREFIX_NATIVE} --with-mpfr=${PREFIX_NATIVE} --with-sysroot=/};
31
- : ${PKG_CBB_VERSION:=cbb-gcc-4.6.4};
32
37
: ${PKG_COREUTILS_SHA256SUM:=ec43ca5bcfc62242accb46b7f121f6b684ee21ecd7d075059bf650ff9e37b82d};
33
38
: ${PKG_COREUTILS_VERSION:=8.23};
34
39
: ${PKG_COREUTILS_URL:=https://ftp.gnu.org/gnu/coreutils/coreutils-${PKG_COREUTILS_VERSION}.tar.xz};
35
40
: ${PKG_DIFFUTILS_SHA256SUM:=a25e89a8ab65fded1731e4186be1bb25cda967834b6df973599cdcd5abdfc19c};
36
41
: ${PKG_DIFFUTILS_VERSION:=3.3};
37
42
: ${PKG_DIFFUTILS_URL:=https://ftp.gnu.org/gnu/diffutils/diffutils-${PKG_DIFFUTILS_VERSION}.tar.xz};
38
- : ${PKG_FINDUTILS_CFLAGS:="${CFLAGS:+${CFLAGS} }-Dendpwent=setpwent"};
43
+ : ${PKG_FINDUTILS_CFLAGS:=-Dendpwent=setpwent};
39
44
: ${PKG_FINDUTILS_SHA256SUM:=0de3cf625a5c9f154eee3171e072515ffdde405244dd00502af617ac57b73ae2};
40
45
: ${PKG_FINDUTILS_VERSION:=4.5.14};
41
46
: ${PKG_FINDUTILS_URL:=http://alpha.gnu.org/gnu/findutils/findutils-${PKG_FINDUTILS_VERSION}.tar.gz};
@@ -51,6 +56,9 @@ TIMESTAMP_FMT="%Y/%m/%d %H:%M:%S";
51
56
: ${PKG_GREP_SHA256SUM:=ca91d22f017bfcb503d4bc3b44295491c89a33a3df0c3d8b8614f2d3831836eb};
52
57
: ${PKG_GREP_VERSION:=2.22};
53
58
: ${PKG_GREP_URL:=https://ftp.gnu.org/gnu/grep/grep-${PKG_GREP_VERSION}.tar.xz};
59
+ : ${PKG_GZIP_CC:=${HOST_NATIVE}-gcc};
60
+ : ${PKG_GZIP_CFLAGS:="-g3 -O0 -I${PREFIX_NATIVE}/include"};
61
+ : ${PKG_GZIP_LDFLAGS:=--sysroot=${PREFIX_NATIVE}};
54
62
: ${PKG_GZIP_SHA256SUM:=1ca41818a23c9c59ef1d5e1d00c0d5eaa2285d931c0fb059637d7c0cc02ad967};
55
63
: ${PKG_GZIP_VERSION:=1.2.4};
56
64
: ${PKG_GZIP_URL:=https://ftp.gnu.org/gnu/gzip/gzip-${PKG_GZIP_VERSION}.tar.gz};