From 938c5c45b976387ceea5792b0ce9717dd97667eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luc=C3=ADa=20Andrea=20Illanes=20Albornoz?= Date: Mon, 27 Mar 2023 08:04:23 +0200 Subject: Generalise subr.pkg/*.subr code. --- etc/README.md | 5 +- etc/build.usage | 2 +- midipix.env | 2 +- subr.ex/ex_pkg_run.subr | 400 ---------------------------------------- subr.ex/ex_rtl.subr | 204 ++++++++++++++++++++ subr.ex/ex_rtl_midipix.subr | 92 +++++++++ subr.ex/ex_rtl_run.subr | 400 ++++++++++++++++++++++++++++++++++++++++ subr.pkg/pkg_build.subr | 2 +- subr.pkg/pkg_build_clean.subr | 2 +- subr.pkg/pkg_configure.subr | 4 +- subr.pkg/pkg_install_files.subr | 97 +++------- subr.pkg/pkg_install_libs.subr | 95 ---------- subr.pkg/pkg_install_make.subr | 2 +- subr.pkg/pkg_install_rpm.subr | 68 ++----- subr.rtl/rtl_filepath.subr | 59 +++++- subr.rtl/rtl_platform.subr | 1 + 16 files changed, 808 insertions(+), 627 deletions(-) delete mode 100644 subr.ex/ex_pkg_run.subr create mode 100644 subr.ex/ex_rtl.subr create mode 100644 subr.ex/ex_rtl_midipix.subr create mode 100644 subr.ex/ex_rtl_run.subr delete mode 100644 subr.pkg/pkg_install_libs.subr diff --git a/etc/README.md b/etc/README.md index 6c6c80c0..1d0acfe9 100644 --- a/etc/README.md +++ b/etc/README.md @@ -447,7 +447,7 @@ package build completion corresponds to the pseudo-build step ``finish``. | install_subdirs | Create default directory hierarchy in ``${PKG_DESTDIR}``, optionally amended w/ ``${PKG_INSTALL_FILES_DESTDIR_EXTRA}`` | | install_make | Call ``make(1)`` w/ ``${PKG_INSTALL_TARGET}`` (defaults to ``install``) and installation-time set of make variables | | install_files | Install ``${PKG_INSTALL_FILES}`` and/or ``${PKG_INSTALL_FILES_V2}``, fix directory and file mode bits within ``${PKG_DESTDIR}`` and optionally ``${PKG_DESTDIR_HOST}``, ``pkgconf(1)`` package files, and/or stripped binaries within ``${PKG_DESTDIR}`` | -| install_libs | Purge libtool ``.la`` files and install shared objects within ``${PKG_DESTDIR}`` w/ ``perk`` and corresponding symbolic links | +| | Purge libtool ``.la`` files and install shared objects within ``${PKG_DESTDIR}`` w/ ``perk`` and corresponding symbolic links | | install | Install into ``${PKG_PREFIX}``, and optionally ``${PKG_DESTDIR_HOST}`` into ``${PREFIX}``, under mutex, and add package to ``${PREFIX}/pkglist.${PKG_BUILD_TYPE}`` (unless inhibited) | | install_rpm | Build package RPM w/ auto-generated specifiation file based on ``etc/package.spec`` beneath ``${PREFIX_RPM}`` | | clean | Clean ``${PKG_BUILD_DIR}`` and/or ``${PKG_DESTDIR}`` and/or ``${PKG_DESTDIR_HOST}`` and/or ``${PKG_BASE_DIR}/${PKG_SUBDIR}`` as per ``-C build,dest,src``, resp., if any | @@ -865,8 +865,7 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[ fetch_clean, fetch_download, fetch_extract, configure_clean, configure_patch_pre, configure_autotools, configure_patch, configure, build_clean, build, install_clean, install_subdirs, - install_make, install_files, install_libs, install, install_rpm, - and clean. + install_make, install_files, install, install_rpm, and clean. Additionally, the following virtual steps are provided: @fetch, @configure, @build, @install, @clean, and finish. diff --git a/etc/build.usage b/etc/build.usage index 5c7bd5ec..26a2b297 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -48,7 +48,7 @@ fetch_clean, fetch_download, fetch_extract, configure_clean, configure_patch_pre, configure_autotools, configure_patch, configure, build_clean, build, install_clean, install_subdirs, - install_make, install_files, install_libs, install, install_rpm, + install_make, install_files, install, install_rpm, and clean. Additionally, the following virtual steps are provided: diff --git a/midipix.env b/midipix.env index a1a1edec..06bb55f1 100644 --- a/midipix.env +++ b/midipix.env @@ -16,7 +16,7 @@ DEFAULT_BUILD_STEPS=" \ fetch_clean fetch_download fetch_extract \ configure_clean configure_patch_pre configure_autotools configure_patch configure \ build_clean build \ - install_clean install_subdirs install_make install_files install_libs install install_rpm \ + install_clean install_subdirs install_make install_files install install_rpm \ clean \ finish"; DEFAULT_BUILD_VARS=" \ diff --git a/subr.ex/ex_pkg_run.subr b/subr.ex/ex_pkg_run.subr deleted file mode 100644 index 38f48f34..00000000 --- a/subr.ex/ex_pkg_run.subr +++ /dev/null @@ -1,400 +0,0 @@ -# -# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lucía Andrea Illanes Albornoz -# set +o errexit -o noglob -o nounset is assumed. -# -# Package {configure,make} command execution -# - -# -# ex_pkg_run_configure() - run configure script -# @_ar: ar(1) command name or pathname -# @_cc: C compiler command name or pathname -# @_configure: configure script command name or pathname -# @_cxx: C++ compiler command name or pathname -# @_ld: ld(1) command name or pathname -# @_libtool: libtool(1) command name or pathname or "none" -# @_pkg_config: pkg-config(1) command name or pathname -# @_python: python command name or pathname -# @_ranlib: ranlib(1) command name or pathname -# @--: (ignored) -# @_flags: configure script flags as a whitespace-separated list -# @_flags_extra: extra configure script flags as a whitespace-separated likst -# @_flags_list: configure script flags as a :-separated list -# @_flags_extra_list: extra configure script flags as a :-separated list -# @--: (ignored) -# @_cflags: $CFLAGS -# @_cflags_extra: extra $CFLAGS -# @_cppflags: $CPPFLAGS -# @_cppflags_extra: extra $CPPFLAGS -# @_cxxflags: $CXXFLAGS -# @_cxxflags_extra: extra $CXXFLAGS -# @_ldflags: $LDFLAGS -# @_ldflags_extra: extra $LDFLAGS -# @_pkg_config_libdir: pkg-config(1) search directory -# -# Returns: zero (0) on success, non-zero (>0) on failure -# -ex_pkg_run_configure() { - local _eprc_ar="${1}" _eprc_cc="${2}" _eprc_configure="${3}" _eprc_cxx="${4}" _eprc_ld="${5}" \ - _eprc_libtool="${6}" _eprc_pkg_config="${7}" _eprc_python="${8}" _eprc_ranlib="${9}" \ - _eprc_ignored="${10}" \ - _eprc_flags="${11}" _eprc_flags_extra="${12}" \ - _eprc_flags_list="${13}" _eprc_flags_extra_list="${14}" \ - _eprc_ignored="${15}" \ - _eprc_cflags="${16}" _eprc_cflags_extra="${17}" _eprc_cppflags="${18}" \ - _eprc_cppflags_extra="${19}" _eprc_cxxflags="${20}" _eprc_cxxflags_extra="${21}" \ - _eprc_ldflags="${22}" _eprc_ldflags_extra="${23}" _eprc_pkg_config_libdir="${24}" \ - _eprc_rc=0; - - case "${_eprc_libtool:-}" in - none) _eprc_libtool=""; ;; - esac; - - [ "${_eprc_cflags_extra:+1}" = 1 ] && _eprc_cflags="${_eprc_cflags:+${_eprc_cflags} }${_eprc_cflags_extra}"; - [ "${_eprc_cppflags_extra:+1}" = 1 ] && _eprc_cppflags="${_eprc_cppflags:+${_eprc_cppflags} }${_eprc_cppflags_extra}"; - [ "${_eprc_cxxflags_extra:+1}" = 1 ] && _eprc_cxxflags="${_eprc_cxxflags:+${_eprc_cxxflags} }${_eprc_cxxflags_extra}"; - [ "${_eprc_ldflags_extra:+1}" = 1 ] && _eprc_ldflags="${_eprc_ldflags:+${_eprc_ldflags} }${_eprc_ldflags_extra}"; - -( - if [ "${_eprc_libtool:+1}" = 1 ]; then - export MAKE="make LIBTOOL=${_eprc_libtool}"; - fi; - - [ "${_eprc_ar:+1}" = 1 ] && export AR="${_eprc_ar}"; - [ "${_eprc_cc:+1}" = 1 ] && export CC="${_eprc_cc}"; - [ "${_eprc_cxx:+1}" = 1 ] && export CXX="${_eprc_cxx}"; - [ "${_eprc_ld:+1}" = 1 ] && export LD="${_eprc_ld}"; - [ "${_eprc_libtool:+1}" = 1 ] && export LIBTOOL="${_eprc_libtool}"; - [ "${_eprc_pkg_config:+1}" = 1 ] && export PKG_CONFIG="${_eprc_pkg_config}"; - [ "${_eprc_python:+1}" = 1 ] && export PYTHON="${_eprc_python}"; - [ "${_eprc_ranlib:+1}" = 1 ] && export RANLIB="${_eprc_ranlib}"; - - [ "${_eprc_cflags:+1}" = 1 ] && export CFLAGS="${_eprc_cflags}"; - [ "${_eprc_cppflags:+1}" = 1 ] && export CPPFLAGS="${_eprc_cppflags}"; - [ "${_eprc_cxxflags:+1}" = 1 ] && export CXXFLAGS="${_eprc_cxxflags}"; - [ "${_eprc_ldflags:+1}" = 1 ] && export LDFLAGS="${_eprc_ldflags}"; - [ "${_eprc_pkg_config_libdir:+1}" = 1 ] && export PKG_CONFIG_LIBDIR="${_eprc_pkg_config_libdir}"; - - if [ "${_eprc_flags_list:+1}" = 1 ]; then - rtl_run_cmdlineV ":" "${_eprc_configure}" \ - "${_eprc_flags_list}" \ - "${_eprc_flags_extra_list:-}" \ - ; - exit "${?}"; - elif [ "${_eprc_flags_extra_list:+1}" = 1 ]; then - rtl_run_cmdlineV ":" "${_eprc_configure}" \ - ${_eprc_flags:-} \ - "${_eprc_flags_extra_list:-}" \ - ; - exit "${?}"; - else - rtl_run_cmdlineV ":" "${_eprc_configure}" \ - ${_eprc_flags:-} \ - ${_eprc_flags_extra:-} \ - ; - exit "${?}"; - fi; -); - _eprc_rc="${?}"; - - return "${_eprc_rc}"; -}; - -# -# ex_pkg_run_configure_cmake() - run configure script -# @_ar: ar(1) command name or pathname -# @_cc: C compiler command name or pathname -# @_ccache: ccache(1) command name or pathname or "" -# @_cmake: CMake command name or pathname -# @_cxx: C++ compiler command name or pathname -# @_ld: ld(1) command name or pathname -# @_pkg_config: pkg-config(1) command name or pathname -# @_python: python command name or pathname -# @_ranlib: ranlib(1) command name or pathname -# @--: (ignored) -# @_build_type: CMake build type (host, cross, native) -# @_cmake_args: additional CMake arguments as a whitespace-separated list -# @_cmake_args_extra: additional CMake extra arguments as a whitespace-separated likst -# @_prefix: build prefix pathname -# @_subdir: CMake build directory pathname -# @_system_name: CMake system name -# @_system_processor: CMake system processor -# @--: (ignored) -# @_cflags: $CFLAGS -# @_cflags_extra: extra $CFLAGS -# @_cppflags: $CPPFLAGS -# @_cppflags_extra: extra $CPPFLAGS -# @_cxxflags: $CXXFLAGS -# @_cxxflags_extra: extra $CXXFLAGS -# @_ldflags: $LDFLAGS -# @_ldflags_extra: extra $LDFLAGS -# @_pkg_config_libdir: pkg-config(1) search directory -# -# Returns: zero (0) on success, non-zero (>0) on failure -# -ex_pkg_run_configure_cmake() { - local _eprcc_ar="${1}" _eprcc_cc="${2}" _eprcc_ccache="${3}" _eprcc_cmake="${4}" \ - _eprcc_cxx="${5}" _eprcc_ld="${6}" _eprcc_pkg_config="${7}" _eprcc_python="${8}" \ - _eprcc_ranlib="${9}" \ - _eprcc_ignored="${10}" \ - _eprcc_build_type="${11}" \ - _eprcc_cmake_args="${12}" _eprcc_cmake_args_extra="${13}" \ - _eprcc_prefix="${14}" _eprcc_subdir="${15}" \ - _eprcc_system_name="${16}" _eprcc_system_processor="${17}" \ - _eprcc_ignored="${18}" \ - _eprcc_cflags="${19}" _eprcc_cflags_extra="${20}" _eprcc_cppflags="${21}" \ - _eprcc_cppflags_extra="${22}" _eprcc_cxxflags="${23}" _eprcc_cxxflags_extra="${24}" \ - _eprcc_ldflags="${25}" _eprcc_ldflags_extra="${26}" _eprcc_pkg_config_libdir="${27}" \ - _eprcc_cmd_name="" _eprcc_cmake_args_auto="" _eprcc_rc=0 _eprcc_vname="" _eprcc_vval="" - - [ "${_eprcc_cflags_extra:+1}" = 1 ] && _eprcc_cflags="${_eprcc_cflags:+${_eprcc_cflags} }${_eprcc_cflags_extra}"; - [ "${_eprcc_cppflags_extra:+1}" = 1 ] && _eprcc_cppflags="${_eprcc_cppflags:+${_eprcc_cppflags} }${_eprcc_cppflags_extra}"; - [ "${_eprcc_cxxflags_extra:+1}" = 1 ] && _eprcc_cxxflags="${_eprcc_cxxflags:+${_eprcc_cxxflags} }${_eprcc_cxxflags_extra}"; - [ "${_eprcc_ldflags_extra:+1}" = 1 ] && _eprcc_ldflags="${_eprcc_ldflags:+${_eprcc_ldflags} }${_eprcc_ldflags_extra}"; - -( - [ "${_eprcc_pkg_config:+1}" = 1 ] && export PKG_CONFIG="${_eprcc_pkg_config}"; - [ "${_eprcc_pkg_config_libdir:+1}" = 1 ] && export PKG_CONFIG_LIBDIR="${_eprcc_pkg_config_libdir}"; - [ "${_eprcc_python:+1}" = 1 ] && export PYTHON="${_eprcc_python}"; - - for _eprcc_vname in ar cc cxx ld pkg_config ranlib; do - case "${_eprcc_vname}" in - cc|cxx) - _eprcc_vname="_eprcc_${_eprcc_vname}"; - if [ "${_eprcc_ccache:+1}" = 1 ]; then - eval ${_eprcc_vname}="\${${_eprcc_vname}#${_eprcc_ccache} }"; - fi; - ;; - - *) - _eprcc_vname="_eprcc_${_eprcc_vname}"; - ;; - esac; - - if eval [ '"${'"${_eprcc_vname}"':+1}"' = 1 ]\ - && eval [ '"${'"${_eprcc_vname}"'#/}"' = '"${'"${_eprcc_vname}"'}"' ]; then - eval _eprcc_cmd_name="\${${_eprcc_vname}% *}"; - eval _eprcc_vval="\${${_eprcc_vname}#* }"; - eval ${_eprcc_vname}='$(which "${_eprcc_cmd_name}")' || return 1; - fi; - done; - - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_AR=${_eprcc_ar}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_BUILD_TYPE=${_eprcc_build_type}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_C_COMPILER=${_eprcc_cc}" ":"; - if [ "${_eprcc_ccache:+1}" = 1 ]; then - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_C_COMPILER_LAUNCHER=${_eprcc_ccache}" ":"; - fi; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_C_FLAGS=${_eprcc_cflags}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_CPP_FLAGS=${_eprcc_cppflags}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_CXX_COMPILER=${_eprcc_cxx}" ":"; - if [ "${_eprcc_ccache:+1}" = 1 ]; then - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_CXX_COMPILER_LAUNCHER=${_eprcc_ccache}" ":"; - fi; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_CXX_FLAGS=${_eprcc_cxxflags}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_EXE_LINKER_FLAGS=${_eprcc_ldflags}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_FIND_ROOT_PATH=${_eprcc_prefix}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_INSTALL_PREFIX=" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_LINKER=${_eprcc_ld}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_MODULE_LINKER_FLAGS=${_eprcc_ldflags}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_RANLIB=${_eprcc_ranlib}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_SHARED_LINKER_FLAGS=${_eprcc_ldflags}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_SYSTEM_PROCESSOR=${_eprcc_system_processor}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DPKG_CONFIG_EXECUTABLE=${_eprcc_pkg_config}" ":"; - - case "${_eprcc_build_type}" in - native) - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_SYSROOT=${_eprcc_prefix}" ":"; - rtl_lconcat \$_eprcc_cmake_args_auto "-DCMAKE_SYSTEM_NAME=${_eprcc_system_name}" ":"; - ;; - esac; - - rtl_run_cmdlineV ":" "${_eprcc_cmake}" \ - "${_eprcc_cmake_args_auto}" \ - ${_eprcc_cmake_args:-} \ - ${_eprcc_cmake_args_extra:-} \ - "${_eprcc_subdir}"; - exit "${?}"; -); - _eprcc_rc="${?}"; - - return "${_eprcc_rc}"; -}; - -# -# ex_pkg_run_make() - run make(1) -# @_ar: ar(1) command name or pathname -# @_cc: C compiler command name or pathname -# @_cxx: C++ compiler command name or pathname -# @_ld: ld(1) command name or pathname -# @_libtool: libtool(1) command name or pathname or "none" -# @_make: make(1) command name or pathname -# @_pkg_config: pkg-config(1) command name or pathname -# @_ranlib: ranlib(1) command name or pathname -# @--: (ignored) -# @_set_ccfl: 1 if CC=... is to be passed to make(1), 0 if CC=... is not to be passed to make(1) -# @_subdir: make(1) -C argument -# @--: (ignored) -# @_makeflags: make(1) flags as a whitespace-separated list -# @_makeflags_extra: extra make(1) flags as a whitespace-separated likst -# @_makeflags_list: make(1) flags as a :-separated list -# @_makeflags_extra_list: extra make(1) flags as a :-separated list -# @_makeflags_loadavg: make(1) -l load argument -# @_makeflags_parallelise: make(1) -j jobs argument -# @_makeflags_verbosity: make(1) Makefile verbosity arguments or "none" -# @--: (ignored) -# @_cflags: $CFLAGS -# @_cflags_extra: extra $CFLAGS -# @_cppflags: $CPPFLAGS -# @_cppflags_extra: extra $CPPFLAGS -# @_cxxflags: $CXXFLAGS -# @_cxxflags_extra: extra $CXXFLAGS -# @_ldflags: $LDFLAGS -# @_ldflags_extra: extra $LDFLAGS -# @_pkg_config_libdir: pkg-config(1) search directory -# @--: (ignored) -# @_destdir_spec: DESTDIR=... specification -# @_target: make(1) target -# -# Returns: zero (0) on success, non-zero (>0) on failure -# -ex_pkg_run_make() { - local _eprm_ar="${1}" _eprm_cc="${2}" _eprm_cxx="${3}" _eprm_ld="${4}" \ - _eprm_libtool="${5}" _eprm_make="${6}" _eprm_pkg_config="${7}" _eprm_ranlib="${8}" \ - _eprm_ignored="${9}" \ - _eprm_set_ccfl="${10}" _eprm_subdir="${11}" \ - _eprm_ignored="${12}" \ - _eprm_makeflags="${13}" _eprm_makeflags_extra="${14}" _eprm_makeflags_list="${15}" \ - _eprm_makeflags_extra_list="${16}" _eprm_makeflags_loadavg="${17}" \ - _eprm_makeflags_parallelise="${18}" _eprm_makeflags_verbosity="${19}" \ - _eprm_ignored="${20}" \ - _eprm_cflags="${21}" _eprm_cflags_extra="${22}" _eprm_cppflags="${23}" \ - _eprm_cppflags_extra="${24}" _eprm_cxxflags="${25}" _eprm_cxxflags_extra="${26}" \ - _eprm_ldflags="${27}" _eprm_ldflags_extra="${28}" _eprm_pkg_config_libdir="${29}" \ - _eprm_ignored="${30}" \ - _eprm_destdir_spec="${31}" _eprm_target="${32}" \ - _eprm_rc=0; - - case "${_eprm_makeflags_loadavg:-}" in - none) _eprm_makeflags_loadavg=""; ;; - esac; - - case "${_eprm_libtool:-}" in - none) _eprm_libtool=""; ;; - esac; - - case "${_eprm_makeflags_verbosity}" in - none) _eprm_makeflags_verbosity=""; ;; - esac; - - case "${_eprm_set_ccfl}" in - 1) _eprm_set_ccfl="1"; ;; - *) _eprm_set_ccfl=""; ;; - esac; - -( - if [ "${_eprm_libtool:+1}" = 1 ]; then - export MAKE="make LIBTOOL=${_eprm_libtool}"; - fi; - - if [ "${_eprm_makeflags_list:+1}" = 1 ]; then - rtl_run_cmdlineV ":" "${_eprm_make}" \ - AR="${_eprm_ar}" \ - ${_eprm_set_ccfl:+CC="${_eprm_cc}"} \ - ${_eprm_set_ccfl:+CXX="${_eprm_cxx}"} \ - LD="${_eprm_ld}" \ - ${_eprm_libtool:+LIBTOOL="${_eprm_libtool}"} \ - ${_eprm_pkg_config:+PKG_CONFIG="${_eprm_pkg_config}"} \ - RANLIB="${_eprm_ranlib}" \ - \ - "${_eprm_makeflags_list}" \ - "${_eprm_makeflags_extra_list:-}" \ - ${_eprm_makeflags_loadavg:-} \ - ${_eprm_makeflags_parallelise:-} \ - ${_eprm_makeflags_verbosity} \ - \ - ${_eprm_cflags:+CFLAGS="${_eprm_cflags}"} \ - ${_eprm_cflags_extra:+CFLAGS+="${_eprm_cflags_extra}"} \ - ${_eprm_cppflags:+CPPFLAGS="${_eprm_cppflags}"} \ - ${_eprm_cppflags_extra:+CPPFLAGS+="${_eprm_cppflags_extra}"} \ - ${_eprm_cxxflags:+CXXFLAGS="${_eprm_cxxflags}"} \ - ${_eprm_cxxflags_extra:+CXXFLAGS+="${_eprm_cxxflags_extra}"} \ - ${_eprm_ldflags:+LDFLAGS="${_eprm_ldflags}"} \ - ${_eprm_ldflags_extra:+LDFLAGS+="${_eprm_ldflags_extra}"} \ - ${_eprm_pkg_config_libdir:+PKG_CONFIG_LIBDIR="${_eprm_pkg_config_libdir}"} \ - \ - ${_eprm_subdir:+-C "${_eprm_subdir}"} \ - ${_eprm_destdir_spec:+"${_eprm_destdir_spec}"} \ - ${_eprm_target:+"${_eprm_target}"} \ - ; - exit "${?}"; - elif [ "${_eprm_makeflags_extra_list:+1}" = 1 ]; then - rtl_run_cmdlineV ":" "${_eprm_make}" \ - AR="${_eprm_ar}" \ - ${_eprm_set_ccfl:+CC="${_eprm_cc}"} \ - ${_eprm_set_ccfl:+CXX="${_eprm_cxx}"} \ - LD="${_eprm_ld}" \ - ${_eprm_libtool:+LIBTOOL="${_eprm_libtool}"} \ - ${_eprm_pkg_config:+PKG_CONFIG="${_eprm_pkg_config}"} \ - RANLIB="${_eprm_ranlib}" \ - \ - ${_eprm_makeflags:-} \ - "${_eprm_makeflags_extra_list}" \ - ${_eprm_makeflags_loadavg:-} \ - ${_eprm_makeflags_parallelise:-} \ - ${_eprm_makeflags_verbosity} \ - \ - ${_eprm_cflags:+CFLAGS="${_eprm_cflags}"} \ - ${_eprm_cflags_extra:+CFLAGS+="${_eprm_cflags_extra}"} \ - ${_eprm_cppflags:+CPPFLAGS="${_eprm_cppflags}"} \ - ${_eprm_cppflags_extra:+CPPFLAGS+="${_eprm_cppflags_extra}"} \ - ${_eprm_cxxflags:+CXXFLAGS="${_eprm_cxxflags}"} \ - ${_eprm_cxxflags_extra:+CXXFLAGS+="${_eprm_cxxflags_extra}"} \ - ${_eprm_ldflags:+LDFLAGS="${_eprm_ldflags}"} \ - ${_eprm_ldflags_extra:+LDFLAGS+="${_eprm_ldflags_extra}"} \ - ${_eprm_pkg_config_libdir:+PKG_CONFIG_LIBDIR="${_eprm_pkg_config_libdir}"} \ - \ - ${_eprm_subdir:+-C "${_eprm_subdir}"} \ - ${_eprm_destdir_spec:+"${_eprm_destdir_spec}"} \ - ${_eprm_target:+"${_eprm_target}"} \ - ; - exit "${?}"; - else - rtl_run_cmdlineV ":" "${_eprm_make}" \ - AR="${_eprm_ar}" \ - ${_eprm_set_ccfl:+CC="${_eprm_cc}"} \ - ${_eprm_set_ccfl:+CXX="${_eprm_cxx}"} \ - LD="${_eprm_ld}" \ - ${_eprm_libtool:+LIBTOOL="${_eprm_libtool}"} \ - ${_eprm_pkg_config:+PKG_CONFIG="${_eprm_pkg_config}"} \ - RANLIB="${_eprm_ranlib}" \ - \ - ${_eprm_makeflags:-} \ - ${_eprm_makeflags_extra:-} \ - ${_eprm_makeflags_loadavg:-} \ - ${_eprm_makeflags_parallelise:-} \ - ${_eprm_makeflags_verbosity} \ - \ - ${_eprm_cflags:+CFLAGS="${_eprm_cflags}"} \ - ${_eprm_cflags_extra:+CFLAGS+="${_eprm_cflags_extra}"} \ - ${_eprm_cppflags:+CPPFLAGS="${_eprm_cppflags}"} \ - ${_eprm_cppflags_extra:+CPPFLAGS+="${_eprm_cppflags_extra}"} \ - ${_eprm_cxxflags:+CXXFLAGS="${_eprm_cxxflags}"} \ - ${_eprm_cxxflags_extra:+CXXFLAGS+="${_eprm_cxxflags_extra}"} \ - ${_eprm_ldflags:+LDFLAGS="${_eprm_ldflags}"} \ - ${_eprm_ldflags_extra:+LDFLAGS+="${_eprm_ldflags_extra}"} \ - ${_eprm_pkg_config_libdir:+PKG_CONFIG_LIBDIR="${_eprm_pkg_config_libdir}"} \ - \ - ${_eprm_subdir:+-C "${_eprm_subdir}"} \ - ${_eprm_destdir_spec:+"${_eprm_destdir_spec}"} \ - ${_eprm_target:+"${_eprm_target}"} \ - ; - exit "${?}"; - fi; -); - _eprm_rc="${?}"; - - return "${_eprm_rc}"; -}; - -# vim:filetype=sh textwidth=0 diff --git a/subr.ex/ex_rtl.subr b/subr.ex/ex_rtl.subr new file mode 100644 index 00000000..1da1b8ef --- /dev/null +++ b/subr.ex/ex_rtl.subr @@ -0,0 +1,204 @@ +# +# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lucía Andrea Illanes Albornoz +# set +o errexit -o noglob -o nounset is assumed. +# +# + +# +# ex_rtl_build_rpm() - build RPM package +# @_destdir: package destination directory +# @_name: package name +# @_rpms_dname: RPMs directory pathname +# @_spec_fname: RPM .spec file pathname +# @_spec_fname_tgt: target package RPM .spec file pathname +# @_tmp_dname: temporary files directory pathname +# @_topdir: package top directory +# @_url: package URL +# @_version: package version +# @_version_rpm: package RPM version +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +ex_rtl_build_rpm() { + local _erbr_destdir="${1}" _erbr_name="${2}" _erbr_rpms_dname="${3}" _erbr_spec_fname="${4}" \ + _erbr_spec_fname_tgt="${5}" _erbr_tmp_dname="${6}" _erbr_topdir="${7}" _erbr_url="${8}" \ + _erbr_version="${9}" _erbr_version_rpm="${10}" \ + _erbr_rc=0; + + if ! rtl_fileop cp "${_erbr_spec_fname}" "${_erbr_spec_fname_tgt}"; then + return 1; + else + while true; do + rpmbuild \ + -bb \ + \ + --define "_binary_payload w2T16.xzdio" \ + \ + --define="_tmppath ${_erbr_tmp_dname=}" \ + --define="_topdir ${_erbr_topdir}" \ + --define="pkg_destdir ${_erbr_destdir}" \ + --define="pkg_name ${_erbr_name}" \ + --define="pkg_url ${_erbr_url}" \ + --define="pkg_version_full ${_erbr_version}" \ + --define="pkg_version_rpm ${_erbr_version_rpm}" \ + --nodeps "${_erbr_spec_fname_tgt}"; + _erbr_rc="${?}"; + + if [ "${_erbr_rc}" -eq 0 ]; then + break; + elif [ "${_erbr_rc}" -eq 141 ]; then + continue; + else + return "${_erbr_rc}"; + fi; + done; + + if ! find "${_erbr_rpms_dname}/${_erbr_name}-${_erbr_version_rpm}/RPMS" \ + -iname \*.rpm -exec cp -pP {} "${_erbr_rpms_dname}/" \; \ + || ! rtl_fileop rm "${_erbr_rpms_dname}/${_erbr_name}-${_erbr_version_rpm}" \ + || ! rtl_fileop cp "${_erbr_spec_fname_tgt}" "${_erbr_rpms_dname}/"; + then + return 1; + fi; + fi; + + return 0; +}; + +# +# ex_rtl_expand_rpm_version() - expand RPM version strings +# @_rurl: out reference to package URL +# @_rversion: out reference to package version +# @_rversion_rpm: out reference to RPM version string +# @_subdir: package subdirectory +# @_url: package URL +# @_url_censor: package URL filter +# @_urls_git: package Git URL(s) +# @_version: package version +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +ex_rtl_expand_rpm_version() { + local _ererv_rurl="${1#\$}" _ererv_rversion="${2#\$}" _ererv_rversion_rpm="${3#\$}" \ + _ererv_subdir="${4}" _ererv_url="${5}" _ererv_url_censor="${6}" \ + _ererv_urls_git="${7}" _ererv_version="${8}" \ + _ererv_version_full="" _ererv_version_rpm="" + + if [ "${_ererv_url:+1}" = 1 ]; then + _ererv_url="${_ererv_url%% *}"; + _ererv_version_full="${_ererv_version}"; + _ererv_version_rpm="${_ererv_version%%-*}"; + + elif [ "${_ererv_urls_git:+1}" = 1 ]; then + _ererv_url="${_ererv_urls_git%% *}"; + _ererv_url="${_ererv_url##*=}"; + _ererv_url="${_ererv_url%%@*}"; + + _ererv_version_rpm="$(cd "${_ererv_subdir}" && git rev-parse HEAD)" || return 1; + _ererv_version_full="${_ererv_version_rpm} ($(cd "${_ererv_subdir}" && git rev-parse --abbrev-ref HEAD))" || return 1; + fi; + + if [ "${_ererv_url#${_ererv_url_censor}}" != "${_ererv_url}" ]; then + _ererv_url="Unknown"; + fi; + + eval ${_ererv_rurl}='${_ererv_url}'; + eval ${_ererv_rversion}='${_ererv_version_full}'; + eval ${_ererv_rversion_rpm}='${_ererv_version_rpm}'; + + return 0; +}; + +# +# ex_rtl_fixup_pkgconfig_paths() - fixup pathname prefixes in pkg-config(1) files +# @_dname_base: base directory pathname +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +ex_rtl_fixup_pkgconfig_paths() { + local _erfpp_dname_base="${1}" \ + _erfpp_pc_path=""; + + for _erfpp_pc_path in $(find "${_erfpp_dname_base=}" -name \*.pc); do + if [ -n "$(sed -ne '/^libdir=[^$]*$/p' "${_erfpp_pc_path}")" ] \ + && ! sed -i"" -e '/^libdir=[^$]*$/s/^libdir=\(.*\)$/libdir=${exec_prefix}\1/' \ + -e '/^exec_prefix=$/s/^.*$/exec_prefix=${prefix}/' \ + "${_erfpp_pc_path}"; + then + return 1; + fi; + + if [ -n "$(sed -ne '/^includedir=[^$]*$/p' "${_erfpp_pc_path}")" ] \ + && ! sed -i"" -e '/^includedir=[^$]*$/s/^includedir=\(.*\)$/includedir=${prefix}\1/' \ + "${_erfpp_pc_path}"; + then + return 1; + fi; + done; + + return 0; +}; + +# +# ex_rtl_purge_la_files() - purge .la files in tree +# @_dname_base: base directory pathname +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +ex_rtl_purge_la_files() { + local _erplf_dname_base="${1}" \ + _erplf_la_path=""; + + for _erplf_la_path in $(find \ + "${_erplf_dname_base}" \ + -type f \ + -name \*.la); + do + if ! rtl_fileop rm "${_erplf_la_path}"; then + return 1; + fi; + done; + return 0; +}; + +# +# ex_rtl_strip_files() - strip files of debugging information +# @_strip_cmd: strip(1) command name +# @_tree_root: pathname to tree root +# @--: (ignored) +# @_log_fn: logging function name; called with @... and pathname of each file stripped +# @...: @_fn initial arguments list as positional parameters +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +ex_rtl_strip_files() { + local _ersf_strip_cmd="${1}" _ersf_tree_root="${2}" \ + _ersf_ignored="${3}" _ersf_log_fn="${4}" \ + _ersf_bin_path=""; + shift 4; + + if [ -e "${_ersf_tree_root}" ]; then + for _ersf_bin_path in $(find \ + "${_ersf_tree_root}" \ + -perm /a=x \ + -type f); + do + if objdump \ + -sj .debug_frame \ + -j .debug_info \ + "${_ersf_bin_path}" \ + >/dev/null 2>&1; + then + if ! "${_ersf_strip_cmd}" "${_ersf_bin_path}"; then + return 1; + else + "${_ersf_log_fn}" "${@}" "${_ersf_bin_path}"; + fi; + fi; + done; + fi; + + return 0; +}; + +# vim:filetype=sh textwidth=0 diff --git a/subr.ex/ex_rtl_midipix.subr b/subr.ex/ex_rtl_midipix.subr new file mode 100644 index 00000000..6c321035 --- /dev/null +++ b/subr.ex/ex_rtl_midipix.subr @@ -0,0 +1,92 @@ +# +# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lucía Andrea Illanes Albornoz +# set +o errexit -o noglob -o nounset is assumed. +# +# + +# +# ex_rtl_install_library_archives() - install library archives and library links (.lib.a) for all libraries (.so) in tree +# @_dname_base: base directory pathname +# @_mdso_cmd: mdso command name +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +ex_rtl_install_library_archives() { + local _erila_dname_base="${1}" _erila_mdso_cmd="${2}" \ + _erila_postfix="" _erila_lib_dst_path="" _erila_lib_name="" \ + _erila_lib_src_path="" _erila_so_dst_dir="" _erila_so_src_path=""; + + for _erila_so_src_path in \ + $(find "${_erila_dname_base=}" \ + \( -name "*.so" -or -name "*.so.*" \) \ + -print); + do + if [ "$(readlink -f "${_erila_so_src_path}")" != "/dev/null" ]\ + && rtl_remove_postfix "[0-9.]" "${_erila_so_src_path##*.so}" \$_erila_postfix\ + && [ "${_erila_postfix:+1}" != 1 ]; then + + case "${_erila_so_src_path}" in + *.so) _erila_lib_src_path="${_erila_so_src_path%%.so}.lib.a"; ;; + *.so.*) _erila_lib_src_path="${_erila_so_src_path%%.so.*}.${_erila_so_src_path##*.so.}.lib.a"; ;; + esac; + + _erila_so_dst_dir="${_erila_so_src_path%/*}"; + rtl_basename2 \$_erila_lib_src_path \$_erila_lib_name; + _erila_lib_dst_path="${_erila_so_dst_dir}/${_erila_lib_name}"; + + if [ ! -L "${_erila_lib_src_path}" ]\ + && [ ! -e "${_erila_lib_dst_path}" ]; then + if ! (rtl_basename2 \$_erila_so_src_path \$_erila_fname; \ + rtl_basename2 \$_erila_lib_dst_path \$_erila_fname_dst; \ + rtl_dirname2 \$_erila_so_src_path \$_erila_dname; \ + rtl_fileop cd "${_erila_dname}" && \ + perk -e "${_erila_fname}" |\ + "${_erila_mdso_cmd}" \ + -i "${_erila_fname_dst}" \ + -n "${_erila_fname}" -); + then + return 1; + fi; + fi; + + if ! ex_rtl_install_library_link \ + "${_erila_lib_name}" "${_erila_so_dst_dir}" \ + "${_erila_so_src_path}"; + then + return 1; + fi; + fi; + done; + + return 0; +}; + +# +# ex_rtl_install_library_link() - install library archive (.lib.a) link for library (.so) +# @_lib_name: library name +# @_so_dir: library directory pathname +# @_so_path: library file pathname +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +ex_rtl_install_library_link() { + local _erill_lib_name="${1}" _erill_so_dir="${2}" _erill_so_path="${3}" \ + _erill_lib_link_path="${3%.so*}.lib.a" _erill_fname="" _erill_lib_link_tgt=""; + + if _erill_lib_link_tgt="$(find "${_erill_so_dir}" \ + -name "${_erill_lib_name%%.*}.*.lib.a" |\ + sort | tail -1)"\ + && [ "${_erill_lib_link_tgt:+1}" = 1 ]\ + && [ "${_erill_lib_link_tgt}" != "${_erill_lib_link_path}" ]; + then + rtl_basename2 \$_erill_lib_link_tgt \$_erill_fname; + + if ! rtl_fileop rm "${_erill_lib_link_path}"\ + || ! rtl_fileop ln_symbolic "${_erill_fname}" "${_erill_lib_link_path}"; then + return 1; + fi; + fi; + return 0; +}; + +# vim:filetype=sh textwidth=0 diff --git a/subr.ex/ex_rtl_run.subr b/subr.ex/ex_rtl_run.subr new file mode 100644 index 00000000..558c8486 --- /dev/null +++ b/subr.ex/ex_rtl_run.subr @@ -0,0 +1,400 @@ +# +# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lucía Andrea Illanes Albornoz +# set +o errexit -o noglob -o nounset is assumed. +# +# Package {configure,make} command execution +# + +# +# ex_rtl_run_configure() - run configure script +# @_ar: ar(1) command name or pathname +# @_cc: C compiler command name or pathname +# @_configure: configure script command name or pathname +# @_cxx: C++ compiler command name or pathname +# @_ld: ld(1) command name or pathname +# @_libtool: libtool(1) command name or pathname or "none" +# @_pkg_config: pkg-config(1) command name or pathname +# @_python: python command name or pathname +# @_ranlib: ranlib(1) command name or pathname +# @--: (ignored) +# @_flags: configure script flags as a whitespace-separated list +# @_flags_extra: extra configure script flags as a whitespace-separated likst +# @_flags_list: configure script flags as a :-separated list +# @_flags_extra_list: extra configure script flags as a :-separated list +# @--: (ignored) +# @_cflags: $CFLAGS +# @_cflags_extra: extra $CFLAGS +# @_cppflags: $CPPFLAGS +# @_cppflags_extra: extra $CPPFLAGS +# @_cxxflags: $CXXFLAGS +# @_cxxflags_extra: extra $CXXFLAGS +# @_ldflags: $LDFLAGS +# @_ldflags_extra: extra $LDFLAGS +# @_pkg_config_libdir: pkg-config(1) search directory +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +ex_rtl_run_configure() { + local _errc_ar="${1}" _errc_cc="${2}" _errc_configure="${3}" _errc_cxx="${4}" _errc_ld="${5}" \ + _errc_libtool="${6}" _errc_pkg_config="${7}" _errc_python="${8}" _errc_ranlib="${9}" \ + _errc_ignored="${10}" \ + _errc_flags="${11}" _errc_flags_extra="${12}" \ + _errc_flags_list="${13}" _errc_flags_extra_list="${14}" \ + _errc_ignored="${15}" \ + _errc_cflags="${16}" _errc_cflags_extra="${17}" _errc_cppflags="${18}" \ + _errc_cppflags_extra="${19}" _errc_cxxflags="${20}" _errc_cxxflags_extra="${21}" \ + _errc_ldflags="${22}" _errc_ldflags_extra="${23}" _errc_pkg_config_libdir="${24}" \ + _errc_rc=0; + + case "${_errc_libtool:-}" in + none) _errc_libtool=""; ;; + esac; + + [ "${_errc_cflags_extra:+1}" = 1 ] && _errc_cflags="${_errc_cflags:+${_errc_cflags} }${_errc_cflags_extra}"; + [ "${_errc_cppflags_extra:+1}" = 1 ] && _errc_cppflags="${_errc_cppflags:+${_errc_cppflags} }${_errc_cppflags_extra}"; + [ "${_errc_cxxflags_extra:+1}" = 1 ] && _errc_cxxflags="${_errc_cxxflags:+${_errc_cxxflags} }${_errc_cxxflags_extra}"; + [ "${_errc_ldflags_extra:+1}" = 1 ] && _errc_ldflags="${_errc_ldflags:+${_errc_ldflags} }${_errc_ldflags_extra}"; + +( + if [ "${_errc_libtool:+1}" = 1 ]; then + export MAKE="make LIBTOOL=${_errc_libtool}"; + fi; + + [ "${_errc_ar:+1}" = 1 ] && export AR="${_errc_ar}"; + [ "${_errc_cc:+1}" = 1 ] && export CC="${_errc_cc}"; + [ "${_errc_cxx:+1}" = 1 ] && export CXX="${_errc_cxx}"; + [ "${_errc_ld:+1}" = 1 ] && export LD="${_errc_ld}"; + [ "${_errc_libtool:+1}" = 1 ] && export LIBTOOL="${_errc_libtool}"; + [ "${_errc_pkg_config:+1}" = 1 ] && export PKG_CONFIG="${_errc_pkg_config}"; + [ "${_errc_python:+1}" = 1 ] && export PYTHON="${_errc_python}"; + [ "${_errc_ranlib:+1}" = 1 ] && export RANLIB="${_errc_ranlib}"; + + [ "${_errc_cflags:+1}" = 1 ] && export CFLAGS="${_errc_cflags}"; + [ "${_errc_cppflags:+1}" = 1 ] && export CPPFLAGS="${_errc_cppflags}"; + [ "${_errc_cxxflags:+1}" = 1 ] && export CXXFLAGS="${_errc_cxxflags}"; + [ "${_errc_ldflags:+1}" = 1 ] && export LDFLAGS="${_errc_ldflags}"; + [ "${_errc_pkg_config_libdir:+1}" = 1 ] && export PKG_CONFIG_LIBDIR="${_errc_pkg_config_libdir}"; + + if [ "${_errc_flags_list:+1}" = 1 ]; then + rtl_run_cmdlineV ":" "${_errc_configure}" \ + "${_errc_flags_list}" \ + "${_errc_flags_extra_list:-}" \ + ; + exit "${?}"; + elif [ "${_errc_flags_extra_list:+1}" = 1 ]; then + rtl_run_cmdlineV ":" "${_errc_configure}" \ + ${_errc_flags:-} \ + "${_errc_flags_extra_list:-}" \ + ; + exit "${?}"; + else + rtl_run_cmdlineV ":" "${_errc_configure}" \ + ${_errc_flags:-} \ + ${_errc_flags_extra:-} \ + ; + exit "${?}"; + fi; +); + _errc_rc="${?}"; + + return "${_errc_rc}"; +}; + +# +# ex_rtl_run_configure_cmake() - run configure script +# @_ar: ar(1) command name or pathname +# @_cc: C compiler command name or pathname +# @_ccache: ccache(1) command name or pathname or "" +# @_cmake: CMake command name or pathname +# @_cxx: C++ compiler command name or pathname +# @_ld: ld(1) command name or pathname +# @_pkg_config: pkg-config(1) command name or pathname +# @_python: python command name or pathname +# @_ranlib: ranlib(1) command name or pathname +# @--: (ignored) +# @_build_type: CMake build type (host, cross, native) +# @_cmake_args: additional CMake arguments as a whitespace-separated list +# @_cmake_args_extra: additional CMake extra arguments as a whitespace-separated likst +# @_prefix: build prefix pathname +# @_subdir: CMake build directory pathname +# @_system_name: CMake system name +# @_system_processor: CMake system processor +# @--: (ignored) +# @_cflags: $CFLAGS +# @_cflags_extra: extra $CFLAGS +# @_cppflags: $CPPFLAGS +# @_cppflags_extra: extra $CPPFLAGS +# @_cxxflags: $CXXFLAGS +# @_cxxflags_extra: extra $CXXFLAGS +# @_ldflags: $LDFLAGS +# @_ldflags_extra: extra $LDFLAGS +# @_pkg_config_libdir: pkg-config(1) search directory +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +ex_rtl_run_configure_cmake() { + local _errcc_ar="${1}" _errcc_cc="${2}" _errcc_ccache="${3}" _errcc_cmake="${4}" \ + _errcc_cxx="${5}" _errcc_ld="${6}" _errcc_pkg_config="${7}" _errcc_python="${8}" \ + _errcc_ranlib="${9}" \ + _errcc_ignored="${10}" \ + _errcc_build_type="${11}" \ + _errcc_cmake_args="${12}" _errcc_cmake_args_extra="${13}" \ + _errcc_prefix="${14}" _errcc_subdir="${15}" \ + _errcc_system_name="${16}" _errcc_system_processor="${17}" \ + _errcc_ignored="${18}" \ + _errcc_cflags="${19}" _errcc_cflags_extra="${20}" _errcc_cppflags="${21}" \ + _errcc_cppflags_extra="${22}" _errcc_cxxflags="${23}" _errcc_cxxflags_extra="${24}" \ + _errcc_ldflags="${25}" _errcc_ldflags_extra="${26}" _errcc_pkg_config_libdir="${27}" \ + _errcc_cmd_name="" _errcc_cmake_args_auto="" _errcc_rc=0 _errcc_vname="" _errcc_vval="" + + [ "${_errcc_cflags_extra:+1}" = 1 ] && _errcc_cflags="${_errcc_cflags:+${_errcc_cflags} }${_errcc_cflags_extra}"; + [ "${_errcc_cppflags_extra:+1}" = 1 ] && _errcc_cppflags="${_errcc_cppflags:+${_errcc_cppflags} }${_errcc_cppflags_extra}"; + [ "${_errcc_cxxflags_extra:+1}" = 1 ] && _errcc_cxxflags="${_errcc_cxxflags:+${_errcc_cxxflags} }${_errcc_cxxflags_extra}"; + [ "${_errcc_ldflags_extra:+1}" = 1 ] && _errcc_ldflags="${_errcc_ldflags:+${_errcc_ldflags} }${_errcc_ldflags_extra}"; + +( + [ "${_errcc_pkg_config:+1}" = 1 ] && export PKG_CONFIG="${_errcc_pkg_config}"; + [ "${_errcc_pkg_config_libdir:+1}" = 1 ] && export PKG_CONFIG_LIBDIR="${_errcc_pkg_config_libdir}"; + [ "${_errcc_python:+1}" = 1 ] && export PYTHON="${_errcc_python}"; + + for _errcc_vname in ar cc cxx ld pkg_config ranlib; do + case "${_errcc_vname}" in + cc|cxx) + _errcc_vname="_errcc_${_errcc_vname}"; + if [ "${_errcc_ccache:+1}" = 1 ]; then + eval ${_errcc_vname}="\${${_errcc_vname}#${_errcc_ccache} }"; + fi; + ;; + + *) + _errcc_vname="_errcc_${_errcc_vname}"; + ;; + esac; + + if eval [ '"${'"${_errcc_vname}"':+1}"' = 1 ]\ + && eval [ '"${'"${_errcc_vname}"'#/}"' = '"${'"${_errcc_vname}"'}"' ]; then + eval _errcc_cmd_name="\${${_errcc_vname}% *}"; + eval _errcc_vval="\${${_errcc_vname}#* }"; + eval ${_errcc_vname}='$(which "${_errcc_cmd_name}")' || return 1; + fi; + done; + + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_AR=${_errcc_ar}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_BUILD_TYPE=${_errcc_build_type}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_C_COMPILER=${_errcc_cc}" ":"; + if [ "${_errcc_ccache:+1}" = 1 ]; then + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_C_COMPILER_LAUNCHER=${_errcc_ccache}" ":"; + fi; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_C_FLAGS=${_errcc_cflags}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_CPP_FLAGS=${_errcc_cppflags}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_CXX_COMPILER=${_errcc_cxx}" ":"; + if [ "${_errcc_ccache:+1}" = 1 ]; then + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_CXX_COMPILER_LAUNCHER=${_errcc_ccache}" ":"; + fi; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_CXX_FLAGS=${_errcc_cxxflags}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_EXE_LINKER_FLAGS=${_errcc_ldflags}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_FIND_ROOT_PATH=${_errcc_prefix}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_INSTALL_PREFIX=" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_LINKER=${_errcc_ld}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_MODULE_LINKER_FLAGS=${_errcc_ldflags}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_RANLIB=${_errcc_ranlib}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_SHARED_LINKER_FLAGS=${_errcc_ldflags}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_SYSTEM_PROCESSOR=${_errcc_system_processor}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DPKG_CONFIG_EXECUTABLE=${_errcc_pkg_config}" ":"; + + case "${_errcc_build_type}" in + native) + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_SYSROOT=${_errcc_prefix}" ":"; + rtl_lconcat \$_errcc_cmake_args_auto "-DCMAKE_SYSTEM_NAME=${_errcc_system_name}" ":"; + ;; + esac; + + rtl_run_cmdlineV ":" "${_errcc_cmake}" \ + "${_errcc_cmake_args_auto}" \ + ${_errcc_cmake_args:-} \ + ${_errcc_cmake_args_extra:-} \ + "${_errcc_subdir}"; + exit "${?}"; +); + _errcc_rc="${?}"; + + return "${_errcc_rc}"; +}; + +# +# ex_rtl_run_make() - run make(1) +# @_ar: ar(1) command name or pathname +# @_cc: C compiler command name or pathname +# @_cxx: C++ compiler command name or pathname +# @_ld: ld(1) command name or pathname +# @_libtool: libtool(1) command name or pathname or "none" +# @_make: make(1) command name or pathname +# @_pkg_config: pkg-config(1) command name or pathname +# @_ranlib: ranlib(1) command name or pathname +# @--: (ignored) +# @_set_ccfl: 1 if CC=... is to be passed to make(1), 0 if CC=... is not to be passed to make(1) +# @_subdir: make(1) -C argument +# @--: (ignored) +# @_makeflags: make(1) flags as a whitespace-separated list +# @_makeflags_extra: extra make(1) flags as a whitespace-separated likst +# @_makeflags_list: make(1) flags as a :-separated list +# @_makeflags_extra_list: extra make(1) flags as a :-separated list +# @_makeflags_loadavg: make(1) -l load argument +# @_makeflags_parallelise: make(1) -j jobs argument +# @_makeflags_verbosity: make(1) Makefile verbosity arguments or "none" +# @--: (ignored) +# @_cflags: $CFLAGS +# @_cflags_extra: extra $CFLAGS +# @_cppflags: $CPPFLAGS +# @_cppflags_extra: extra $CPPFLAGS +# @_cxxflags: $CXXFLAGS +# @_cxxflags_extra: extra $CXXFLAGS +# @_ldflags: $LDFLAGS +# @_ldflags_extra: extra $LDFLAGS +# @_pkg_config_libdir: pkg-config(1) search directory +# @--: (ignored) +# @_destdir_spec: DESTDIR=... specification +# @_target: make(1) target +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +ex_rtl_run_make() { + local _errm_ar="${1}" _errm_cc="${2}" _errm_cxx="${3}" _errm_ld="${4}" \ + _errm_libtool="${5}" _errm_make="${6}" _errm_pkg_config="${7}" _errm_ranlib="${8}" \ + _errm_ignored="${9}" \ + _errm_set_ccfl="${10}" _errm_subdir="${11}" \ + _errm_ignored="${12}" \ + _errm_makeflags="${13}" _errm_makeflags_extra="${14}" _errm_makeflags_list="${15}" \ + _errm_makeflags_extra_list="${16}" _errm_makeflags_loadavg="${17}" \ + _errm_makeflags_parallelise="${18}" _errm_makeflags_verbosity="${19}" \ + _errm_ignored="${20}" \ + _errm_cflags="${21}" _errm_cflags_extra="${22}" _errm_cppflags="${23}" \ + _errm_cppflags_extra="${24}" _errm_cxxflags="${25}" _errm_cxxflags_extra="${26}" \ + _errm_ldflags="${27}" _errm_ldflags_extra="${28}" _errm_pkg_config_libdir="${29}" \ + _errm_ignored="${30}" \ + _errm_destdir_spec="${31}" _errm_target="${32}" \ + _errm_rc=0; + + case "${_errm_makeflags_loadavg:-}" in + none) _errm_makeflags_loadavg=""; ;; + esac; + + case "${_errm_libtool:-}" in + none) _errm_libtool=""; ;; + esac; + + case "${_errm_makeflags_verbosity}" in + none) _errm_makeflags_verbosity=""; ;; + esac; + + case "${_errm_set_ccfl}" in + 1) _errm_set_ccfl="1"; ;; + *) _errm_set_ccfl=""; ;; + esac; + +( + if [ "${_errm_libtool:+1}" = 1 ]; then + export MAKE="make LIBTOOL=${_errm_libtool}"; + fi; + + if [ "${_errm_makeflags_list:+1}" = 1 ]; then + rtl_run_cmdlineV ":" "${_errm_make}" \ + AR="${_errm_ar}" \ + ${_errm_set_ccfl:+CC="${_errm_cc}"} \ + ${_errm_set_ccfl:+CXX="${_errm_cxx}"} \ + LD="${_errm_ld}" \ + ${_errm_libtool:+LIBTOOL="${_errm_libtool}"} \ + ${_errm_pkg_config:+PKG_CONFIG="${_errm_pkg_config}"} \ + RANLIB="${_errm_ranlib}" \ + \ + "${_errm_makeflags_list}" \ + "${_errm_makeflags_extra_list:-}" \ + ${_errm_makeflags_loadavg:-} \ + ${_errm_makeflags_parallelise:-} \ + ${_errm_makeflags_verbosity} \ + \ + ${_errm_cflags:+CFLAGS="${_errm_cflags}"} \ + ${_errm_cflags_extra:+CFLAGS+="${_errm_cflags_extra}"} \ + ${_errm_cppflags:+CPPFLAGS="${_errm_cppflags}"} \ + ${_errm_cppflags_extra:+CPPFLAGS+="${_errm_cppflags_extra}"} \ + ${_errm_cxxflags:+CXXFLAGS="${_errm_cxxflags}"} \ + ${_errm_cxxflags_extra:+CXXFLAGS+="${_errm_cxxflags_extra}"} \ + ${_errm_ldflags:+LDFLAGS="${_errm_ldflags}"} \ + ${_errm_ldflags_extra:+LDFLAGS+="${_errm_ldflags_extra}"} \ + ${_errm_pkg_config_libdir:+PKG_CONFIG_LIBDIR="${_errm_pkg_config_libdir}"} \ + \ + ${_errm_subdir:+-C "${_errm_subdir}"} \ + ${_errm_destdir_spec:+"${_errm_destdir_spec}"} \ + ${_errm_target:+"${_errm_target}"} \ + ; + exit "${?}"; + elif [ "${_errm_makeflags_extra_list:+1}" = 1 ]; then + rtl_run_cmdlineV ":" "${_errm_make}" \ + AR="${_errm_ar}" \ + ${_errm_set_ccfl:+CC="${_errm_cc}"} \ + ${_errm_set_ccfl:+CXX="${_errm_cxx}"} \ + LD="${_errm_ld}" \ + ${_errm_libtool:+LIBTOOL="${_errm_libtool}"} \ + ${_errm_pkg_config:+PKG_CONFIG="${_errm_pkg_config}"} \ + RANLIB="${_errm_ranlib}" \ + \ + ${_errm_makeflags:-} \ + "${_errm_makeflags_extra_list}" \ + ${_errm_makeflags_loadavg:-} \ + ${_errm_makeflags_parallelise:-} \ + ${_errm_makeflags_verbosity} \ + \ + ${_errm_cflags:+CFLAGS="${_errm_cflags}"} \ + ${_errm_cflags_extra:+CFLAGS+="${_errm_cflags_extra}"} \ + ${_errm_cppflags:+CPPFLAGS="${_errm_cppflags}"} \ + ${_errm_cppflags_extra:+CPPFLAGS+="${_errm_cppflags_extra}"} \ + ${_errm_cxxflags:+CXXFLAGS="${_errm_cxxflags}"} \ + ${_errm_cxxflags_extra:+CXXFLAGS+="${_errm_cxxflags_extra}"} \ + ${_errm_ldflags:+LDFLAGS="${_errm_ldflags}"} \ + ${_errm_ldflags_extra:+LDFLAGS+="${_errm_ldflags_extra}"} \ + ${_errm_pkg_config_libdir:+PKG_CONFIG_LIBDIR="${_errm_pkg_config_libdir}"} \ + \ + ${_errm_subdir:+-C "${_errm_subdir}"} \ + ${_errm_destdir_spec:+"${_errm_destdir_spec}"} \ + ${_errm_target:+"${_errm_target}"} \ + ; + exit "${?}"; + else + rtl_run_cmdlineV ":" "${_errm_make}" \ + AR="${_errm_ar}" \ + ${_errm_set_ccfl:+CC="${_errm_cc}"} \ + ${_errm_set_ccfl:+CXX="${_errm_cxx}"} \ + LD="${_errm_ld}" \ + ${_errm_libtool:+LIBTOOL="${_errm_libtool}"} \ + ${_errm_pkg_config:+PKG_CONFIG="${_errm_pkg_config}"} \ + RANLIB="${_errm_ranlib}" \ + \ + ${_errm_makeflags:-} \ + ${_errm_makeflags_extra:-} \ + ${_errm_makeflags_loadavg:-} \ + ${_errm_makeflags_parallelise:-} \ + ${_errm_makeflags_verbosity} \ + \ + ${_errm_cflags:+CFLAGS="${_errm_cflags}"} \ + ${_errm_cflags_extra:+CFLAGS+="${_errm_cflags_extra}"} \ + ${_errm_cppflags:+CPPFLAGS="${_errm_cppflags}"} \ + ${_errm_cppflags_extra:+CPPFLAGS+="${_errm_cppflags_extra}"} \ + ${_errm_cxxflags:+CXXFLAGS="${_errm_cxxflags}"} \ + ${_errm_cxxflags_extra:+CXXFLAGS+="${_errm_cxxflags_extra}"} \ + ${_errm_ldflags:+LDFLAGS="${_errm_ldflags}"} \ + ${_errm_ldflags_extra:+LDFLAGS+="${_errm_ldflags_extra}"} \ + ${_errm_pkg_config_libdir:+PKG_CONFIG_LIBDIR="${_errm_pkg_config_libdir}"} \ + \ + ${_errm_subdir:+-C "${_errm_subdir}"} \ + ${_errm_destdir_spec:+"${_errm_destdir_spec}"} \ + ${_errm_target:+"${_errm_target}"} \ + ; + exit "${?}"; + fi; +); + _errm_rc="${?}"; + + return "${_errm_rc}"; +}; + +# vim:filetype=sh textwidth=0 diff --git a/subr.pkg/pkg_build.subr b/subr.pkg/pkg_build.subr index a11e87ac..9ca2afce 100644 --- a/subr.pkg/pkg_build.subr +++ b/subr.pkg/pkg_build.subr @@ -21,7 +21,7 @@ pkg_build() { # autoconf as it often abuses it by appending -std={gnu99,...} to it # instead of amending CFLAGS. # - ex_pkg_run_make \ + ex_rtl_run_make \ "${PKG_AR}" "${PKG_CC}" "${PKG_CXX}" "${PKG_CCLD}" "${PKG_LIBTOOL}" \ "${PKG_MAKE}" "${PKG_PKG_CONFIG}" "${PKG_RANLIB}" \ -- \ diff --git a/subr.pkg/pkg_build_clean.subr b/subr.pkg/pkg_build_clean.subr index 3cd78bb9..f93577ec 100644 --- a/subr.pkg/pkg_build_clean.subr +++ b/subr.pkg/pkg_build_clean.subr @@ -17,7 +17,7 @@ pkg_build_clean() { _pbc_subdir=""; fi; - ex_pkg_run_make \ + ex_rtl_run_make \ "${PKG_AR}" "${PKG_CC}" "${PKG_CXX}" "${PKG_CCLD}" "${PKG_LIBTOOL}" \ "${PKG_MAKE}" "${PKG_PKG_CONFIG}" "${PKG_RANLIB}" \ -- \ diff --git a/subr.pkg/pkg_configure.subr b/subr.pkg/pkg_configure.subr index 71fac55a..8d75b6f7 100644 --- a/subr.pkg/pkg_configure.subr +++ b/subr.pkg/pkg_configure.subr @@ -13,7 +13,7 @@ pkgp_configure_autotools() { then _ppca_rc=2; else - ex_pkg_run_configure \ + ex_rtl_run_configure \ "${PKG_AR}" "${PKG_CC}" "${PKG_CONFIGURE}" "${PKG_CXX}" "${PKG_LD}" \ "${PKG_LIBTOOL}" "${PKG_PKG_CONFIG}" "${PKG_PYTHON:-}" "${PKG_RANLIB}" \ -- \ @@ -53,7 +53,7 @@ pkgp_configure_cmake() { esac; esac; - ex_pkg_run_configure_cmake \ + ex_rtl_run_configure_cmake \ "${PKG_AR}" "${PKG_CC}" "${ARG_CCACHE}" "${PKG_CMAKE}" "${PKG_CXX}" \ "${PKG_LD}" "${PKG_PKG_CONFIG}" "${PKG_PYTHON:-}" "${PKG_RANLIB}" \ -- \ diff --git a/subr.pkg/pkg_install_files.subr b/subr.pkg/pkg_install_files.subr index 204bab74..ac471188 100644 --- a/subr.pkg/pkg_install_files.subr +++ b/subr.pkg/pkg_install_files.subr @@ -41,80 +41,38 @@ pkgp_install_files_v2() { fi; }; -pkgp_install_files_perms() { - local _ppifp_destdir="" _ppifp_fname="" IFS; - - for _ppifp_destdir in "${PKG_DESTDIR}" "${PKG_DESTDIR_HOST}"; do - if [ -e "${_ppifp_destdir}" ]; then - rtl_set_IFS_nl; - - for _ppifp_fname in $(find "${_ppifp_destdir}" -type d); do - if ! rtl_fileop chmod 0755 "${_ppifp_fname}"; then - return 1; - fi; - done; - - for _ppifp_fname in $(find "${_ppifp_destdir}" \( -not -perm /0111 \) -type f); do - if ! rtl_fileop chmod 0644 "${_ppifp_fname}"; then - return 1; - fi; - done; - - for _ppifp_fname in $(find "${_ppifp_destdir}" -perm /0111 -type f); do - if ! rtl_fileop chmod 0755 "${_ppifp_fname}"; then - return 1; - fi; - done; - fi; - done; +pkgp_install_files_libraries() { + if [ "${PKG_BUILD_TYPE}" != "host" ]; then + ex_rtl_install_library_archives "${PKG_DESTDIR}" "${PKG_TARGET}-mdso" || return 1; + fi; + ex_rtl_purge_la_files "${PKG_DESTDIR}" || return 1; return 0; }; -pkgp_install_files_pkgconfig() { - local _ppifp2_pc_path=""; - - for _ppifp2_pc_path in $(find "${PKG_DESTDIR}" -name \*.pc); do - if [ -n "$(sed -ne '/^libdir=[^$]*$/p' "${_ppifp2_pc_path}")" ] \ - && ! sed -i"" -e '/^libdir=[^$]*$/s/^libdir=\(.*\)$/libdir=${exec_prefix}\1/' \ - -e '/^exec_prefix=$/s/^.*$/exec_prefix=${prefix}/' \ - "${_ppifp2_pc_path}"; then - return 1; - fi; - - if [ -n "$(sed -ne '/^includedir=[^$]*$/p' "${_ppifp2_pc_path}")" ] \ - && ! sed -i"" -e '/^includedir=[^$]*$/s/^includedir=\(.*\)$/includedir=${prefix}\1/' \ - "${_ppifp2_pc_path}"; then - return 1; - fi; - done; +pkgp_install_files_perms() { + rtl_set_perms_treeV \ + 0755 0755 0644 \ + "${PKG_DESTDIR}" \ + "${PKG_DESTDIR_HOST}"; + return "${?}"; }; pkgp_install_files_strip() { - local _ppifs_bin_path="" _ppifs_stripfl=0 _ppifs_tree_root="${PKG_DESTDIR}"; - - if [ -e "${_ppifs_tree_root}" ]; then - if rtl_match "${PKG_NAME}" "*_ppifs_minipix"; then - : $((_ppifs_stripfl=(${ARG_DEBUG_MINIPIX:-0} ? 0 : 1))); - elif [ "${BUILD_KIND}" = release ]\ - && [ "${PKG_BUILD_TYPE}" = native ]; - then - _ppifs_stripfl=1; - else - _ppifs_stripfl=0; - fi; - - if [ "${_ppifs_stripfl:-0}" -eq 1 ]; then - for _ppifs_bin_path in $(find "${_ppifs_tree_root}" -perm /a=x -type f); do - if objdump -sj .debug_frame -j .debug_info "${_ppifs_bin_path}" >/dev/null 2>&1; then - rtl_log_msgV "pkg_strip" "${MSG_pkg_strip}" "${_ppifs_bin_path}"; - if ! "${PKG_TARGET}-strip" "${_ppifs_bin_path}"; then - return 1; - fi; - fi; - done; - fi; + local _ppifs_files_stripped="" _ppifs_pkg_minipixfl=0 _ppifs_rc=0; + + rtl_match "${PKG_NAME}" "*_minipix"; _ppifs_pkg_minipixfl="${?}"; + if [ \( "${_ppifs_pkg_minipixfl}" -eq 0 \) -a \( "${ARG_DEBUG_MINIPIX:-0}" -eq 0 \) ]\ + || [ \( "${BUILD_KIND}" = release \) -a \( "${PKG_BUILD_TYPE}" = native \) ]; then + ex_rtl_strip_files \ + \$_ppifs_files_stripped \ + "${PKG_TARGET}-strip" \ + "${PKG_DESTDIR}" \ + -- \ + rtl_log_msgV "pkg_strip" "${MSG_pkg_strip}"; + _ppifs_rc="${?}"; fi; - return 0; + + return "${_ppifs_rc}"; }; pkg_install_files() { @@ -123,8 +81,9 @@ pkg_install_files() { if ! pkgp_install_files\ || ! pkgp_install_files_v2\ || ! pkgp_install_files_perms\ - || ! pkgp_install_files_pkgconfig\ - || ! pkgp_install_files_strip; + || ! ex_rtl_fixup_pkgconfig_paths "${PKG_DESTDIR}"\ + || ! pkgp_install_files_strip\ + || ! pkgp_install_files_libraries; then return 1; fi; diff --git a/subr.pkg/pkg_install_libs.subr b/subr.pkg/pkg_install_libs.subr deleted file mode 100644 index d19c9565..00000000 --- a/subr.pkg/pkg_install_libs.subr +++ /dev/null @@ -1,95 +0,0 @@ -# -# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lucía Andrea Illanes Albornoz -# set +o errexit -o noglob -o nounset is assumed. -# - -pkgp_install_libs_purge_la() { - local _ppilpl_la_path=""; - - for _ppilpl_la_path in $(find "${PKG_DESTDIR}" -type f -name \*.la); do - if ! rtl_fileop rm "${_ppilpl_la_path}"; then - return 1; - fi; - done; - return 0; -}; - -pkgp_install_libs_shared_link() { - local _ppilsl_lib_name="${1}" _ppilsl_so_dir="${2}" _ppilsl_so_path="${3}" \ - _ppilsl_lib_link_path="${3%.so*}.lib.a" _ppilsl_fname="" _ppilsl_lib_link_tgt=""; - - if _ppilsl_lib_link_tgt="$(find "${_ppilsl_so_dir}" -name "${_ppilsl_lib_name%%.*}.*.lib.a" | sort | tail -1)"\ - && [ "${_ppilsl_lib_link_tgt:+1}" = 1 ]\ - && [ "${_ppilsl_lib_link_tgt}" != "${_ppilsl_lib_link_path}" ]; - then - rtl_basename2 \$_ppilsl_lib_link_tgt \$_ppilsl_fname; - - if ! rtl_fileop rm "${_ppilsl_lib_link_path}"\ - || ! rtl_fileop ln_symbolic "${_ppilsl_fname}" "${_ppilsl_lib_link_path}"; then - return 1; - fi; - fi; - return 0; -}; - -pkgp_install_libs_shared() { - local _ppils_postfix="" _ppils_lib_dst_path="" _ppils_lib_name="" \ - _ppils_lib_src_path="" _ppils_so_dst_dir="" _ppils_so_src_path=""; - - if [ "${PKG_BUILD_TYPE}" != "host" ]; then - for _ppils_so_src_path in \ - $(find "${PKG_DESTDIR}" \ - \( -name "*.so" -or -name "*.so.*" \) -print); - do - if [ "$(readlink -f "${_ppils_so_src_path}")" != "/dev/null" ]\ - && rtl_remove_postfix "[0-9.]" "${_ppils_so_src_path##*.so}" \$_ppils_postfix\ - && [ "${_ppils_postfix:+1}" != 1 ]; then - case "${_ppils_so_src_path}" in - *.so) _ppils_lib_src_path="${_ppils_so_src_path%%.so}.lib.a"; ;; - *.so.*) _ppils_lib_src_path="${_ppils_so_src_path%%.so.*}.${_ppils_so_src_path##*.so.}.lib.a"; ;; - esac; - - _ppils_so_dst_dir="${_ppils_so_src_path%/*}"; - rtl_basename2 \$_ppils_lib_src_path \$_ppils_lib_name; - _ppils_lib_dst_path="${_ppils_so_dst_dir}/${_ppils_lib_name}"; - - if [ ! -L "${_ppils_lib_src_path}" ]\ - && [ ! -e "${_ppils_lib_dst_path}" ]; then - if ! (rtl_basename2 \$_ppils_so_src_path \$_ppils_fname; \ - rtl_basename2 \$_ppils_lib_dst_path \$_ppils_fname_dst; \ - rtl_dirname2 \$_ppils_so_src_path \$_ppils_dname; \ - rtl_fileop cd "${_ppils_dname}" && \ - perk -e "${_ppils_fname}" |\ - "${PKG_TARGET}-mdso" \ - -i "${_ppils_fname_dst}" \ - -n "${_ppils_fname}" -); - then - return 1; - fi; - fi; - - if ! pkgp_install_libs_shared_link \ - "${_ppils_lib_name}" "${_ppils_so_dst_dir}" \ - "${_ppils_so_src_path}"; - then - return 1; - fi; - fi; - done; - fi; - - return 0; -}; - -pkg_install_libs() { - local _pil_group_name="${1}" _pil_pkg_name="${2}" _pil_restart_at="${3}"; - - if ! pkgp_install_libs_purge_la\ - || ! pkgp_install_libs_shared; - then - return 1; - fi; - return 0; -}; - -# vim:filetype=sh textwidth=0 diff --git a/subr.pkg/pkg_install_make.subr b/subr.pkg/pkg_install_make.subr index 914a2af2..fe255767 100644 --- a/subr.pkg/pkg_install_make.subr +++ b/subr.pkg/pkg_install_make.subr @@ -17,7 +17,7 @@ pkg_install_make() { _pim_subdir=""; fi; - ex_pkg_run_make \ + ex_rtl_run_make \ "${PKG_AR}" "${PKG_CC}" "${PKG_CXX}" "${PKG_CCLD}" "${PKG_LIBTOOL}" \ "${PKG_MAKE}" "${PKG_PKG_CONFIG}" "${_pim_ranlib}" \ -- \ diff --git a/subr.pkg/pkg_install_rpm.subr b/subr.pkg/pkg_install_rpm.subr index fccdc7f0..ac3d4407 100644 --- a/subr.pkg/pkg_install_rpm.subr +++ b/subr.pkg/pkg_install_rpm.subr @@ -5,63 +5,27 @@ pkg_install_rpm() { local _pir_group_name="${1}" _pir_pkg_name="${2}" _pir_restart_at="${3}" \ - _pir_pkg_url="" _pir_pkg_version_full="" _pir_pkg_version_rpm="" \ - _pir_rc=0; + _pir_rc=0 _pir_url="" _pir_version="" _pir_version_rpm=""; if rtl_lmatch \$ARG_DIST "rpm" ","\ && [ "${PKG_RPM_DISABLE:-0}" -eq 0 ]\ && command which rpmbuild >/dev/null 2>&1; then - if [ "${PKG_URL:+1}" = 1 ]; then - _pir_pkg_url="${PKG_URL%% *}"; _pir_pkg_version_full="${PKG_VERSION}"; _pir_pkg_version_rpm="${PKG_VERSION%%-*}"; - elif [ "${PKG_URLS_GIT:+1}" = 1 ]; then - _pir_pkg_version_rpm="$(cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && git rev-parse HEAD)"; - _pir_pkg_version_full="${_pir_pkg_version_rpm} ($(cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && git rev-parse --abbrev-ref HEAD))"; - _pir_pkg_url="${PKG_URLS_GIT%% *}"; _pir_pkg_url="${_pir_pkg_url##*=}"; _pir_pkg_url="${_pir_pkg_url%%@*}"; - - if [ "${_pir_pkg_url#${DEFAULT_GITROOT_HEAD}}" != "${_pir_pkg_url}" ]; then - _pir_pkg_url="Unknown"; - fi; - fi; - - if ! rtl_fileop cp "${MIDIPIX_BUILD_PWD}/etc/package.spec" \ - "${PKG_BASE_DIR}/${PKG_NAME}-${_pir_pkg_version_rpm}.spec"; - then - return 1; - else - while true; do - rpmbuild \ - -bb \ - \ - --define "_binary_payload w2T16.xzdio" \ - \ - --define="_tmppath ${BUILD_WORKDIR}" \ - --define="_topdir ${PREFIX_RPM}/${PKG_NAME}-${_pir_pkg_version_rpm}" \ - --define="pkg_destdir ${PKG_DESTDIR}" \ - --define="pkg_name ${PKG_NAME}" \ - --define="pkg_url ${_pir_pkg_url}" \ - --define="pkg_version_full ${_pir_pkg_version_full}" \ - --define="pkg_version_rpm ${_pir_pkg_version_rpm}" \ - --nodeps "${PKG_BASE_DIR}/${PKG_NAME}-${_pir_pkg_version_rpm}.spec"; - _pir_rc="${?}"; - - if [ "${_pir_rc}" -eq 0 ]; then - break; - elif [ "${_pir_rc}" -eq 141 ]; then - continue; - else - return "${_pir_rc}"; - fi; - done; - - if ! find "${PREFIX_RPM}/${PKG_NAME}-${_pir_pkg_version_rpm}/RPMS" \ - -iname \*.rpm -exec cp -pP {} "${PREFIX_RPM}/" \; \ - || ! rtl_fileop rm "${PREFIX_RPM}/${PKG_NAME}-${_pir_pkg_version_rpm}" \ - || ! rtl_fileop cp "${PKG_BASE_DIR}/${PKG_NAME}-${_pir_pkg_version_rpm}.spec" "${PREFIX_RPM}/"; - then - return 1; - fi; - fi; + ex_rtl_expand_rpm_version \ + \$_pir_url \$_pir_version \$_pir_version_rpm \ + "${PKG_BASE_DIR}/${PKG_SUBDIR}" \ + "${PKG_URL:-}" "${DEFAULT_GITROOT_HEAD}" "${PKG_URLS_GIT:-}" \ + "${PKG_VERSION:-}" || return 1; + ex_rtl_build_rpm \ + "${PKG_DESTDIR}" \ + "${PKG_NAME}" \ + "${PREFIX_RPM}" \ + "${MIDIPIX_BUILD_PWD}/etc/package.spec" \ + "${PKG_BASE_DIR}/${PKG_NAME}-${_pir_version_rpm}.spec" \ + "${BUILD_WORKDIR}" \ + "${PREFIX_RPM}/${PKG_NAME}-${_pir_version_rpm}" \ + "${_pir_url}" \ + "${_pir_version}" "${_pir_version_rpm}" || return 1; fi; return 0; diff --git a/subr.rtl/rtl_filepath.subr b/subr.rtl/rtl_filepath.subr index 3e24057f..a2f0f5c4 100644 --- a/subr.rtl/rtl_filepath.subr +++ b/subr.rtl/rtl_filepath.subr @@ -213,7 +213,7 @@ rtl_is_newer() { }; # -# rtl_patch_files() - +# rtl_patch_files() - patch files # @_patch_cwd: patch(1) -d directory # @_strip_count: patch(1) strip count # @_fn: name of function that produces patch filenames and takes the arguments @_rpatch_fname @_patch_idx @... @@ -246,4 +246,61 @@ rtl_patch_files() { return 0; }; +# +# rtl_set_perms_treeV() - set mode bits of directories and files +# @_mode_dir: mode bits for directories +# @_mode_file_exec: mode bits for executable files +# @_mode_file_nonexec: mode bits for non-executable files +# @...: list of base directory pathnames as positional parameters; empty strings are ignored +# +# Returns: zero (0) on success, non-zero (>0) on failure +# +rtl_set_perms_treeV() { + local _rspt_mode_dir="${1}" _rspt_mode_file_exec="${2}" _rspt_mode_file_nonexec="${3}" \ + _rspt_destdir="" _rspt_fname="" \ + IFS IFS0="${IFS}"; + shift 3; + + for _rspt_destdir in "${@}"; do + if [ -e "${_rspt_destdir}" ]; then + rtl_set_IFS_nl; + + for _rspt_fname in $(find "${_rspt_destdir}" -type d); do + if ! rtl_fileop chmod "${_rspt_mode_dir}" \ + "${_rspt_fname}"; + then + return 1; + fi; + done; + + for _rspt_fname in $(find \ + "${_rspt_destdir}" \ + \( -not -perm /0111 \) \ + -type f); + do + if ! rtl_fileop chmod "${_rspt_mode_file_nonexec}" \ + "${_rspt_fname}"; + then + return 1; + fi; + done; + + for _rspt_fname in $(find \ + "${_rspt_destdir}" \ + -perm /0111 \ + -type f); + do + if ! rtl_fileop chmod "${_rspt_mode_file_exec}" \ + "${_rspt_fname}"; + then + return 1; + fi; + done; + + IFS="${IFS0}"; + fi; + done; + return 0; +}; + # vim:filetype=sh textwidth=0 diff --git a/subr.rtl/rtl_platform.subr b/subr.rtl/rtl_platform.subr index 9fc7b013..d3ba8f56 100644 --- a/subr.rtl/rtl_platform.subr +++ b/subr.rtl/rtl_platform.subr @@ -237,6 +237,7 @@ rtl_set_var() { # N.B.: This function is *unsafe* and impossible to implement otherwise w/o filtering @_vname # and implicitly allows for code execution and other undefined behaviour via @_vname. # Do *not* pass untrusted input through @_vname. +# rtl_set_var_unsafe() { local _rsvu_vname="" _rsvu_vval=""; if [ "x${1}" = "x-u" ]; then -- cgit v1.2.3