diff --git a/build-tools/create-yum-conf b/build-tools/create-yum-conf index 80b4ecf7..67a8486f 100755 --- a/build-tools/create-yum-conf +++ b/build-tools/create-yum-conf @@ -63,11 +63,16 @@ if [ ! -f "$MY_YUM_CONF" ]; then mock_cfg_to_yum_conf.py "$MOCK_CFG_PROTO" > "$MY_YUM_CONF" sed -i "s%\[main\]%&\ncachedir=$YUM_CACHE%" "$MY_YUM_CONF" sed -i "s%logfile=.*%logfile=$YUM_DIR/yum.log%" "$MY_YUM_CONF" + # eg: LOCAL_BASE/MY_BUILD_DIR => file:///MY_BUILD_DIR sed -i "s%LOCAL_BASE%file://%g" "$MY_YUM_CONF" sed -i "s%MIRROR_BASE%file:///import/mirrors%g" "$MY_YUM_CONF" sed -i "s%BUILD_ENV%$MY_BUILD_ENVIRONMENT%g" "$MY_YUM_CONF" + # eg: file:///MY_BUILD_DIR => file:///localdisk/loadbuild/... sed -i "s%/MY_BUILD_DIR%$MY_BUILD_DIR%g" "$MY_YUM_CONF" sed -i "s%/MY_REPO_DIR%$MY_REPO%g" "$MY_YUM_CONF" + # eg = MY_BUILD_DIR/xyz => /localdisk/loadbuild/.../xyz + sed -i "s%MY_BUILD_DIR%$MY_BUILD_DIR%g" "$MY_YUM_CONF" + sed -i "s%MY_REPO_DIR%$MY_REPO%g" "$MY_YUM_CONF" else echo "ERROR: Could not find yum.conf or MOCK_CFG_PROTO" exit 1 diff --git a/build-tools/modify-build-cfg b/build-tools/modify-build-cfg index 78658623..6c273f79 100755 --- a/build-tools/modify-build-cfg +++ b/build-tools/modify-build-cfg @@ -83,11 +83,16 @@ if [ ! -f $FILE ]; then exit 1 fi + # eg: LOCAL_BASE/MY_BUILD_DIR => http://127.0.0.1:8088/MY_BUILD_DIR sed -i "s%LOCAL_BASE%http://127.0.0.1:8088%g" "$FILE" sed -i "s%MIRROR_BASE%http://127.0.0.1:8088%g" "$FILE" sed -i "s%BUILD_ENV%$MY_BUILD_ENVIRONMENT%g" "$FILE" + # eg http://127.0.0.1:8088/MY_BUILD_DIR => http://12.0.0.1:8088/localdisk/loadbuild/... sed -i "s%/MY_BUILD_DIR%$MY_BUILD_DIR_TOP%g" "$FILE" sed -i "s%/MY_REPO_DIR%$MY_REPO%g" "$FILE" + # eg = MY_BUILD_DIR/xyz => /localdisk/loadbuild/.../xyz + sed -i "s%MY_BUILD_DIR%$MY_BUILD_DIR_TOP%g" "$FILE" + sed -i "s%MY_REPO_DIR%$MY_REPO%g" "$FILE" # Disable all local-* repos for the build-types other than the current one for bt in std rt; do diff --git a/build-tools/repo_files/mock.cfg.centos7.all.proto b/build-tools/repo_files/mock.cfg.centos7.all.proto index 6d9eb63e..95ed980c 100644 --- a/build-tools/repo_files/mock.cfg.centos7.all.proto +++ b/build-tools/repo_files/mock.cfg.centos7.all.proto @@ -5,6 +5,7 @@ config_opts['chroot_setup_cmd'] = 'install @buildsys-build' config_opts['dist'] = 'el7' # only useful for --resultdir variable subst config_opts['releasever'] = '7' config_opts['package_manager'] = 'yum' +config_opts['yum_builddep_command'] = 'MY_REPO_DIR/build-tools/yum-builddep-wrapper' config_opts['use_bootstrap'] = False config_opts['use_bootstrap_image'] = False config_opts['rpmbuild_networking'] = False diff --git a/build-tools/repo_files/mock.cfg.centos7.distro.proto b/build-tools/repo_files/mock.cfg.centos7.distro.proto index 6d9eb63e..95ed980c 100644 --- a/build-tools/repo_files/mock.cfg.centos7.distro.proto +++ b/build-tools/repo_files/mock.cfg.centos7.distro.proto @@ -5,6 +5,7 @@ config_opts['chroot_setup_cmd'] = 'install @buildsys-build' config_opts['dist'] = 'el7' # only useful for --resultdir variable subst config_opts['releasever'] = '7' config_opts['package_manager'] = 'yum' +config_opts['yum_builddep_command'] = 'MY_REPO_DIR/build-tools/yum-builddep-wrapper' config_opts['use_bootstrap'] = False config_opts['use_bootstrap_image'] = False config_opts['rpmbuild_networking'] = False diff --git a/build-tools/repo_files/mock.cfg.centos7.proto b/build-tools/repo_files/mock.cfg.centos7.proto index 779c5b59..2ca56fdc 100644 --- a/build-tools/repo_files/mock.cfg.centos7.proto +++ b/build-tools/repo_files/mock.cfg.centos7.proto @@ -5,6 +5,7 @@ config_opts['chroot_setup_cmd'] = 'install @buildsys-build' config_opts['dist'] = 'el7' # only useful for --resultdir variable subst config_opts['releasever'] = '7' config_opts['package_manager'] = 'yum' +config_opts['yum_builddep_command'] = 'MY_REPO_DIR/build-tools/yum-builddep-wrapper' config_opts['use_bootstrap'] = False config_opts['use_bootstrap_image'] = False config_opts['rpmbuild_networking'] = False diff --git a/build-tools/yum-builddep-wrapper b/build-tools/yum-builddep-wrapper new file mode 100755 index 00000000..4f82d2d2 --- /dev/null +++ b/build-tools/yum-builddep-wrapper @@ -0,0 +1,66 @@ +#!/bin/bash + +# Old versions of yum-builddep leave a stale yum.pid file behind. +# Remove that file if necessary after yum-builddep exits + +# find yum-builddep +YUM_BUILDDEP=$(which yum-builddep 2>/dev/null) + +# dnf: call it directly +if [[ -z $YUM_BUILDDEP ]] || grep -q -F dnf.cli "$YUM_BUILDDEP" ; then + yum-builddep "$@" + exit $? +fi + + +# old yum: scan command line for --installroot +ROOT_PREFIX= +YUM_CONF=/etc/yum.conf +find_root_prefix() { + while [[ "$#" -gt 0 ]] ; do + case "$1" in + --installroot) + ROOT_PREFIX="$2" + shift + ;; + --installroot=*) + ROOT_PREFIX="${1#*=}" + ;; + -c|--config) + YUM_CONF="$2" + shift + ;; + --config=*) + YUM_CONF="${1#*=}" + ;; + esac + shift + done + if [[ -z "$ROOT_PREFIX" ]] && [[ -f "$YUM_CONF" ]] ; then + ROOT_PREFIX=$(sed -rn 's/^\s*installroot\s*=\s*(\S+)\s*$/\1/p' $YUM_CONF) + fi +} +find_root_prefix "$@" + +# ignore signals -- always wait for yum-builddep +trap "" INT TERM HUP PIPE + +# run it in the background to get its PID +"$YUM_BUILDDEP" "$@" & +pid="$!" + +# wait for it +wait "$pid" +res="$?" + +# if yum.pid remains and contains yum-builddep's PID, delete it +if [[ -f "${ROOT_PREFIX}/run/yum.pid" ]] ; then + lock_owner= + read lock_owner <"${ROOT_PREFIX}/run/yum.pid" || : + if [[ -n $lock_owner && $lock_owner == $pid ]] ; then + rm -f "${ROOT_PREFIX}/run/yum.pid" + fi +fi + +# done +exit $res