update to attempt to solve bug which could delete empty dirs in /etc
This commit is contained in:
parent
29c8de2daa
commit
85ac4b99f5
@ -7,8 +7,8 @@ Name: copy-jdk-configs
|
||||
|
||||
# hash relevant to version tag
|
||||
%global htag 88d3ed89f30d8b0eb4877d860fa8d951f224f156
|
||||
Version: 4.0
|
||||
Release: 4%{?dist}
|
||||
Version: 4.1
|
||||
Release: 0%{?dist}
|
||||
Summary: JDKs configuration files copier
|
||||
|
||||
License: BSD
|
||||
@ -75,6 +75,9 @@ rm "%{rpm_state_dir}/%{file}" 2> /dev/null || :
|
||||
%license LICENSE
|
||||
|
||||
%changelog
|
||||
* Wed Sep 28 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.1-0
|
||||
- update to attempt to solve bug which could delete empty dirs in /etc
|
||||
|
||||
* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.0-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||
|
||||
|
@ -10,6 +10,20 @@ debug(){
|
||||
|
||||
debug "cjc: bash debug is on"
|
||||
|
||||
isJavaConfig() {
|
||||
local arg="${1}"
|
||||
local relpath=`realpath -s $arg`
|
||||
local realink=`readlink -f $arg`
|
||||
if [[ ${relpath} = /usr/lib/jvm/java* || ${relpath} = /etc/java/java* ]] ; then
|
||||
if [[ ${realink} = /usr/lib/jvm/java* || ${realink} = /etc/java/java* ]] ; then
|
||||
debug "$arg / ${relpath} / ${realink} is correct jdk folder"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
debug "$arg / ${relpath} / ${realink} is not jdk folder, file/dir should be skipped"
|
||||
return 1
|
||||
}
|
||||
|
||||
cmdvDebug() {
|
||||
if [ "x$debug" == "xtrue" ] ; then
|
||||
"$@" -v
|
||||
@ -23,11 +37,19 @@ mvDebug() {
|
||||
}
|
||||
|
||||
rmDebug() {
|
||||
cmdvDebug rm "$@"
|
||||
for x in "$@" ; do
|
||||
if isJavaConfig "$x" ; then
|
||||
cmdvDebug rm "$@"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
rmdirDebug() {
|
||||
cmdvDebug rmdir "$@"
|
||||
for x in "$@" ; do
|
||||
if isJavaConfig "$x" ; then
|
||||
cmdvDebug rmdir "$@"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#we should be pretty strict about removing once used (even "used" [with fail]) config file, as it may corrupt another installation
|
||||
@ -225,9 +247,12 @@ done
|
||||
|
||||
debug "cleaning legacy leftowers"
|
||||
if [ "x$debug" == "xtrue" ] ; then
|
||||
find $sourceSearchPath -empty -type d -delete
|
||||
emptyCandidates=`find $sourceSearchPath -empty -type d`
|
||||
else
|
||||
find $sourceSearchPath -empty -type d -delete 2>/dev/null >/dev/null
|
||||
emptyCandidates=`find $sourceSearchPath -empty -type d 2>/dev/null`
|
||||
fi
|
||||
if [ ! "x$emptyCandidates" == "x" ] ; then
|
||||
rmdirDebug $emptyCandidates
|
||||
fi
|
||||
rmdirDebug $sourceSearchPath
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user