summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dist/dist_minipix.dist24
-rw-r--r--dist/dist_zipdist.dist2
-rw-r--r--subr/build_init.subr46
-rw-r--r--subr/ex_pkg_dispatch.subr10
-rw-r--r--subr/ex_pkg_env.subr14
-rw-r--r--subr/pkg_install_files.subr6
-rw-r--r--subr/rtl_complex.subr24
-rw-r--r--subr/rtl_string.subr9
-rw-r--r--vars/gdk.vars2
-rw-r--r--vars/glib.vars2
-rw-r--r--vars/python2_host.vars2
-rw-r--r--vars/python3_host.vars2
12 files changed, 84 insertions, 59 deletions
diff --git a/dist/dist_minipix.dist b/dist/dist_minipix.dist
index 728f14df..99d4b2f8 100644
--- a/dist/dist_minipix.dist
+++ b/dist/dist_minipix.dist
@@ -2,18 +2,6 @@
# set +o errexit -o noglob is assumed.
#
-pkgp_dist_minipix_is_newer() {
- local _new_fname="${1}" _new_ts="" _old_dname="${2}" _old_ts="";
- if ! _old_ts="$(stat -c %Y "${_old_dname%%/}/${_new_fname##*/}" 2>/dev/null)" \
- || ! _new_ts="$(stat -c %Y "${_new_fname}" 2>/dev/null)"; then
- return 0;
- elif [ "${_new_ts}" -gt "${_old_ts}" ]; then
- return 0;
- else
- return 1;
- fi;
-};
-
pkg_dist_minipix_all() {
local _dname="" _fname="" _pname="";
if rtl_lmatch "${ARG_DIST}" "minipix" ","; then
@@ -25,14 +13,14 @@ pkg_dist_minipix_all() {
done;
for _fname in clear reset tset; do
if [ -e "${PREFIX_NATIVE}/bin/${_fname}" ]\
- && pkgp_dist_minipix_is_newer "${PREFIX_NATIVE}/bin/${_fname}" "${PREFIX_MINIPIX}/bin"\
+ && rtl_is_newer "${PREFIX_NATIVE}/bin/${_fname}" "${PREFIX_MINIPIX}/bin/${_fname}"\
&& ! rtl_fileop cp_follow "${PREFIX_NATIVE}/bin/${_fname}" "${PREFIX_MINIPIX}/bin"; then
return 1;
fi;
done;
- for _pname in $([ -e "${PREFIX}/minipix_dist/bin" ] && find "${PREFIX}/minipix_dist/bin" \
+ for _pname in $([ -e "${PREFIX}/minipix_dist/bin" ] && find "${PREFIX}/minipix_dist/bin"\
-maxdepth 1 -perm /a=x -type f -and \( -not -name "lib*" \)); do
- if pkgp_dist_minipix_is_newer "${_pname}" "${PREFIX_MINIPIX}/bin"\
+ if rtl_is_newer "${_pname}" "${PREFIX_MINIPIX}/bin/${_pname##*/}"\
&& ! rtl_fileop cp_follow "${_pname}" "${PREFIX_MINIPIX}/bin"; then
return 1;
fi;
@@ -43,7 +31,7 @@ pkg_dist_minipix_all() {
libu16ports.so.0 libtinfo.so.6 libtinfow.so.6 libunistring.so.2 \
libuuid.so.1; do
if [ -e "${PREFIX_NATIVE}/lib/${_fname}" ]\
- && pkgp_dist_minipix_is_newer "${PREFIX_NATIVE}/lib/${_fname}" "${PREFIX_MINIPIX}/bin"\
+ && rtl_is_newer "${PREFIX_NATIVE}/lib/${_fname}" "${PREFIX_MINIPIX}/bin/${_fname}"\
&& ! rtl_fileop cp_follow "${PREFIX_NATIVE}/lib/${_fname}" "${PREFIX_MINIPIX}/bin"; then
return 1;
fi;
@@ -56,7 +44,7 @@ pkg_dist_minipix_all() {
done;
for _fname in nano vim; do
if [ -e "${PREFIX}/minipix_dist/share/${_fname}" ]\
- && pkgp_dist_minipix_is_newer "${PREFIX}/minipix_dist/share/${_fname}" "${PREFIX_MINIPIX}/share"\
+ && rtl_is_newer "${PREFIX}/minipix_dist/share/${_fname}" "${PREFIX_MINIPIX}/share/${_fname}"\
&& ! rtl_fileop cp_follow "${PREFIX}/minipix_dist/share/${_fname}" "${PREFIX_MINIPIX}/share"; then
return 1;
fi;
@@ -76,7 +64,7 @@ pkg_dist_minipix_all() {
return 1;
fi;
if [ -e "${PREFIX_NATIVE}/${_dname}/${_fname}" ]\
- && pkgp_dist_minipix_is_newer "${PREFIX_NATIVE}/${_dname}/${_fname}" "${PREFIX_MINIPIX}/${_dname}"\
+ && rtl_is_newer "${PREFIX_NATIVE}/${_dname}/${_fname}" "${PREFIX_MINIPIX}/${_dname}/${_fname}"\
&& ! rtl_fileop cp_follow "${PREFIX_NATIVE}/${_dname}/${_fname}" "${PREFIX_MINIPIX}/${_dname}"; then
return 1;
fi;
diff --git a/dist/dist_zipdist.dist b/dist/dist_zipdist.dist
index 571dc0ce..eda7997c 100644
--- a/dist/dist_zipdist.dist
+++ b/dist/dist_zipdist.dist
@@ -8,7 +8,7 @@ pkg_dist_zipdist_all() {
echo "msg_pkg dist dist_zipdist Building deployable distribution ZIP archive..." >&3;
rtl_log_msg info "Finished building deployable distribution ZIP archive.";
for _pkg_name in $(cat "${_pkglist_fname}"); do
- if ! stat "${BUILD_WORKDIR}/${_pkg_name}-native-${DEFAULT_TARGET}" >/dev/null 2>&1; then
+ if [ ! -e "${BUILD_WORKDIR}/${_pkg_name}-native-${DEFAULT_TARGET}" ]; then
rtl_log_msg failexit "Error: missing package build directory for package \`${_pkg_name}'.";
fi;
done;
diff --git a/subr/build_init.subr b/subr/build_init.subr
index c5f91174..eeeaf60b 100644
--- a/subr/build_init.subr
+++ b/subr/build_init.subr
@@ -87,7 +87,7 @@ buildp_init_env() {
};
buildp_init_files() {
- local _log_last_fname="" _log_last_ts="" _rc=0; _status=""
+ local _log_last_fname="" _log_last_num=1 _rc=0; _status=""
if ! rtl_fileop mkdir "${BUILD_DLCACHEDIR}" "${BUILD_WORKDIR}"\
|| rtl_lmatch "${ARG_DIST}" "rpm" ","\
&& ! rtl_fileop mkdir "${PREFIX_RPM}"; then
@@ -98,12 +98,12 @@ buildp_init_files() {
_rc=1; _status="Error: failed to clean environment.";
elif ! rtl_check_path_vars "${DEFAULT_CHECK_PATH_VARS}"; then
_rc=1; _status="${_status}";
- else
- touch "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";
+ else touch "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";
if [ -e "${DEFAULT_BUILD_LOG_FNAME}" ]; then
- _log_last_ts="$(stat -c %Y "${DEFAULT_BUILD_LOG_FNAME}")";
- _log_last_ts="$(awk 'BEGIN {printf(strftime("%Y-%m-%d-%H-%M-%S", '"${_log_last_ts}"'))}')";
- _log_last_fname="${DEFAULT_BUILD_LOG_FNAME}.${_log_last_ts}";
+ while [ -e "${DEFAULT_BUILD_LOG_FNAME}.${_log_last_num}" ]; do
+ : $((_log_last_num+=1));
+ done;
+ _log_last_fname="${DEFAULT_BUILD_LOG_FNAME}.${_log_last_num}";
rtl_fileop mv "${DEFAULT_BUILD_LOG_FNAME}" "${_log_last_fname}";
rtl_fileop ln_symbolic "${_log_last_fname}" "${DEFAULT_BUILD_LOG_LAST_FNAME}";
fi;
@@ -224,21 +224,20 @@ buildp_init_groups() {
buildp_init_prereqs() {
local _cmd="" _cmds_missing="" _rc=0; _status="";
for _cmd in \
- awk bunzip2 cat chmod cmake cp date find flock g++ \
- gcc git grep gunzip gzip hostname install kill \
- ln lzip make mkdir mkfifo mv paste patch perl \
- pgrep pkill printf readlink rm sed seq sha256sum \
- sort stat tail tar test touch tr wget xz zip; do
+ awk bunzip2 bzip2 cat chmod cmake cp date find flock \
+ g++ gcc git grep gunzip gzip hostname install kill \
+ ln lzip make mkdir mkfifo mktemp mv paste patch perl \
+ pgrep pkill printf readlink rm sed sha256sum sort \
+ tail tar test touch tr uniq wget xz zip; do
if ! which "${_cmd}" >/dev/null 2>&1; then
_cmds_missing="${_cmds_missing:+${_cmds_missing} }${_cmd}";
fi;
done;
if [ -n "${_cmds_missing}" ]; then
_rc=1; _status="Error: missing prerequisite package(s): ${_cmds_missing}";
- elif ! awk -V 2>/dev/null | grep -q "^GNU Awk "; then
- _rc=1; _status="Error: awk(1) in \$PATH must be GNU Awk.";
- elif ! sed --version 2>/dev/null | grep -q "^GNU sed "; then
- _rc=1; _status="Error: sed(1) in \$PATH must be GNU sed.";
+ elif ! (FNAME="$(mktemp)" && { trap "rm -f \"\${FNAME}\"" EXIT; \
+ sed -i'' -e '' "${FNAME}" >/dev/null 2>&1; }); then
+ _rc=1; _status="Error: sed(1) in \${PATH} does not support the \`-i' option.";
fi;
return "${_rc}";
};
@@ -256,20 +255,19 @@ buildp_init_vars() {
nt32) DEFAULT_TARGET="i686-nt32-midipix"; ;;
nt64) DEFAULT_TARGET="x86_64-nt64-midipix"; ;;
esac;
- if [ -e "/proc/cpuinfo" ]; then
- DEFAULT_BUILD_CPUS="$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo)";
+ if DEFAULT_BUILD_CPUS="$(rtl_get_cpu_count)"; then
if [ "${ARG_PARALLEL}" = "auto" ]\
&& [ "${DEFAULT_BUILD_CPUS}" -gt 1 ]; then
ARG_PARALLEL=$((${DEFAULT_BUILD_CPUS}/2));
fi;
+ rtl_fileop source_opt \
+ "${HOME}/midipix_build.vars" "${HOME}/.midipix_build.vars" \
+ ../midipix_build.vars ./midipix.env;
+ if [ -z "${PREFIX}" ]; then
+ _rc=1; _status="Error: \${PREFIX} empty or unset.";
+ fi;
fi;
- rtl_fileop source_opt \
- "${HOME}/midipix_build.vars" "${HOME}/.midipix_build.vars" \
- ../midipix_build.vars ./midipix.env;
- if [ -z "${PREFIX}" ]; then
- _rc=1; _status="Error: \${PREFIX} empty or unset.";
- fi; fi;
- return "${_rc}";
+ fi; return "${_rc}";
};
build_init() {
diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr
index f0c0a2b6..5274d3f3 100644
--- a/subr/ex_pkg_dispatch.subr
+++ b/subr/ex_pkg_dispatch.subr
@@ -129,8 +129,9 @@ exp_pkg_dispatch_packages() {
local _build_steps_default="${1}" _build_vars_default="${2}" _dispatch_fn="${3}" \
_group_name="${4}" _njobs_max="${5}" _pipe_path="${6}" _pkg_complete="${7}" \
_restart_at="${8}" _restart_recursive="${9}" _workdir="${10}" \
- _njob=0 _pkg_depends="" _pkg_name="";
- for _njob in $(seq 1 $((${_njobs_max}-${EXP_PKG_DISPATCH_NJOBS}))); do
+ _foundfl=0 _njob=0 _pkg_depends="" _pkg_name="";
+ while [ "${EXP_PKG_DISPATCH_NJOBS:-0}" -lt "${_njobs_max}" ]; do
+ _foundfl=0;
for _pkg_name in ${EXP_PKG_NAMES}; do
if ! rtl_lmatch "${_pkg_complete}" "${_pkg_name}"\
&& ! rtl_lmatch "${EX_PKG_DISPATCH_WAIT}" "${_pkg_name}"\
@@ -138,9 +139,12 @@ exp_pkg_dispatch_packages() {
exp_pkg_dispatch_package "${_build_steps_default}" \
"${_build_vars_default}" "${_dispatch_fn}" \
"${_group_name}" "${_pkg_name}" "${_restart_at}" \
- "${_workdir}"; break;
+ "${_workdir}"; _foundfl=1; break;
fi;
done;
+ if [ "${_foundfl:-0}" -eq 0 ]; then
+ break;
+ fi;
done;
};
diff --git a/subr/ex_pkg_env.subr b/subr/ex_pkg_env.subr
index 7b1483b7..b4e1810f 100644
--- a/subr/ex_pkg_env.subr
+++ b/subr/ex_pkg_env.subr
@@ -56,18 +56,20 @@ exp_pkg_env_set() {
_var_prefixes="$(rtl_toupper "DEFAULT DEFAULT_${PKG_BUILD_TYPE} ${_group_name}")";
for _vname in $(rtl_lfilter "${_build_vars_default}" BUILD_TYPE); do
if [ -n "${PKG_INHERIT_FROM}" ]; then
- rtl_set_vars _vars_set "${_vname}" \
- "$(rtl_lconcat "${_var_prefixes}" "$(rtl_toupper "PKG_${PKG_INHERIT_FROM} PKG_${_pkg_name}")")"
+ rtl_set_vars _vars_set "${_vname}" \
+ "$(rtl_lconcat "${_var_prefixes}" \
+ "$(rtl_toupper "PKG_${PKG_INHERIT_FROM} PKG_${_pkg_name}")")"
else
- rtl_set_vars _vars_set "${_vname}" \
- "$(rtl_lconcat "${_var_prefixes}" "$(rtl_toupper "PKG_${_pkg_name}")")";
+ rtl_set_vars _vars_set "${_vname}" \
+ "$(rtl_lconcat "${_var_prefixes}" \
+ "$(rtl_toupper "PKG_${_pkg_name}")")";
fi;
done;
rtl_push_IFS :; for _vname in ${PKG_ENV_VARS_EXTRA}; do
export "${_vname}";
done; rtl_pop_IFS;
- rtl_unset_vars $(rtl_lfilter \
- "$(set | awk -F= '/^PKG_/{print $1}' | sort)" \
+ rtl_unset_vars $(rtl_lfilter \
+ "$(set | sed -ne '/^PKG_[^=]*=/s/=.*$//p')" \
"${_vars_set}");
};
diff --git a/subr/pkg_install_files.subr b/subr/pkg_install_files.subr
index 362f4926..c555499b 100644
--- a/subr/pkg_install_files.subr
+++ b/subr/pkg_install_files.subr
@@ -13,9 +13,9 @@ pkgp_install_files() {
pkgp_install_files_pkgconfig() {
local _pc_path="";
for _pc_path in $(find "${PKG_DESTDIR}" -name \*.pc); do
- if grep -Eq '^libdir=[^$]+$' "${_pc_path}"\
- && ! sed -i"" -e '/^libdir=[^$]\+$/s/^libdir=\(.\+\)$/libdir=${exec_prefix}\1/' \
- -e '/^exec_prefix=$/s/^.*$/exec_prefix=${prefix}/' \
+ if [ -n "$(sed -ne '/^libdir=[^$]*$/p' "${_pc_path}")" ] \
+ && ! sed -i"" -e '/^libdir=[^$]*$/s/^libdir=\(.*\)$/libdir=${exec_prefix}\1/' \
+ -e '/^exec_prefix=$/s/^.*$/exec_prefix=${prefix}/' \
"${_pc_path}"; then
return 1;
fi;
diff --git a/subr/rtl_complex.subr b/subr/rtl_complex.subr
index 41f0b2b4..01e373ea 100644
--- a/subr/rtl_complex.subr
+++ b/subr/rtl_complex.subr
@@ -87,6 +87,21 @@ rtl_filter_vars() {
echo "${_vars}";
};
+rtl_get_cpu_count() {
+ local _line="" _ncpus=0 _rc=0 _sname="$(uname -s 2>/dev/null)"; _status="";
+ case "${_sname}" in
+ Linux) if [ ! -e "/proc/cpuinfo" ]; then
+ _rc=1; _status="Error: /proc/cpuinfo non-existent.";
+ else while read -r _line; do
+ if rtl_match "${_line}" "processor*:"; then
+ : $((_ncpus+=1));
+ fi;
+ done < /proc/cpuinfo; echo "${_ncpus}";
+ fi; ;;
+ *) _rc=1; _status="Error: unknown platform \`${_sname}'."; ;;
+ esac; return "${_rc}";
+};
+
rtl_get_var_unsafe() {
local _vname="";
if [ "x${1}" = "x-u" ]; then
@@ -109,6 +124,15 @@ rtl_head() {
echo "${_s}";
};
+rtl_is_newer() {
+ local _new_fname="${1}" _old_fname="${2}";
+ if [ -n "$(find -name "${_new_fname}" -newer "${_old_fname}" 2>/dev/null)" ]; then
+ return 0;
+ else
+ return 1;
+ fi;
+};
+
rtl_kill_tree() {
local _pid="${1}" _signal="${2:-TERM}" _pid_child="" _pids="";
if _pids="$(pgrep -P "${_pid}")"\
diff --git a/subr/rtl_string.subr b/subr/rtl_string.subr
index 2d529786..c30cfe8c 100644
--- a/subr/rtl_string.subr
+++ b/subr/rtl_string.subr
@@ -12,6 +12,15 @@ rtl_isnumber() {
return "${_rc}";
};
+rtl_match() {
+ local _s="${1}" _find="${2}";
+ if [ "${_s#${_find}}" != "${_s}" ]; then
+ return 0;
+ else
+ return 1;
+ fi;
+};
+
rtl_subst() {
local _s="${1}" _find="${2}" _replace="${3}" _prefix="" _s_new="";
while [ -n "${_s}" ]; do
diff --git a/vars/gdk.vars b/vars/gdk.vars
index 0aac8f8a..0274be8c 100644
--- a/vars/gdk.vars
+++ b/vars/gdk.vars
@@ -8,7 +8,7 @@ enable_gio_sniffing=yes"};
pkg_gdk_install_files_post() {
local _pc_path="";
for _pc_path in $(find "${PKG_DESTDIR}"/lib/pkgconfig -name \*.pc); do
- if ! sed -i"" -e '/^Requires:\s\+gobject-2.0$/s/^.*$/& gio-2.0/' "${_pc_path}"; then
+ if ! sed -i"" -e '/^Requires:[[:space:]]*gobject-2.0$/s/^.*$/& gio-2.0/' "${_pc_path}"; then
return 1;
fi;
done;
diff --git a/vars/glib.vars b/vars/glib.vars
index 55d97500..23b4ca7e 100644
--- a/vars/glib.vars
+++ b/vars/glib.vars
@@ -13,7 +13,7 @@ glib_cv_uscore=yes"};
pkg_glib_install_files_post() {
local _pc_path="";
for _pc_path in $(find "${PKG_DESTDIR}"/lib/pkgconfig -name \*.pc); do
- if ! sed -i"" -e '/^Libs:/s/^\(Libs:\s\+-L\${libdir}\)\s\+\(.\+\)$/\1 \2 -lffi -lpcre -lz/' "${_pc_path}"; then
+ if ! sed -i"" -e '/^Libs:/s/^\(Libs:[[:space:]]*-L\${libdir}\)[[:space:]]*\(.*\)$/\1 \2 -lffi -lpcre -lz/' "${_pc_path}"; then
return 1;
fi;
done;
diff --git a/vars/python2_host.vars b/vars/python2_host.vars
index 495d0b2f..0338eb61 100644
--- a/vars/python2_host.vars
+++ b/vars/python2_host.vars
@@ -7,7 +7,7 @@ pkg_python2_host_fetch_download() {
|| ! rtl_fileop rm "${PKG_BASE_DIR}/sbpython2"\
|| ! rtl_fetch_urls_git "${PKG_BASE_DIR}/build" "sbpython2=${DEFAULT_GITROOT}/python/sbpython2@main"\
|| ! rtl_fileop cp "../sbpython2/project/config/cfgdefs.sh" "../sbpython2/project/config/cfgdefs.sh.orig"\
- || ! sed -i"" -e"s/-ltinfo/&w/" -e"s/mb_ncurses_libs='\([^']\+\)'/mb_ncurses_libs='\1 -ltinfow'/" ../sbpython2/project/config/cfgdefs.sh\
+ || ! sed -i"" -e"s/-ltinfo/&w/" -e"s/mb_ncurses_libs='\([^']*\)'/mb_ncurses_libs='\1 -ltinfow'/" ../sbpython2/project/config/cfgdefs.sh\
|| ! sed -i"" -e'108a\
cfgtest_ldflags_append "-L$mb_prefix/lib"' "../sbpython2/project/config/cfgdefs.sh"\
|| ! sed -i"" '/^PYCOMPILE_CFLAGS.*+= -std=c99/a\
diff --git a/vars/python3_host.vars b/vars/python3_host.vars
index 55ec443a..07fe489f 100644
--- a/vars/python3_host.vars
+++ b/vars/python3_host.vars
@@ -7,7 +7,7 @@ pkg_python3_host_fetch_download() {
|| ! rtl_fileop rm "${PKG_BASE_DIR}/sbpython3"\
|| ! rtl_fetch_urls_git "${PKG_BASE_DIR}/build" "sbpython3=${DEFAULT_GITROOT}/python/sbpython3@main"\
|| ! rtl_fileop cp "../sbpython3/project/config/cfgdefs.sh" "../sbpython3/project/config/cfgdefs.sh.orig"\
- || ! sed -i"" -e"s/-ltinfo/&w/" -e"s/mb_ncurses_libs='\([^']\+\)'/mb_ncurses_libs='\1 -ltinfow'/" "../sbpython3/project/config/cfgdefs.sh"\
+ || ! sed -i"" -e"s/-ltinfo/&w/" -e"s/mb_ncurses_libs='\([^']*\)'/mb_ncurses_libs='\1 -ltinfow'/" "../sbpython3/project/config/cfgdefs.sh"\
|| ! sed -i"" -e'108a\
cfgtest_ldflags_append "-L$mb_prefix/lib"' "../sbpython3/project/config/cfgdefs.sh"\
|| ! sed -i"" '/^PYCOMPILE_CFLAGS.*+= -std=c99/a\