diff --git a/SOURCES/copy_jdk_configs.lua b/SOURCES/copy_jdk_configs.lua index 8e8c853..02b94b3 100755 --- a/SOURCES/copy_jdk_configs.lua +++ b/SOURCES/copy_jdk_configs.lua @@ -15,6 +15,7 @@ local origname = nil local origjavaver = nil local arch = nil local debug = false; +local temp = nil; for i=1,#arg,2 do if (arg[i] == "--help" or arg[i] == "-h") then @@ -33,6 +34,8 @@ for i=1,#arg,2 do print(" Migration/testing switch. Target Mostly same as jvmdir, but you may wont to copy ouside it.") print(" --debug") print(" Enables printing out whats going on. true/false") + print(" --temp") + print(" optional file to save intermediate result - directory configs were copied from") os.exit(0) end if (arg[i] == "--currentjvm") then @@ -59,9 +62,12 @@ for i=1,#arg,2 do debug = true end end + if (arg[i] == "--temp") then + temp=arg[i+1] + end end -if (jvmDestdir == nill) then +if (jvmDestdir == nil) then jvmDestdir = jvmdir end @@ -104,7 +110,41 @@ local caredFiles = {"jre/lib/calendars.properties", "jre/lib/security/java.security", "jre/lib/security/local_policy.jar", "jre/lib/security/nss.cfg", - "jre/lib/ext"} + "jre/lib/security/cacerts", + "jre/lib/security/blacklisted.certs", + "jre/lib/ext", + "lib/calendars.properties", + "lib/content-types.properties", + "lib/flavormap.properties", + "lib/logging.properties", + "lib/net.properties", + "lib/psfontj2d.properties", + "lib/sound.properties", + "lib/deployment.properties", + "lib/deployment.config", + "lib/security/US_export_policy.jar", + "lib/security/java.policy", + "lib/security/java.security", + "lib/security/local_policy.jar", + "lib/security/nss.cfg", + "lib/security/cacerts", + "lib/security/blacklisted.certs", + "lib/security/default.policy", + "conf/security/policy/limited/exempt_local.policy", + "conf/security/policy/limited/default_local.policy", + "conf/security/policy/limited/default_US_export.policy", + "conf/security/policy/unlimited/default_local.policy", + "conf/security/policy/unlimited/default_US_export.policy", + "conf/security/java.policy", + "conf/security/java.security", + "conf/logging.properties", + "conf/security/nss.cfg", + "conf/management/jmxremote.access", + "conf/management/jmxremote.password.template", + "conf/management/management.properties", + "conf/net.properties", + "conf/sound.properties", + "lib/ext"} function splitToTable(source, pattern) local i1 = string.gmatch(source, pattern) @@ -143,7 +183,11 @@ for i,p in pairs(foundJvms) do end; return end ; - table.insert(jvms, p) + if (string.match(p, ".*-debug$")) then + print(p.." matched but seems to be debug variant. Skipping") + else + table.insert(jvms, p) + end else if (debug) then print("NOT matched: "..p) @@ -194,6 +238,16 @@ end latestjvm = jvms[#jvms] +if ( temp ~= nil ) then + src=jvmdir.."/"..latestjvm + if (debug) then + print("temp declared as "..temp.." saving used dir of "..src) + end + file = io.open (temp, "w") + file:write(src) + file:close() +end + for i,file in pairs(caredFiles) do local SOURCE=jvmdir.."/"..latestjvm.."/"..file diff --git a/SOURCES/copy_jdk_configs_fixFiles.sh b/SOURCES/copy_jdk_configs_fixFiles.sh new file mode 100755 index 0000000..d027784 --- /dev/null +++ b/SOURCES/copy_jdk_configs_fixFiles.sh @@ -0,0 +1,169 @@ +#!/bin/bash +config=$1 +target=$2 + +debug="false" + +rma="" + if [ "x$debug" == "xtrue" ] ; then + rma="-v" + fi + +debug(){ + if [ "x$debug" == "xtrue" ] ; then + echo "$1" + fi +} + +#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" == "x$config" ] ; then + debug "no config file specified" + exit 1 +fi + +if [ ! -f "$config" ] ; then + debug "$config file do not exists" + # expected case, when no migration happened + exit 0 +fi + +if [ "x" == "x$target" ] ; then + debug "no target dir specified" + clean + exit 2 +fi + +if [ ! -d "$target" ] ; then + debug "$target is not directory" + clean + exit 22 +fi + +source=`cat $config` + +if [ "x" == "x$source" ] ; then + debug "no information in $config" + clean + exit 3 +fi + +if [ ! -d "$source" ] ; then + debug "$source from $config is not directory" + clean + exit 33 +fi + +debug "source: $source" +debug "target: $target" + +work(){ + if [ "X$1" == "Xrpmnew" -o "X$1" == "Xrpmorig" ] ; then + debug "Working with $1 (1)" + else + debug "unknown parameter: $1" + return 1 + fi + + local files=`find $target | grep "\\.$1$"` + for file in $files ; do + local sf1=`echo $file | sed "s/\\.$1$//"` + local sf2=`echo $sf1 | sed "s/$targetName/$srcName/"` + # was file modified in origianl installation? + rpm -Vf $source | grep -q $sf2 + if [ $? -gt 0 ] ; then + if [ "X$1" == "Xrpmnew" ] ; then + debug "$sf2 was NOT modified, removing possibly corrupted $sf1 and renaming from $file" + rm $rma $sf1 + mv $rma $file $sf1 + if [ $? -eq 0 ] ; then + echo "restored $file to $sf1" + else + echo "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 + 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 + # or its corresponding backup + rm -f $rma $sf2.$1 + fi +done +} + + +srcName=`basename $source` +targetName=`basename $target` + +work rpmnew +work rpmorig + +debug "Working with rpmorig (2)" +# simply moving old rpmsaves to new dir +# fix for config (replace) leftovers +files=`find $source | grep "\\.rpmorig$"` + for file in $files ; do + rpmsaveTarget=`echo $file | sed "s/$srcName/$targetName/"` + debug "relocating $file to $rpmsaveTarget" + if [ -e $rpmsaveTarget ] ; then + rm $rma $file + else + mv $rma $file $rpmsaveTarget + fi + done + +debug "Working with rpmsave (1)" +files=`find $source | grep "\\.rpmsave$"` + for file in $files ; do + rpmsaveTarget=`echo $file | sed "s/$srcName/$targetName/"` + debug "relocating $file to $rpmsaveTarget" + if [ -e $rpmsaveTarget ] ; then + rm $rma $file + else + mv $rma $file $rpmsaveTarget + fi + done + + +#warning: file /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64-debug/jre/lib/applet: remove failed: No such file or directory +#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 +#those dirs might be mepty by installtion, filling to not be rmeoved later +blackdirs="$source/jre/lib/applet $source/jre/lib/*/client" +for blackdir in $blackdirs; do + if [ -e $blackdir ] ; then + debug "nasty $blackdir exists, filling" + touch $blackdir/C-J-C_placeholder + else + debug "nasty $blackdir DONT exists, ignoring" + fi +done + +debug "cleaning legacy leftowers" +if [ "x$debug" == "xtrue" ] ; then + find $source -empty -type d -delete + rmdir $rma $source +else + find $source -empty -type d -delete 2>/dev/null >/dev/null + rmdir $rma $source 2>/dev/null >/dev/null +fi + +# and remove placeholders +for blackdir in $blackdirs; do + if [ -e $blackdir ] ; then + debug "nasty $blackdir exists, cleaning placeholder" + rm $blackdir/C-J-C_placeholder + else + debug "nasty $blackdir DONT exists, ignoring again" + fi +done + +clean diff --git a/SPECS/copy-jdk-configs.spec b/SPECS/copy-jdk-configs.spec index 01da2d8..08a6669 100644 --- a/SPECS/copy-jdk-configs.spec +++ b/SPECS/copy-jdk-configs.spec @@ -1,17 +1,21 @@ %global project copy_jdk_configs %global file %{project}.lua +%global fixFile %{project}_fixFiles.sh %global rpm_state_dir %{_localstatedir}/lib/rpm-state Name: copy-jdk-configs -Version: 1.2 -Release: 1%{?dist} +# hash relevant to version tag +%global htag 3f9d6c4448f867a95fb166416a41c45c7e795c10 +Version: 2.2 +Release: 3%{?dist} Summary: JDKs configuration files copier License: BSD -URL: https://hg.fedorahosted.org/hg/%{project} -Source0: https://hg.fedorahosted.org/hg/copy_jdk_configs/raw-file/%{project}-%{version}/%{file} -Source1: https://hg.fedorahosted.org/hg/copy_jdk_configs/raw-file/%{project}-%{version}/LICENSE +URL: https://pagure.io/%{project} +Source0: %{URL}/blob/%{htag}/f/%{file} +Source1: %{URL}/blob/%{htag}/f/LICENSE +Source2: %{URL}/blob/%{htag}/f/%{fixFile} # we need to duplicate msot of the percents in that script so they survive rpm expansion (even in that sed they have to be duplicated) %global pretrans_install %(cat %{SOURCE0} | sed s/%%/%%%%/g | sed s/\\^%%%%/^%%/g) @@ -23,7 +27,7 @@ Requires: lua %description Utility script to transfer JDKs configuration files between updates or for -archiving. +archiving. With script to fix incorrectly created rpmnew files %prep cp -a %{SOURCE1} . @@ -56,6 +60,7 @@ end mkdir -p $RPM_BUILD_ROOT/%{_libexecdir} cp -a %{SOURCE0} $RPM_BUILD_ROOT/%{_libexecdir}/%{file} chmod 644 $RPM_BUILD_ROOT/%{_libexecdir}/%{file} +cp -a %{SOURCE2} $RPM_BUILD_ROOT/%{_libexecdir}/%{fixFile} %posttrans # remove file created in pretrans @@ -64,9 +69,26 @@ rm "%{rpm_state_dir}/%{file}" 2> /dev/null || : %files %{_libexecdir}/%{file} +%{_libexecdir}/%{fixFile} %license LICENSE %changelog +* Mon Jun 19 2017 Jiri Vanek - 2.2-3 +- updated to latest head +- Resolves: rhbz#1427463 + +* Tue Jun 13 2017 Jiri Vanek - 2.2-1 +- added "jre/lib/security/blacklisted.certs" to cared files +- moved to newest release 2.1 +- moved to new upstream at pagure.io +- added new script of copy_jdk_configs_fixFiles.sh +- copy_jdk_configs.lua aligned to it +- Resolves: rhbz#1427463 + +* Tue Dec 01 2016 Jiri Vanek - 1.3-1 +- updated to upstream 1.3 (adding jre/lib/security/cacerts file) +- Resolves: rhbz#1399719 + * Tue Aug 09 2016 Jiri Vanek - 1.2-1 - updated to 1,3 which fixing nss minor issue - Resolves: rhbz#1296430