From d279a98da1aae886a4b4201122ce5614a185f008 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz Date: Jan 19 2019 15:28:07 +0000 Subject: etc/build.usage, subr/build_{args,checks}.subr: merges -c into -C as -C prefix. etc/build.usage, subr/build_{args,init}.subr: merges -[46N] into -F as ipv4|ipv6|offline. subr/ex_rtl_fetch.subr: honour ${{ARG_FETCH_FORCE,DEFAULT_GIT_ARGS}}. subr/pkg_install_strip.subr: correctly strip non-release build binaries. subr/pkg_install_strip.subr:pkg_install_strip(): honour ${ARG_DEBUG_MINIPIX}. vars/env.vars, subr/pkg_fetch_{download,git,wget}.subr: merges fetch_{git,wget} into fetch_download. vars/midipix.vars: adds ${DEFAULT_GIT_ARGS}. vars/{musl,python[23]{,_host}}.vars: updated concerning fetch_download. --- diff --git a/build.sh b/build.sh index cf32cb6..183367c 100755 --- a/build.sh +++ b/build.sh @@ -82,18 +82,6 @@ buildp_dispatch() { ex_rtl_log_env_vars "build" \ $(set | awk -F= '/^PKG_/{print $1}' | sort); fi; - if [ "${ARG_DEBUG_MINIPIX:-0}" -eq 1 ]\ - && [ "${_tgt_name}" = "dist_minipix" ]; then - PKG_BUILD_STEPS="$(ex_rtl_lfilter_not \ - "${PKG_BUILD_STEPS}" "strip")"; - elif [ "${BUILD}" = release ]; then - PKG_BUILD_STEPS="$(ex_rtl_lfilter_not \ - "${PKG_BUILD_STEPS}" "strip")"; - fi; - if [ "${ARG_OFFLINE:-0}" -eq 1 ]; then - PKG_BUILD_STEPS="$(ex_rtl_lfilter_not \ - "${PKG_BUILD_STEPS}" "fetch_git fetch_wget")"; - fi; if [ "${ARG_XTRACE:-0}" -eq 1 ]; then set -o xtrace; fi; ;; diff --git a/etc/build.usage b/etc/build.usage index bd77ae3..4a0a0d1 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -1,45 +1,45 @@ -usage: ./build.sh [-4|6] [-a nt32|nt64] [-b debug|release] [-c] [-C dir[,..]] - [-D kind[,..]] [-h] [-N] [-P [jobs]] [-r ALL[:step,..]] - [-r name[,..][:step,..]] [-R] [-v[v[v]]] [-x] - [--as-needed] [--debug-minipix] [[ ..]] - -4|-6 Force IPv[46] when downloading files. - -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. - -b debug|release Selects debug or release build; defaults to debug. - -c Clean ${PREFIX} before processing build scripts. - -C dir[,..] Clean build directory (build,) source directory (src,) and/or - destination directory (dest) after successful package builds. - -D kind[,..] Produce minimal midipix distribution directory (minipix,) package - tarballs (pkg,) RPM binary packages (rpm,) compressed and optionally - signed binary and source tarballs containing ${PREFIX} sans ${BUILD_WORKDIR} - (t{bz2,gz,xz},) and/or deployable distribution ZIP archive (zipdist.) - {t{bz2,gz,xz},zipdist} imply minipix. - -h Show this screen. - -N Offline mode: no {wget,git-{clone,pull}}(1) calls. - -P [jobs] Enables parallelisation at target-level, whenever applicable. - The maximum count of jobs defaults to the number of logical - processors on the host system. - If -R is not specified and at least one (1) package fails to build, - all remaining package builds will be forcibly aborted for convenience. - -r ALL[:step,..] - -r name[,..][:step,..] Restart all packages/the specified comma-separated package(s) - completely or at optionally specified comma-separated step(s). - Currently defined steps are: - fetch_wget, fetch_git, fetch_extract, - configure_patch_pre, configure_autotools, configure_patch, - configure, build, install_subdirs, install_make, - install_files, install_libs, install_pkgconfig, install_purge_la, - install_strip, install, and install_rpm. - -R Ignore build failures, skip printing package logs, and continue - building (relaxed mode.) - -v[v[v]] Be verbose; -vv: always print package logs; -vvv: logs fileops. - -x Set xtrace during package builds; implies -vv. - --as-needed Don't build unless the midipix_build repository has received new commits. - --debug-minipix Don't strip(1) minipix binaries to facilitate debugging minipix. - [ ..] One of: - host or host_tools, host_tools_deps, host_tools_rpm, host_toolchain_deps, host_toolchain, host_toolchain_mingw32, - native or native_tools, native_toolchain_deps, native_toolchain, native_toolchain_mingw32, native_runtime, - packages_deps or host_packages_deps, native_packages_deps, native_packages_deps_x11, - packages or native_packages. +usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] + [-F ipv4|ipv6|offline] [-h] [-P [jobs]] [-r ALL|name[,..][:step,..]] + [-R] [-v[v[v]]] [-x] [--as-needed] [--debug-minipix] [[ ..]] + -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. + -b debug|release Selects debug or release build; defaults to debug. + -C dir[,..] Clean build directory (build,) ${PREFIX} before processing build + scripts (prefix,) source directory (src,) and/or destination directory + (dest) after successful package builds. + -D kind[,..] Produce minimal midipix distribution directory (minipix,) package + tarballs (pkg,) RPM binary packages (rpm,) compressed and optionally + signed binary and source tarballs containing ${PREFIX} sans ${BUILD_WORKDIR} + (t{bz2,gz,xz},) and/or deployable distribution ZIP archive (zipdist.) + {t{bz2,gz,xz},zipdist} imply minipix. + -F ipv4|ipv6|offline + Force IPv4 (ipv4) or IPv6 (ipv6) when downloading package archives + and/or Git repositories or don't download either at all (offline.) + -h Show this screen. + -P [jobs] Enables parallelisation at target-level, whenever applicable. + The maximum count of jobs defaults to the number of logical + processors on the host system. + If -R is not specified and at least one (1) package fails to build, + all remaining package builds will be forcibly aborted for convenience. + -r ALL|name[,..][:step,..] + Restart all packages/the specified comma-separated package(s) + completely or at optionally specified comma-separated step(s). + Currently defined steps are: + fetch_wget, fetch_git, fetch_extract, + configure_patch_pre, configure_autotools, configure_patch, + configure, build, install_subdirs, install_make, + install_files, install_libs, install_pkgconfig, install_purge_la, + install_strip, install, and install_rpm. + -R Ignore build failures, skip printing package logs, and continue + building (relaxed mode.) + -v[v[v]] Be verbose; -vv: always print package logs; -vvv: logs fileops. + -x Set xtrace during package builds; implies -vv. + --as-needed Don't build unless the midipix_build repository has received new commits. + --debug-minipix Don't strip(1) minipix binaries to facilitate debugging minipix. + [ ..] One of: + host or host_tools, host_tools_deps, host_tools_rpm, host_toolchain_deps, host_toolchain, host_toolchain_mingw32, + native or native_tools, native_toolchain_deps, native_toolchain, native_toolchain_mingw32, native_runtime, + packages_deps or host_packages_deps, native_packages_deps, native_packages_deps_x11, + packages or native_packages. ${HOME}/midipix_build.vars, ${HOME}/.midipix_build.vars, and/or ../midipix_build.vars will be sourced if present. @@ -50,5 +50,5 @@ usage: ./build.sh [-4|6] [-a nt32|nt64] [-b debug|release] [-c] [-C dir[,..]] ./build.sh -r coreutils:configure,build,install Restart the configure, build, and install steps of the coreutils build. - ./build.sh -c -r ALL DEFAULT_GITROOT_HEAD=... + ./build.sh -C prefix -r ALL DEFAULT_GITROOT_HEAD=... Clean ${PREFIX} and forcibly rebuild everything. diff --git a/subr/build_args.subr b/subr/build_args.subr index 2f18a5d..7f84414 100644 --- a/subr/build_args.subr +++ b/subr/build_args.subr @@ -4,14 +4,11 @@ BUILD_ARGS_SPEC=" ARCH:arg:-a: - ARG_IPV4_ONLY:-4: - ARG_IPV6_ONLY:-6: ARG_AS_NEEDED:--as-needed: - ARG_CLEAN:-c: ARG_CLEAN_BUILDS:arg:-C: ARG_DEBUG_MINIPIX:--debug-minipix: ARG_DIST:arg:-D: - ARG_OFFLINE:-N: + ARG_FETCH_FORCE:-F: ARG_PARALLEL:optarg:-P:auto ARG_RELAXED:-R: ARG_RESTART:arg:-r: diff --git a/subr/build_checks.subr b/subr/build_checks.subr index b0ba88b..1955d58 100644 --- a/subr/build_checks.subr +++ b/subr/build_checks.subr @@ -33,8 +33,8 @@ build_checks() { if [ ${_exit:-0} = 1 ]; then exit 1; fi; - if [ ${ARG_CLEAN:-0} -eq 1 ]; then - ex_rtl_log_msg info "-c specified, cleaning prefix..."; + if ex_rtl_lmatch "${ARG_CLEAN_BUILDS}" , prefix; then + ex_rtl_log_msg info "-C prefix specified, cleaning prefix..."; for _pname in ${DEFAULT_CLEAR_PREFIX_PATHS}; do ex_rtl_fileop rm ${PREFIX}/${_pname}; done; diff --git a/subr/build_init.subr b/subr/build_init.subr index 34fa6b6..c7ec7d4 100644 --- a/subr/build_init.subr +++ b/subr/build_init.subr @@ -40,9 +40,11 @@ build_init() { exit 0; fi; export PATH="${PREFIX}/bin${PATH:+:${PATH}}"; - if [ ${ARG_IPV4_ONLY:-0} -eq 1 ]; then + if [ "${ARG_FETCH_FORCE}" = "ipv4" ]; then + DEFAULT_GIT_ARGS="-4${DEFAULT_GIT_ARGS:+ ${DEFAULT_GIT_ARGS}}"; DEFAULT_WGET_ARGS="-4${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}"; - elif [ ${ARG_IPV6_ONLY:-0} -eq 1 ]; then + elif [ "${ARG_FETCH_FORCE}" = "ipv6" ]; then + DEFAULT_GIT_ARGS="-6${DEFAULT_GIT_ARGS:+ ${DEFAULT_GIT_ARGS}}"; DEFAULT_WGET_ARGS="-6${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}"; fi; _env_vars="$(export | sed -e 's/^export //' -e 's/=.*$//')"; diff --git a/subr/ex_rtl_fetch.subr b/subr/ex_rtl_fetch.subr index 5b06346..2468fb6 100644 --- a/subr/ex_rtl_fetch.subr +++ b/subr/ex_rtl_fetch.subr @@ -7,9 +7,9 @@ exp_rtl_fetch_url_git() { _oldpwd=""; if [ -e "${BUILD_DLCACHEDIR}/${_subdir}" ]; then (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ - git pull origin "${_branch:-main}"); + git pull ${DEFAULT_GIT_ARGS} origin "${_branch:-main}"); else - git clone "${_url}" "${BUILD_DLCACHEDIR}/${_subdir}"; + git clone ${DEFAULT_GIT_ARGS} "${_url}" "${BUILD_DLCACHEDIR}/${_subdir}"; if [ -n "${_branch}" ]; then (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ git checkout "${_branch}"); @@ -24,6 +24,9 @@ exp_rtl_fetch_url_git() { ex_rtl_fetch_urls_git() { local _tgtdir="" _url_spec="" _subdir="" _url="" _git_branch=""; _tgtdir="${1}"; shift; + if [ "${ARG_FETCH_FORCE}" = "offline" ]; then + return 0; + fi; for _url_spec in "${@}"; do _subdir="${_url_spec%=*}"; _url="${_url_spec#*=}"; @@ -39,6 +42,9 @@ ex_rtl_fetch_urls_git() { # N.B. URLs ($1) may contain `?' or '&' characters. ex_rtl_fetch_url_wget() { local _url="${1}" _sha256sum_src="${2}" _sha256sum_dst=""; + if [ "${ARG_FETCH_FORCE}" = "offline" ]; then + return 0; + fi; if [ -z "${3}" ]; then _url_dst="${BUILD_DLCACHEDIR}/$(ex_rtl_basename "${_url}")"; else diff --git a/subr/pkg_fetch_download.subr b/subr/pkg_fetch_download.subr new file mode 100644 index 0000000..5774d2e --- /dev/null +++ b/subr/pkg_fetch_download.subr @@ -0,0 +1,14 @@ +# +# set -o errexit -o noglob are assumed. +# + +pkg_fetch_download() { + if [ -n "${PKG_URL}" ]; then + ex_rtl_fetch_url_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${PKG_FNAME}"; + fi; + if [ -n "${PKG_URLS_GIT}" ]; then + ex_rtl_fetch_urls_git "${PKG_BASE_DIR}" ${PKG_URLS_GIT}; + fi; +}; + +# vim:filetype=sh diff --git a/subr/pkg_fetch_git.subr b/subr/pkg_fetch_git.subr deleted file mode 100644 index 67c0545..0000000 --- a/subr/pkg_fetch_git.subr +++ /dev/null @@ -1,11 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pkg_fetch_git() { - if [ -n "${PKG_URLS_GIT}" ]; then - ex_rtl_fetch_urls_git "${PKG_BASE_DIR}" ${PKG_URLS_GIT}; - fi; -}; - -# vim:filetype=sh diff --git a/subr/pkg_fetch_wget.subr b/subr/pkg_fetch_wget.subr deleted file mode 100644 index 56fe79d..0000000 --- a/subr/pkg_fetch_wget.subr +++ /dev/null @@ -1,11 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pkg_fetch_wget() { - if [ -n "${PKG_URL}" ]; then - ex_rtl_fetch_url_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${PKG_FNAME}"; - fi; -}; - -# vim:filetype=sh diff --git a/subr/pkg_install_strip.subr b/subr/pkg_install_strip.subr index 2709e77..5b34d70 100644 --- a/subr/pkg_install_strip.subr +++ b/subr/pkg_install_strip.subr @@ -2,19 +2,23 @@ # set -o errexit -o noglob are assumed. # -pkg_strip() { - local _tree_root="${PKG_DESTDIR}/bin" _bin_path=""; - if [ ! -e "${_tree_root}" ]; then - return; - fi; - for _bin_path in $(find "${_tree_root}" -perm /a=x \ - \( -type f -or -type l \)); do - if objdump -sj .debug_info "${_bin_path}" >/dev/null 2>&1; then - ex_rtl_log_msg info "Stripping ${_bin_path}..."; - ex_rtl_log_msg vnfo "${PKG_TARGET}-strip ${_bin_path}"; - ${PKG_TARGET}-strip ${_bin_path}; +pkg_install_strip() { + local _tree_root="${PKG_DESTDIR}" _bin_path=""; + if [ -e "${_tree_root}" ]\ + && [ "${BUILD}" != release ]; then + if [ "${PKG_NAME%_minipix}" != "${PKG_NAME}" ]\ + && [ "${ARG_DEBUG_MINIPIX:-0}" -eq 1 ]; then + return; fi; - done; + for _bin_path in $(find "${_tree_root}" -perm /a=x \ + \( -type f -or -type l \)); do + if objdump -sj .debug_info "${_bin_path}" >/dev/null 2>&1; then + ex_rtl_log_msg info "Stripping ${_bin_path}..."; + ex_rtl_log_msg vnfo "${PKG_TARGET}-strip ${_bin_path}"; + ${PKG_TARGET}-strip ${_bin_path}; + fi; + done; + fi; }; # vim:filetype=sh diff --git a/vars/env.vars b/vars/env.vars index 1f1c7f1..7e7b6d5 100644 --- a/vars/env.vars +++ b/vars/env.vars @@ -1,5 +1,5 @@ DEFAULT_BUILD_STEPS=" - fetch_wget fetch_git fetch_extract fetch \ + fetch_download fetch_extract \ configure_patch_pre configure_autotools configure_patch configure \ build \ install_subdirs install_make install_files install_libs \ diff --git a/vars/midipix.vars b/vars/midipix.vars index 55df1d7..471670c 100644 --- a/vars/midipix.vars +++ b/vars/midipix.vars @@ -51,6 +51,7 @@ : ${DEFAULT_GITROOT_HEAD:=git://midipix.org}; : ${DEFAULT_MAKE_INSTALL_VNAME:=DESTDIR}; : ${DEFAULT_MAKEFLAGS_BUILD:=-j${DEFAULT_BUILD_CPUS}}; +: ${DEFAULT_GIT_ARGS:=""}; : ${DEFAULT_WGET_ARGS:="--no-check-certificate"}; # Target-relative defaults diff --git a/vars/musl.vars b/vars/musl.vars index 97ee5cc..5b2b984 100644 --- a/vars/musl.vars +++ b/vars/musl.vars @@ -2,22 +2,22 @@ # set -o errexit -o noglob are assumed. # -pkgp_mmglue_fetch_git() { +pkgp_mmglue_fetch_download() { ex_rtl_fileop rm "${PKG_BASE_DIR}/mmglue"; ex_rtl_fetch_urls_git "${PKG_BASE_DIR}/build" "mmglue=${DEFAULT_GITROOT}/mmglue@main"; - ex_pkg_state_set "${PKG_NAME}" fetch -extract; + ex_pkg_state_set "${PKG_NAME}" fetch_download -fetch_extract; }; -pkg_musl_no_complex_host_fetch_git() { - pkgp_mmglue_fetch_git -} +pkg_musl_full_fetch_download() { + pkgp_mmglue_fetch_download; +}; -pkg_musl_full_host_fetch_git() { - pkgp_mmglue_fetch_git -} +pkg_musl_full_host_fetch_download() { + pkgp_mmglue_fetch_download; +}; -pkg_musl_full_fetch_git() { - pkgp_mmglue_fetch_git -} +pkg_musl_no_complex_host_fetch_download() { + pkgp_mmglue_fetch_download; +}; # vim:filetype=sh diff --git a/vars/python2.vars b/vars/python2.vars index aee9d6c..6e13843 100644 --- a/vars/python2.vars +++ b/vars/python2.vars @@ -2,10 +2,10 @@ # set -o errexit -o noglob are assumed. # -pkg_python2_fetch_git() { +pkg_python2_fetch_download() { ex_rtl_fileop rm "${PKG_BASE_DIR}/sbpython2"; ex_rtl_fetch_urls_git "${PKG_BASE_DIR}/build" "sbpython2=${DEFAULT_GITROOT}/python/sbpython2@main"; - ex_pkg_state_set "${PKG_NAME}" fetch -extract; + ex_pkg_state_set "${PKG_NAME}" fetch_download -fetch_extract; }; # vim:filetype=sh diff --git a/vars/python2_host.vars b/vars/python2_host.vars index 99f7963..c6343f2 100644 --- a/vars/python2_host.vars +++ b/vars/python2_host.vars @@ -2,10 +2,10 @@ # set -o errexit -o noglob are assumed. # -pkg_python2_host_fetch_git() { +pkg_python2_host_fetch_download() { ex_rtl_fileop rm "${PKG_BASE_DIR}/sbpython2"; ex_rtl_fetch_urls_git "${PKG_BASE_DIR}/build" "sbpython2=${DEFAULT_GITROOT}/python/sbpython2@main"; - ex_pkg_state_set "${PKG_NAME}" fetch -extract; + ex_pkg_state_set "${PKG_NAME}" fetch_download -fetch_extract; }; # vim:filetype=sh diff --git a/vars/python3.vars b/vars/python3.vars index da82bfc..100a1b0 100644 --- a/vars/python3.vars +++ b/vars/python3.vars @@ -2,10 +2,10 @@ # set -o errexit -o noglob are assumed. # -pkg_python3_fetch_git() { +pkg_python3_fetch_download() { ex_rtl_fileop rm "${PKG_BASE_DIR}/sbpython3"; ex_rtl_fetch_urls_git "${PKG_BASE_DIR}/build" "sbpython3=${DEFAULT_GITROOT}/python/sbpython3@main"; - ex_pkg_state_set "${PKG_NAME}" fetch -extract; + ex_pkg_state_set "${PKG_NAME}" fetch_download -fetch_extract; }; # vim:filetype=sh diff --git a/vars/python3_host.vars b/vars/python3_host.vars index f0063ef..f2c7271 100644 --- a/vars/python3_host.vars +++ b/vars/python3_host.vars @@ -2,10 +2,10 @@ # set -o errexit -o noglob are assumed. # -pkg_python3_host_fetch_git() { +pkg_python3_host_fetch_download() { ex_rtl_fileop rm "${PKG_BASE_DIR}/sbpython3"; ex_rtl_fetch_urls_git "${PKG_BASE_DIR}/build" "sbpython3=${DEFAULT_GITROOT}/python/sbpython3@main"; - ex_pkg_state_set "${PKG_NAME}" fetch -extract; + ex_pkg_state_set "${PKG_NAME}" fetch_download -fetch_extract; }; # vim:filetype=sh