centos7: delete yum.pid after yum-builddep
Pre-dnf yum-builddep leaves a stale yum.pid file behind with its own process ID. If that PID happens to be reused and match an existing process, a subsequent yum & co invocation hangs. Solution: create a wrapper script that deletes the pid file if necessary. Change-Id: I821643f576645d78ab1c29cdccefa12740bbc12f Closes-Bug: 1920805 Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
This commit is contained in:
parent
290b3ea8d2
commit
3ef97d279c
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
66
build-tools/yum-builddep-wrapper
Executable file
66
build-tools/yum-builddep-wrapper
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user