diff options
Diffstat (limited to 'subr')
-rw-r--r-- | subr/build.subr (renamed from subr/rtl.subr) | 142 | ||||
-rw-r--r-- | subr/pkg_autoconf.subr | 7 | ||||
-rw-r--r-- | subr/pkg_build_dir.subr | 2 | ||||
-rw-r--r-- | subr/pkg_configure.subr | 2 | ||||
-rw-r--r-- | subr/pkg_distclean.subr | 4 | ||||
-rw-r--r-- | subr/pkg_extract.subr | 4 | ||||
-rw-r--r-- | subr/pkg_fetch.subr | 14 | ||||
-rw-r--r-- | subr/pkg_install.subr | 7 | ||||
-rw-r--r-- | subr/pkg_setup_env.subr | 2 | ||||
-rw-r--r-- | subr/post_tarballs.subr | 2 | ||||
-rw-r--r-- | subr/pre_subdirs.subr | 37 |
11 files changed, 100 insertions, 123 deletions
diff --git a/subr/rtl.subr b/subr/build.subr index 4779af8c..a1009c2b 100644 --- a/subr/rtl.subr +++ b/subr/build.subr @@ -22,6 +22,13 @@ get_vars_unsafe() { unset _gvu_vval _gvu_vval_; }; +set_env_vars_with_sep() { + _sevws_sep=${1}; shift; push_IFS ${_sevws_sep}; set -- ${1}; + while [ ${#} -gt 0 ]; do + export "${1}"; shift; + done; unset _sevws_sep; pop_IFS; +}; + log_msg() { _lm_lvl=${1}; shift; if [ "${_lm_lvl#v}" != "${_lm_lvl}" ]\ @@ -44,21 +51,10 @@ log_msg() { fi; [ ${_lm_lvl} = failexit ] && exit 1 || unset _lm_lvl; }; -insecure_mkdir() { - while [ ${#} -gt 0 ]; do - if [ -z "${1}" ]; then - return 1; - elif [ ! -e "${1}" ]; then - log_msg varn "Making directory \`${1}'."; - mkdir -p -- "${1}"; - fi; shift; - done; -}; - install_files() { if [ "${1}" = "-v" ]; then _if_verbose="${1}"; shift; - fi; + fi; _if_prefix="${1}"; shift; while [ ${#} -gt 0 ]; do case "${1}" in @*=*) @@ -67,32 +63,23 @@ install_files() { __ln_fname="${1#*=}"; if [ -e ${__ln_fname} ]; then if [ ${_if_verbose:-0} -eq 1 ]; then - echo secure_rm ${__ln_fname}; + echo build_fileop rm ${__ln_fname}; fi; - secure_rm ${__ln_fname}; - fi; - if [ ${_if_verbose:-0} -eq 1 ]; then - echo ln -sf -- ${__ln_target} ${PKG_PREFIX:+${PKG_PREFIX}/}${__ln_fname}; + build_fileop rm ${__ln_fname}; fi; - ln -sf -- ${__ln_target} ${PKG_PREFIX:+${PKG_PREFIX}/}${__ln_fname}; + build_fileop ln_symbolic ${__ln_target} ${_if_prefix:+${_if_prefix}/}${__ln_fname}; ;; /=*) __mkdir_fname="${1#/=}"; - if [ ${_if_verbose:-0} -eq 1 ]; then - echo insecure_mkdir ${PKG_PREFIX:+${PKG_PREFIX}/}${__mkdir_fname}; - fi; - insecure_mkdir ${PKG_PREFIX:+${PKG_PREFIX}/}${__mkdir_fname}; + build_fileop mkdir ${_if_prefix:+${_if_prefix}/}${__mkdir_fname}; ;; *) __file_fname_src="${1%=*}"; __file_fname_dst="${1#*=}"; - if [ ${_if_verbose:-0} -eq 1 ]; then - echo cp -pP -- ${__file_fname_src} ${PKG_PREFIX:+${PKG_PREFIX}/}${__file_fname_dst}; - fi; - cp -pP -- ${__file_fname_src} ${PKG_PREFIX:+${PKG_PREFIX}/}${__file_fname_dst}; + build_fileop cp ${__file_fname_src} ${_if_prefix:+${_if_prefix}/}${__file_fname_dst}; ;; esac; shift; - done; unset _if_verbose; + done; unset _if_verbose _if_prefix; }; match_list() { @@ -104,45 +91,37 @@ match_list() { done; unset _ml_cmp; return 1; }; -secure_cd() { - if [ \( -z "${1}" \) -o \( ! -e "${1}" \) ]; then - return 1; - else - (cd "${1}"; [ "${PWD#${PREFIX_ROOT}}" = "${PWD}" ] &&\ - return 1 || return 0); - if [ ${?} -eq 0 ]; then - log_msg varn "Changing working directory to \`${1}'."; - cd -- "${1}"; - else - log_msg failexit "secure_cd() called with pathname \`${1}' not below \${PREFIX_ROOT} (${PREFIX_ROOT}). This is a bug."; - fi; - fi; -}; - -secure_rm() { - while [ ${#} -gt 0 ]; do - if [ -z "${1}" ]; then - return 1; - elif [ -e "${1}" ]; then - if [ -d "${1}" ]; then - _sr_pname_check="${1}"; - else - _sr_pname_check="$(dirname "${1}")"; - fi; - (cd "${_sr_pname_check}"; [ "${PWD#${PREFIX_ROOT}}" = "${PWD}" ] &&\ - return 1 || return 0); - if [ ${?} -eq 0 ]; then - unset _sr_pname_check; +build_fileop() { + _bf_op=${1}; shift; + if [ "${_bf_op}" = cd ]; then + log_msg varn "Changing working directory to \`${1}'."; + [ \( -n "${1}" \) -a \( -e "${1}" \) ] && cd -- ${1}; + elif [ "${_bf_op}" = cp ]; then + log_msg varn "Copying \`${1}' to \`${2}' w/ -pPR."; + [ ${#} -ge 2 ] && cp -pPR -- "${@}"; + elif [ "${_bf_op}" = ln_symbolic ]; then + log_msg varn "Linking \`${1}' to \`${2}' w/ -fs"; + [ \( -n "${1}" \) -a \( -n "${2}" \) ] && ln -fs -- ${1} ${2}; + elif [ "${_bf_op}" = mkdir ]\ + || [ "${_bf_op}" = rm ]; then + while [ ${#} -gt 0 ]; do + if [ -z "${1}" ]; then + return 1; + elif [ "${_bf_op}" = mkdir ]\ + && [ ! -e "${1}" ]; then + log_msg varn "Making directory \`${1}'."; + mkdir -p -- "${1}"; + elif [ "${_bf_op}" = rm ]\ + && [ -e "${1}" ]; then log_msg varn "Removing directory or file \`${1}'."; rm -rf -- "${1}"; - else - log_msg failexit "secure_rm() called with pathname \`${1}' not below \${PREFIX_ROOT} (${PREFIX_ROOT}). This is a bug."; - fi; - fi; shift; - done; + fi; shift; + done; + else + log_msg failexit "Error: build_fileop() called w/ invalid parameter(s) \`${@}'."; + fi; }; - is_build_script_done() { if [ "${1}" = "clean" ]\ || [ "${1}" = distclean ]; then @@ -174,6 +153,19 @@ is_build_script_done() { fi; }; +set_build_script_done() { + _sbsd_script_fname=${BUILD_PACKAGE_LC}; + _sbsd_done_fname=${WORKDIR}/.${_sbsd_script_fname}; + while [ $# -ge 1 ]; do + if [ "${1#-}" != "${1}" ]; then + build_fileop rm ${_sbsd_done_fname}.${1#-}; + else + touch ${_sbsd_done_fname}.${1}; + log_msg info "Finished build step ${1} of \`${_sbsd_script_fname}'."; + fi; shift; + done; unset _sbsd_script_fname _sbsd_done_fname; +}; + log_env_vars() { log_msg info "Variables for this ${1:-build}:"; shift; while [ ${_lev_nvar:=0} -lt ${#} ]; do @@ -192,7 +184,11 @@ log_env_vars() { }; parse_with_pkg_name() { - PKG_NAME=${1}; shift; + PKG_NAME=${1}; shift; PKG_TARGET=${TARGET}; + MIDIPIX_BUILD_PWD=$(pwd); build_fileop cd ${WORKDIR}; + for __ in vars/${PKG_NAME}.vars; do + [ -e ${MIDIPIX_BUILD_PWD}/${__} ] && . ${MIDIPIX_BUILD_PWD}/${__}; + done; _pwpn_pkg_name_uc=$(echo ${PKG_NAME} | tr a-z A-Z); if [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_URL)" ]\ && [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_URLS_GIT)" ]\ @@ -242,26 +238,6 @@ run_cmd_unsplit() { unset _rcu_cmd _rcu_cmdline; return ${_rcu_rc}; }; -set_build_script_done() { - _sbsd_script_fname=${BUILD_PACKAGE_LC}; - _sbsd_done_fname=${WORKDIR}/.${_sbsd_script_fname}; - while [ $# -ge 1 ]; do - if [ "${1#-}" != "${1}" ]; then - secure_rm ${_sbsd_done_fname}.${1#-}; - else - touch ${_sbsd_done_fname}.${1}; - log_msg info "Finished build step ${1} of \`${_sbsd_script_fname}'."; - fi; shift; - done; unset _sbsd_script_fname _sbsd_done_fname; -}; - -set_env_vars_with_sep() { - _sevws_sep=${1}; shift; push_IFS ${_sevws_sep}; set -- ${1}; - while [ ${#} -gt 0 ]; do - export "${1}"; shift; - done; unset _sevws_sep; pop_IFS; -}; - subst_tgts() { while [ ${#} -ge 1 ]; do case "${1}" in diff --git a/subr/pkg_autoconf.subr b/subr/pkg_autoconf.subr index 1896fc1c..6390dc97 100644 --- a/subr/pkg_autoconf.subr +++ b/subr/pkg_autoconf.subr @@ -27,14 +27,13 @@ pkg_autoconf() { break; fi; done; - (cd ${PKG_SUBDIR} && ${SHELL} ./autogen.sh) || exit 1; + (build_fileop cd ${PKG_SUBDIR} && ${SHELL} ./autogen.sh) || exit 1; else - (cd ${PKG_SUBDIR} && autoconf) || exit 1; + (build_fileop cd ${PKG_SUBDIR} && autoconf) || exit 1; fi; fi; for __ in ${PKG_BUILD_DIR} ${PKG_CONFIG_CACHE_EXTRA}; do - echo cp -- ${MIDIPIX_BUILD_PWD}/etc/config.cache ${__}/; - cp -- ${MIDIPIX_BUILD_PWD}/etc/config.cache ${__}/; + build_fileop cp ${MIDIPIX_BUILD_PWD}/etc/config.cache ${__}/; done; fi; set_build_script_done autoconf -patch; diff --git a/subr/pkg_build_dir.subr b/subr/pkg_build_dir.subr index abb852f9..7d500758 100644 --- a/subr/pkg_build_dir.subr +++ b/subr/pkg_build_dir.subr @@ -8,7 +8,7 @@ pkg_build_dir() { set_build_dir ${PKG_SUBDIR} ${PKG_BUILD_TYPE:-native}; fi; if [ ! -d "${PKG_BUILD_DIR}" ]; then - insecure_mkdir ${PKG_BUILD_DIR}; + build_fileop mkdir ${PKG_BUILD_DIR}; fi; set_build_script_done build_dir -patch_pre; }; diff --git a/subr/pkg_configure.subr b/subr/pkg_configure.subr index 501ad710..598c2366 100644 --- a/subr/pkg_configure.subr +++ b/subr/pkg_configure.subr @@ -10,7 +10,7 @@ pkg_configure() { fi; CFLAGS="${PKG_CFLAGS_CONFIGURE}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}"\ LDFLAGS="${PKG_LDFLAGS_CONFIGURE}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}"\ - ${PKG_CONFIGURE} \ + ${PKG_CONFIGURE} \ ${PKG_CONFIGURE_ARGS} ${PKG_CONFIGURE_ARGS_EXTRA} ${PKG_CONFIGURE_ARGS_EXTRA_DEBUG}; fi; set_build_script_done configure clean -build; diff --git a/subr/pkg_distclean.subr b/subr/pkg_distclean.subr index aae22162..ed380727 100644 --- a/subr/pkg_distclean.subr +++ b/subr/pkg_distclean.subr @@ -5,8 +5,8 @@ pkg_distclean() { if [ "${PKG_SUBDIR}" != "${PKG_BUILD_DIR}" ]; then - secure_rm ${PKG_BUILD_DIR}; - insecure_mkdir ${PKG_BUILD_DIR}; + build_fileop rm ${PKG_BUILD_DIR}; + build_fileop mkdir ${PKG_BUILD_DIR}; fi; set_build_script_done distclean -configure; }; diff --git a/subr/pkg_extract.subr b/subr/pkg_extract.subr index 2b7d4fd4..f63cefa0 100644 --- a/subr/pkg_extract.subr +++ b/subr/pkg_extract.subr @@ -6,9 +6,9 @@ pkg_extract() { if [ -n "${PKG_URL}" ]\ && [ "${PKG_URL_TYPE:-wget}" = wget ]; then - secure_rm ${PKG_SUBDIR}; + build_fileop rm ${PKG_SUBDIR}; if [ ${PKG_SUBDIR_CREATE:-0} -eq 1 ]; then - insecure_mkdir ${PKG_SUBDIR}; + build_fileop mkdir ${PKG_SUBDIR}; fi; if [ "${PKG_FNAME##*.tar.}" = "bz2" ]; then bunzip2 -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -; diff --git a/subr/pkg_fetch.subr b/subr/pkg_fetch.subr index beb76e60..f7da99fe 100644 --- a/subr/pkg_fetch.subr +++ b/subr/pkg_fetch.subr @@ -32,20 +32,22 @@ pkgp_fetch_git() { _fg_subdir="${1}"; _fg_url="${2}"; _fg_branch="${3}"; if [ ${ARG_OFFLINE:-0} -eq 0 ]; then if [ -e "${DLCACHEDIR}/${_fg_subdir}" ]; then - cd ${DLCACHEDIR}/${_fg_subdir} &&\ - git pull origin ${_fg_branch:-main} && cd ${OLDPWD}; + build_fileop cd ${DLCACHEDIR}/${_fg_subdir} &&\ + git pull origin ${_fg_branch:-main} &&\ + build_fileop cd ${OLDPWD}; else git clone ${_fg_url} ${DLCACHEDIR}/${_fg_subdir}; if [ -n "${_fg_branch}" -a \ \( -z "${_fg_branch#main}" \) -a \ \( -z "${_fg_branch#master}" \) ]; then - cd ${DLCACHEDIR}/${_fg_subdir} &&\ - git checkout -b ${_fg_branch} && cd ${OLDPWD}; + build_fileop cd ${DLCACHEDIR}/${_fg_subdir} &&\ + git checkout -b ${_fg_branch} &&\ + build_fileop cd ${OLDPWD}; fi; fi; fi; - secure_rm ${_fg_subdir}; - cp -pr ${DLCACHEDIR}/${_fg_subdir} .; + build_fileop rm ${_fg_subdir}; + build_fileop cp ${DLCACHEDIR}/${_fg_subdir} .; }; pkgp_fetch_urls_git() { diff --git a/subr/pkg_install.subr b/subr/pkg_install.subr index 73898337..ad451e80 100644 --- a/subr/pkg_install.subr +++ b/subr/pkg_install.subr @@ -6,7 +6,7 @@ pkgp_install_clean_lib() { if [ -d ${PKG_PREFIX}/lib ]; then for __ in $(find ${PKG_PREFIX}/lib -type f -name \*.la); do - secure_rm ${__}; + build_fileop rm ${__}; done; fi; }; @@ -33,8 +33,7 @@ pkgp_install_dlltool() { -D ${__so_fname} -d ${__so_fname%.so}.def; ${PKG_TARGET}-dlltool -l ${__so_fname%.so}.lib.a \ -D ${__so_fname} -d ${__so_fname%.so}.def; - echo cp -- ${__so_fname%.so}.lib.a "${PKG_PREFIX}/lib"; - cp -- ${__so_fname%.so}.lib.a "${PKG_PREFIX}/lib"; + build_fileop cp ${__so_fname%.so}.lib.a "${PKG_PREFIX}/lib"; fi; done; fi; @@ -71,7 +70,7 @@ pkg_install() { fi; pkgp_install_clean_lib; if [ -n "${PKG_INSTALL_FILES}" ]; then - (install_files -v ${PKG_INSTALL_FILES}); + (install_files -v ${PKG_PREFIX} ${PKG_INSTALL_FILES}); fi; pkgp_install_dlltool; set_build_script_done install -finish; diff --git a/subr/pkg_setup_env.subr b/subr/pkg_setup_env.subr index de304328..9faf3875 100644 --- a/subr/pkg_setup_env.subr +++ b/subr/pkg_setup_env.subr @@ -29,7 +29,7 @@ pkg_setup_env() { if [ "${PKG_SLIBTOOL}" != "default" ]; then export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}"; fi; - cd ${PKG_BUILD_DIR}; + build_fileop cd ${PKG_BUILD_DIR}; set_build_script_done setup distclean -configure; }; diff --git a/subr/post_tarballs.subr b/subr/post_tarballs.subr index 739acdd9..d55d2a41 100644 --- a/subr/post_tarballs.subr +++ b/subr/post_tarballs.subr @@ -84,7 +84,7 @@ post_tarballs() { TARBALL_COMPRESS_ARGS="-T0"; ;; *) log_msg failexit "Unknown tarball suffix \`.${TARBALL_SUFFIX}'."; esac; - cd ${PREFIX}; PREFIX_BASENAME=${PREFIX_NATIVE##*/}; + build_fileop cd ${PREFIX}; PREFIX_BASENAME=${PREFIX_NATIVE##*/}; postp_tarball_dist; postp_tarball_toolchain; postp_tarball_minipix; if [ "${BUILD}" = "debug" ]; then postp_tarball_src; diff --git a/subr/pre_subdirs.subr b/subr/pre_subdirs.subr index 81b89d06..383ab55a 100644 --- a/subr/pre_subdirs.subr +++ b/subr/pre_subdirs.subr @@ -2,31 +2,32 @@ # . ./build.vars and set -o errexit -o noglob are assumed. # -post_subdirs() { +pre_subdirs() { if [ ${ARG_CLEAN:-0} -eq 1 ]; then log_msg info "-c specified, cleaning prefix..."; for __ in ${CLEAR_PREFIX_DIRS}; do if [ -e ${PREFIX}/${__} ]; then - secure_rm ${PREFIX}/${__}; + build_rm ${PREFIX}/${__}; fi; done; fi; - install_files \ - /=${DLCACHEDIR} \ - /=${WORKDIR} \ - /=${PREFIX} \ - /=${PREFIX}/x86_64-w64-mingw32/mingw/include \ - /=${PREFIX_CROSS} \ - /=${PREFIX_MINIPIX}/bin \ - /=${PREFIX_NATIVE} \ - /=${PREFIX_TARGET}/lib \ - @.=${PREFIX}/usr \ - @.=${PREFIX}/x86_64-w64-mingw32/mingw \ - @.=${PREFIX_NATIVE}/usr \ - @bin=${PREFIX_MINIPIX}/lib \ - @bin=${PREFIX_MINIPIX}/libexec \ - @bin=${PREFIX_MINIPIX}/share \ - @share/man=${PREFIX}/man \ + install_files "" \ + /=${DLCACHEDIR} \ + /=${WORKDIR} \ + /=${PREFIX} \ + /=${PREFIX}/x86_64-w64-mingw32 \ + /=${PREFIX_CROSS} \ + /=${PREFIX_MINIPIX}/bin \ + /=${PREFIX_NATIVE} \ + /=${PREFIX_TARGET}/lib \ + @.=${PREFIX}/usr \ + @.=${PREFIX}/x86_64-w64-mingw32/mingw \ + /=${PREFIX}/x86_64-w64-mingw32/mingw/include \ + @.=${PREFIX_NATIVE}/usr \ + @bin=${PREFIX_MINIPIX}/lib \ + @bin=${PREFIX_MINIPIX}/libexec \ + @bin=${PREFIX_MINIPIX}/share \ + @share/man=${PREFIX}/man \ @share/man=${PREFIX_NATIVE}/man; }; |