diff --git a/SOURCES/copy_jdk_configs_fixFiles.sh b/SOURCES/copy_jdk_configs_fixFiles.sh index 964f607..2e5d603 100755 --- a/SOURCES/copy_jdk_configs_fixFiles.sh +++ b/SOURCES/copy_jdk_configs_fixFiles.sh @@ -2,23 +2,70 @@ config=$1 target=$2 -debug="false" - -rma="" +debug(){ if [ "x$debug" == "xtrue" ] ; then - rma="-v" + echo "$@" fi +} -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 - echo "$1" + "$@" -v + else + "$@" 1>/dev/null 2>&1 fi } +mvDebug() { + cmdvDebug mv "$@" +} + +rmDebug() { + local switch="" + for x in "$@" ; do + if [[ $x == -* ]] ; then + switch="$switch $x" + elif isJavaConfig "$x" ; then + cmdvDebug rm $switch "$x" + fi + done +} + +rmdirDebug() { + local switch="" + for x in "$@" ; do + if [[ $x == -* ]] ; then + switch="$switch $x" + elif isJavaConfig "$x" ; then + cmdvDebug rmdir $switch "$x" + fi + done +} + #we should be pretty strict about removing once used (even "used" [with fail]) config file, as it may corrupt another installation clean(){ debug "cleanup: removing $config" - rm -rf $config + if [ "x$debug" == "xtrue" ] ; then + rm -rf $config -v + else + rm -rf $config 1>/dev/null 2>&1 + fi } if [ "x" == "x$config" ] ; then @@ -133,23 +180,23 @@ work(){ if [ $? -gt 0 ] ; then if [ "X$1" == "Xrpmnew" ] ; then debug "$sf2 was NOT modified, removing possibly corrupted $sf1 and renaming from $file" - mv $rma -f $file $sf1 + mvDebug -f $file $sf1 if [ $? -eq 0 ] ; then echo "restored $file to $sf1" else - echo "FAILED to restore $file to $sf1" + debug "FAILED to restore $file to $sf1" fi fi if [ "X$1" == "Xrpmorig" ] ; then debug "$sf2 was NOT modified, removing possibly corrupted $file" - rm $rma $file + rmDebug $file fi else debug "$sf2 was modified, keeping $file, and removing the duplicated original" # information is now backuped, in new directory anyway. Removing future rpmsave to allow rpm -e - rm -f $rma $sf2 + rmDebug -f $sf2 # or its corresponding backup - rm -f $rma $sf2.$1 + rmDebug -f $sf2.$1 fi done } @@ -169,9 +216,9 @@ files=`find $sourceSearchPath | grep "\\.rpmorig$"` rpmsaveTarget=`echo $file | sed "s/$srcName/$targetName/"` debug "relocating $file to $rpmsaveTarget" if [ -e $rpmsaveTarget ] ; then - rm $rma $file + rmDebug $file else - mv $rma $file $rpmsaveTarget + mvDebug $file $rpmsaveTarget fi done @@ -181,9 +228,9 @@ files=`find $sourceSearchPath | grep "\\.rpmsave$"` rpmsaveTarget=`echo $file | sed "s/$srcName/$targetName/"` debug "relocating $file to $rpmsaveTarget" if [ -e $rpmsaveTarget ] ; then - rm $rma $file + rmDebug $file else - mv $rma $file $rpmsaveTarget + mvDebug $file $rpmsaveTarget fi done @@ -192,7 +239,13 @@ files=`find $sourceSearchPath | grep "\\.rpmsave$"` #warning: file /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64-debug/jre/lib/amd64/client: remove failed: No such file or directory #warning: file /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64/jre/lib/amd64/xawt: remove failed: No such file or directory #those dirs might be mepty by installtion, filling to not be rmeoved later -blackdirs="$source/jre/lib/applet $source/jre/lib/*/client $source/jre/lib/locale/*/LC_MESSAGE $source/jre/lib/*/xawt" +#use exported CJC_BLACKDIRS_ADD to extend it in runtime/spec file +blackdirs="" +internal_blackdirs="jre/lib/applet jre/lib/*/client jre/lib/locale/*/LC_MESSAGES jre/lib/*/xawt jre/javaws properties/version properties jre/lib/endorsed jre/lib/boot lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/profileRegistry/JMC.profile/.data" +for x in $internal_blackdirs $CJC_BLACKDIRS_ADD ; do + blackdirs="$blackdirs $source/$x" +done + for blackdir in $blackdirs; do if [ -e $blackdir ] ; then debug "nasty $blackdir exists, filling" @@ -204,21 +257,25 @@ done debug "cleaning legacy leftowers" if [ "x$debug" == "xtrue" ] ; then - find $sourceSearchPath -empty -type d -delete - rmdir $rma $sourceSearchPath + emptyCandidates=`find $sourceSearchPath -empty -type d` else - find $sourceSearchPath -empty -type d -delete 2>/dev/null >/dev/null - rmdir $rma $sourceSearchPath 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 # and remove placeholders for blackdir in $blackdirs; do if [ -e $blackdir ] ; then debug "nasty $blackdir exists, cleaning placeholder" - rm $blackdir/C-J-C_placeholder + rmDebug $blackdir/C-J-C_placeholder else debug "nasty $blackdir DONT exists, ignoring again" fi done clean + +exit 0 diff --git a/SPECS/copy-jdk-configs.spec b/SPECS/copy-jdk-configs.spec index 6d6c08d..2005259 100644 --- a/SPECS/copy-jdk-configs.spec +++ b/SPECS/copy-jdk-configs.spec @@ -8,7 +8,7 @@ Name: copy-jdk-configs # hash relevant to version tag %global htag ed45a7dce13fab490529d4d13a064d379c8f66e7 Version: 3.3 -Release: 10%{?dist} +Release: 11%{?dist} Summary: JDKs configuration files copier License: BSD @@ -73,13 +73,17 @@ rm "%{rpm_state_dir}/%{file}" 2> /dev/null || : %license LICENSE %changelog +* Wed Oct 05 2018 Jiri Vanek - 3.3-11 +- Fixing deletation ofemtpy dirs via rogue symlink +- Resolves: rhbz#2100617 + * Mon Apr 30 2018 Jiri Vanek - 3.3-10 - added javaws.policy and blacklist -- Resolves: rhbz#1573163 +- Resolves: rhbz#1571854 * Wed Apr 25 2018 Jiri Vanek - 3.3-3 - fixes issue when java.security for openjdk7 was erased -- Resolves: rhbz#1573163 +- Resolves: rhbz#1571854 * Fri Nov 03 2017 Jiri Vanek - 3.3-2 - added another subdirs for policies files