import copy-jdk-configs-4.0-3.el9
This commit is contained in:
commit
2eae39ae76
0
.copy-jdk-configs.metadata
Normal file
0
.copy-jdk-configs.metadata
Normal file
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
14
SOURCES/LICENSE
Normal file
14
SOURCES/LICENSE
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Copyright (c) 2015 Red Hat inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms are permitted
|
||||||
|
provided that the above copyright notice and this paragraph are
|
||||||
|
duplicated in all such forms and that any documentation,
|
||||||
|
advertising materials, and other materials related to such
|
||||||
|
distribution and use acknowledge that the software was developed
|
||||||
|
by the Red Hat inc. The name of the Red Hat inc. may not be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission. THIS SOFTWARE IS PROVIDED
|
||||||
|
``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||||
|
WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE.
|
358
SOURCES/copy_jdk_configs.lua
Executable file
358
SOURCES/copy_jdk_configs.lua
Executable file
@ -0,0 +1,358 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
-- rpm call
|
||||||
|
-- debug=true lua -- copy_jdk_configs.lua --currentjvm "%{uniquesuffix %{nil}}" --jvmdir "%{_jvmdir %{nil}}" --origname "%{name}" --origjavaver "%{javaver}" --arch "%{_arch}"
|
||||||
|
--test call
|
||||||
|
-- debug=true lua -- copy_jdk_configs.lua --currentjvm "java-1.8.0-openjdk-1.8.0.65-3.b17.fc22.x86_64" --jvmdir "/usr/lib/jvm" --origname "java-1.8.0-openjdk" --origjavaver "1.8.0" --arch "x86_64" --jvmDestdir /home/jvanek/Desktop
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
if (os.getenv("debug") == "true") then
|
||||||
|
debug = true;
|
||||||
|
else
|
||||||
|
debug = false;
|
||||||
|
end
|
||||||
|
|
||||||
|
local function debugOneLinePrint(string)
|
||||||
|
if (debug) then
|
||||||
|
print(string)
|
||||||
|
end ;
|
||||||
|
end
|
||||||
|
|
||||||
|
function getPath(str, sep)
|
||||||
|
sep = sep or '/'
|
||||||
|
return str:match("(.*" .. sep .. ")")
|
||||||
|
end
|
||||||
|
|
||||||
|
function splitToTable(source, pattern)
|
||||||
|
local i1 = string.gmatch(source, pattern)
|
||||||
|
local l1 = {}
|
||||||
|
for i in i1 do
|
||||||
|
table.insert(l1, i)
|
||||||
|
end
|
||||||
|
return l1
|
||||||
|
end
|
||||||
|
|
||||||
|
local function slurp(path)
|
||||||
|
local f = io.open(path)
|
||||||
|
local s = f:read("*a")
|
||||||
|
f:close()
|
||||||
|
return s
|
||||||
|
end
|
||||||
|
|
||||||
|
function trim(s)
|
||||||
|
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function dirWithParents(path)
|
||||||
|
local s = ""
|
||||||
|
local dirs = splitToTable(path, "[^/]+")
|
||||||
|
for i, d in pairs(dirs) do
|
||||||
|
if (i == #dirs) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
s = s .. "/" .. d
|
||||||
|
local stat2 = posix.stat(s, "type");
|
||||||
|
if (stat2 == nil) then
|
||||||
|
debugOneLinePrint(s .. " does not exists, creating")
|
||||||
|
if (not dry) then
|
||||||
|
posix.mkdir(s)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
debugOneLinePrint(s .. " exists,not creating")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- main function,
|
||||||
|
-- formelry main body
|
||||||
|
-- move to function resolved
|
||||||
|
-- https://bugzilla.redhat.com/show_bug.cgi?id=1892224
|
||||||
|
-- for readability not indented, todo, indent once tuned
|
||||||
|
|
||||||
|
function M.mainProgram(arg)
|
||||||
|
debugOneLinePrint("cjc: lua debug on")
|
||||||
|
local caredFiles = { "jre/lib/calendars.properties",
|
||||||
|
"jre/lib/content-types.properties",
|
||||||
|
"jre/lib/flavormap.properties",
|
||||||
|
"jre/lib/logging.properties",
|
||||||
|
"jre/lib/net.properties",
|
||||||
|
"jre/lib/psfontj2d.properties",
|
||||||
|
"jre/lib/sound.properties",
|
||||||
|
"jre/lib/deployment.properties",
|
||||||
|
"jre/lib/deployment.config",
|
||||||
|
"jre/lib/security/US_export_policy.jar",
|
||||||
|
"jre/lib/security/unlimited/US_export_policy.jar",
|
||||||
|
"jre/lib/security/limited/US_export_policy.jar",
|
||||||
|
"jre/lib/security/policy/unlimited/US_export_policy.jar",
|
||||||
|
"jre/lib/security/policy/limited/US_export_policy.jar",
|
||||||
|
"jre/lib/security/java.policy",
|
||||||
|
"jre/lib/security/java.security",
|
||||||
|
"jre/lib/security/local_policy.jar",
|
||||||
|
"jre/lib/security/unlimited/local_policy.jar",
|
||||||
|
"jre/lib/security/limited/local_policy.jar",
|
||||||
|
"jre/lib/security/policy/unlimited/local_policy.jar",
|
||||||
|
"jre/lib/security/policy/limited/local_policy.jar",
|
||||||
|
"jre/lib/security/nss.cfg",
|
||||||
|
"jre/lib/security/cacerts",
|
||||||
|
"jre/lib/security/blacklisted.certs",
|
||||||
|
"jre/lib/security/jssecacerts",
|
||||||
|
"jre/lib/security/trusted.certs",
|
||||||
|
"jre/lib/security/trusted.jssecerts",
|
||||||
|
"jre/lib/security/trusted.clientcerts",
|
||||||
|
"jre/lib/ext",
|
||||||
|
"jre/lib/security/blacklist",
|
||||||
|
"jre/lib/security/javaws.policy",
|
||||||
|
"jre/lib/security/nss.fips.cfg",
|
||||||
|
"lib/security",
|
||||||
|
"conf",
|
||||||
|
"lib/ext" }
|
||||||
|
|
||||||
|
-- before import to allow run from spec
|
||||||
|
if (arg[1] == "--list") then
|
||||||
|
for i, file in pairs(caredFiles) do
|
||||||
|
print(file)
|
||||||
|
end
|
||||||
|
return 0;
|
||||||
|
end
|
||||||
|
|
||||||
|
-- yum install lua-posix
|
||||||
|
local posix = require "posix"
|
||||||
|
|
||||||
|
-- the one we are installing
|
||||||
|
local currentjvm = nil
|
||||||
|
local jvmdir = nil
|
||||||
|
local jvmDestdir = nil
|
||||||
|
local origname = nil
|
||||||
|
local origjavaver = nil
|
||||||
|
local arch = nil
|
||||||
|
local temp = nil;
|
||||||
|
local dry = false;
|
||||||
|
|
||||||
|
for i = 1, #arg, 2 do
|
||||||
|
if (arg[i] == "--help" or arg[i] == "-h") then
|
||||||
|
print("all but jvmDestdir and debug are mandatory")
|
||||||
|
print(" --currentjvm")
|
||||||
|
print(" NVRA of currently installed java")
|
||||||
|
print(" --jvmdir")
|
||||||
|
print(" Directory where to find this kind of virtual machine. Generally /usr/lib/jvm")
|
||||||
|
print(" --origname")
|
||||||
|
print(" convinient switch to determine jdk. Generally java-1.X.0-vendor")
|
||||||
|
print(" --origjavaver")
|
||||||
|
print(" convinient switch to determine jdk's version. Generally 1.X.0")
|
||||||
|
print(" --arch")
|
||||||
|
print(" convinient switch to determine jdk's arch")
|
||||||
|
print(" --jvmDestdir")
|
||||||
|
print(" Migration/testing switch. Target Mostly same as jvmdir, but you may wont to copy ouside it.")
|
||||||
|
print(" --debug or $debug")
|
||||||
|
print(" Enables printing out whats going on. true/false. False by default")
|
||||||
|
print(" --temp")
|
||||||
|
print(" optional file to save intermediate result - directory configs were copied from")
|
||||||
|
print(" --dry")
|
||||||
|
print(" true/fase if true, then no changes will be written to disk except one tmp file. False by default")
|
||||||
|
print(" **** specil parasm ****")
|
||||||
|
print(" --list")
|
||||||
|
print(" if present on cmdline, list all cared files and exists")
|
||||||
|
os.exit(0)
|
||||||
|
end
|
||||||
|
if (arg[i] == "--currentjvm") then
|
||||||
|
currentjvm = arg[i + 1]
|
||||||
|
end
|
||||||
|
if (arg[i] == "--jvmdir") then
|
||||||
|
jvmdir = arg[i + 1]
|
||||||
|
end
|
||||||
|
if (arg[i] == "--origname") then
|
||||||
|
origname = arg[i + 1]
|
||||||
|
end
|
||||||
|
if (arg[i] == "--origjavaver") then
|
||||||
|
origjavaver = arg[i + 1]
|
||||||
|
end
|
||||||
|
if (arg[i] == "--arch") then
|
||||||
|
arch = arg[i + 1]
|
||||||
|
end
|
||||||
|
if (arg[i] == "--jvmDestdir") then
|
||||||
|
jvmDestdir = arg[i + 1]
|
||||||
|
end
|
||||||
|
if (arg[i] == "--debug") then
|
||||||
|
--no string, boolean, workaround
|
||||||
|
if (arg[i + 1] == "true") then
|
||||||
|
debug = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (arg[i] == "--dry") then
|
||||||
|
--no string, boolean, workaround
|
||||||
|
if (arg[i + 1] == "true") then
|
||||||
|
dry = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (arg[i] == "--temp") then
|
||||||
|
temp = arg[i + 1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (jvmDestdir == nil) then
|
||||||
|
jvmDestdir = jvmdir
|
||||||
|
end
|
||||||
|
|
||||||
|
if (debug) then
|
||||||
|
print("--currentjvm:");
|
||||||
|
print(currentjvm);
|
||||||
|
print("--jvmdir:");
|
||||||
|
print(jvmdir);
|
||||||
|
print("--jvmDestdir:");
|
||||||
|
print(jvmDestdir);
|
||||||
|
print("--origname:");
|
||||||
|
print(origname);
|
||||||
|
print("--origjavaver:");
|
||||||
|
print(origjavaver);
|
||||||
|
print("--arch:");
|
||||||
|
print(arch);
|
||||||
|
print("--debug:");
|
||||||
|
print(debug);
|
||||||
|
end
|
||||||
|
|
||||||
|
--trasnform substitute names to lua patterns
|
||||||
|
local name = string.gsub(string.gsub(origname, "%-", "%%-"), "%.", "%%.")
|
||||||
|
local javaver = string.gsub(origjavaver, "%.", "%%.")
|
||||||
|
|
||||||
|
local jvms = { }
|
||||||
|
|
||||||
|
debugOneLinePrint("started")
|
||||||
|
|
||||||
|
foundJvms = posix.dir(jvmdir);
|
||||||
|
if (foundJvms == nil) then
|
||||||
|
debugOneLinePrint("no, or nothing in " .. jvmdir .. " exit")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
debugOneLinePrint("found " .. #foundJvms .. " jvms")
|
||||||
|
|
||||||
|
for i, p in pairs(foundJvms) do
|
||||||
|
-- regex similar to %{_jvmdir}/%{name}-%{javaver}*%{_arch} bash command
|
||||||
|
if (string.find(p, name .. "%-" .. javaver .. ".*" .. arch) ~= nil) then
|
||||||
|
debugOneLinePrint("matched: " .. p)
|
||||||
|
if (currentjvm == p) then
|
||||||
|
debugOneLinePrint("this jdk is already installed. exiting lua script")
|
||||||
|
return
|
||||||
|
end ;
|
||||||
|
if (string.match(p, ".*-debug$")) then
|
||||||
|
print(p .. " matched but seems to be debug variant. Skipping")
|
||||||
|
else
|
||||||
|
table.insert(jvms, p)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
debugOneLinePrint("NOT matched: " .. p)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (#jvms <= 0) then
|
||||||
|
debugOneLinePrint("no matching jdk in " .. jvmdir .. " exit")
|
||||||
|
return
|
||||||
|
end ;
|
||||||
|
|
||||||
|
debugOneLinePrint("matched " .. #jvms .. " jdk in " .. jvmdir)
|
||||||
|
|
||||||
|
--full names are like java-1.7.0-openjdk-1.7.0.60-2.4.5.1.fc20.x86_64
|
||||||
|
table.sort(jvms, function(a, b)
|
||||||
|
-- version-sort
|
||||||
|
-- split on non word: . -
|
||||||
|
local l1 = splitToTable(a, "[^%.-]+")
|
||||||
|
local l2 = splitToTable(b, "[^%.-]+")
|
||||||
|
for x = 1, math.min(#l1, #l2) do
|
||||||
|
local l1x = tonumber(l1[x])
|
||||||
|
local l2x = tonumber(l2[x])
|
||||||
|
if (l1x ~= nil and l2x ~= nil) then
|
||||||
|
--if hunks are numbers, go with them
|
||||||
|
if (l1x < l2x) then
|
||||||
|
return true;
|
||||||
|
end
|
||||||
|
if (l1x > l2x) then
|
||||||
|
return false;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if (l1[x] < l2[x]) then
|
||||||
|
return true;
|
||||||
|
end
|
||||||
|
if (l1[x] > l2[x]) then
|
||||||
|
return false;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- if hunks are equals then move to another pair of hunks
|
||||||
|
end
|
||||||
|
return a < b
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
if (debug) then
|
||||||
|
print("sorted lsit of jvms")
|
||||||
|
for i, file in pairs(jvms) do
|
||||||
|
print(file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
latestjvm = jvms[#jvms]
|
||||||
|
|
||||||
|
if (temp ~= nil) then
|
||||||
|
src = jvmdir .. "/" .. latestjvm
|
||||||
|
debugOneLinePrint("temp declared as " .. temp .. " saving used dir of " .. src)
|
||||||
|
file = io.open(temp, "w")
|
||||||
|
file:write(src)
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
local readlinkOutput = os.tmpname()
|
||||||
|
|
||||||
|
for i, file in pairs(caredFiles) do
|
||||||
|
local SOURCE = jvmdir .. "/" .. latestjvm .. "/" .. file
|
||||||
|
local DEST = jvmDestdir .. "/" .. currentjvm .. "/" .. file
|
||||||
|
debugOneLinePrint("going to copy " .. SOURCE)
|
||||||
|
debugOneLinePrint("to " .. DEST)
|
||||||
|
local stat1 = posix.stat(SOURCE, "type");
|
||||||
|
if (stat1 ~= nil) then
|
||||||
|
debugOneLinePrint(SOURCE .. " exists")
|
||||||
|
dirWithParents(DEST)
|
||||||
|
-- Copy with -a to keep everything intact
|
||||||
|
local exe = "cp" .. " -ar " .. SOURCE .. " " .. DEST
|
||||||
|
local linkExe = "readlink" .. " -f " .. SOURCE .. " > " .. readlinkOutput
|
||||||
|
debugOneLinePrint("executing " .. linkExe)
|
||||||
|
os.remove(readlinkOutput)
|
||||||
|
os.execute(linkExe)
|
||||||
|
local link = trim(slurp(readlinkOutput))
|
||||||
|
debugOneLinePrint(" ...link is " .. link)
|
||||||
|
if (not ((link) == (SOURCE))) then
|
||||||
|
debugOneLinePrint("WARNING link " .. link .. " where file " .. SOURCE .. " expected!")
|
||||||
|
debugOneLinePrint("Will try to copy link target rather then link itself!")
|
||||||
|
--replacing any NVRA by future NVRA (still execting to have NVRA for any multiple-installable targets
|
||||||
|
-- lua stubbornly consider dash as inteval. Replacing by dot to match X-Y more correct as X.Y rather then not at all
|
||||||
|
local linkDest = string.gsub(link, latestjvm:gsub("-", "."), currentjvm)
|
||||||
|
debugOneLinePrint("attempting to copy " .. link .. " to " .. linkDest)
|
||||||
|
if (link == linkDest) then
|
||||||
|
debugOneLinePrint("Those are identical files! Nothing to do!")
|
||||||
|
else
|
||||||
|
local exe2 = "cp" .. " -ar " .. link .. " " .. linkDest
|
||||||
|
dirWithParents(linkDest)
|
||||||
|
debugOneLinePrint("executing " .. exe2)
|
||||||
|
if (not dry) then
|
||||||
|
os.execute(exe2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
debugOneLinePrint("executing " .. exe)
|
||||||
|
if (not dry) then
|
||||||
|
os.execute(exe)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
debugOneLinePrint(SOURCE .. " does not exists")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end --unindented main function
|
||||||
|
|
||||||
|
if (arg == nil) then
|
||||||
|
debugOneLinePrint("arg variable is nil, you have to call mainProgram manually") -- this can actually not be invoked, as the debug is set via arg
|
||||||
|
else
|
||||||
|
M.mainProgram(arg)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
246
SOURCES/copy_jdk_configs_fixFiles.sh
Executable file
246
SOURCES/copy_jdk_configs_fixFiles.sh
Executable file
@ -0,0 +1,246 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
config=$1
|
||||||
|
target=$2
|
||||||
|
|
||||||
|
debug(){
|
||||||
|
if [ "x$debug" == "xtrue" ] ; then
|
||||||
|
echo "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
debug "cjc: bash debug is on"
|
||||||
|
|
||||||
|
cmdvDebug() {
|
||||||
|
if [ "x$debug" == "xtrue" ] ; then
|
||||||
|
"$@" -v
|
||||||
|
else
|
||||||
|
"$@" 1>/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
mvDebug() {
|
||||||
|
cmdvDebug mv "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
rmDebug() {
|
||||||
|
cmdvDebug rm "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
rmdirDebug() {
|
||||||
|
cmdvDebug rmdir "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
#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"
|
||||||
|
rmDebug -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
|
||||||
|
|
||||||
|
|
||||||
|
listLinks(){
|
||||||
|
find $1 -type l -print0 | xargs -0 ls -ld | sed "s; \+-> \+;_->_;g" | sed "s;.* $1;$1;"
|
||||||
|
}
|
||||||
|
|
||||||
|
printIfExists(){
|
||||||
|
if [ -e $ffileCandidate ] ; then
|
||||||
|
echo $1
|
||||||
|
else
|
||||||
|
# stdout can be captured, therefore stderr
|
||||||
|
debug "skipping not-existing link-target-dir $1" 1>&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
createListOfLinksTargetsDirectories(){
|
||||||
|
pushd $source >/dev/null 2>&1
|
||||||
|
local links=`listLinks $1`
|
||||||
|
for x in $links ; do
|
||||||
|
echo "$x" | grep "jre-abrt" > /dev/null
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
local ffileCandidate=$(echo $x | sed "s/.*_->_//") ;
|
||||||
|
# ignoring relative paths as they may lead who know where later
|
||||||
|
# there can be simlink relative to position, so push is not catching all
|
||||||
|
if [ "$ffileCandidate" != "${ffileCandidate#/}" ] ; then
|
||||||
|
if [ -d $ffileCandidate ] ; then
|
||||||
|
# should we accept the links to directories themselves?
|
||||||
|
printIfExists $ffileCandidate
|
||||||
|
else
|
||||||
|
printIfExists `dirname $ffileCandidate`
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done | sort | uniq
|
||||||
|
popd >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceLinks=`listLinks $source`
|
||||||
|
targetLinks=`listLinks $target`
|
||||||
|
sourceLinksDirsTarget=`createListOfLinksTargetsDirectories $source`
|
||||||
|
targetLinksDirsTarget=`createListOfLinksTargetsDirectories $target`
|
||||||
|
|
||||||
|
debug "source: $source"
|
||||||
|
debug "target: $target"
|
||||||
|
|
||||||
|
debug "sourceLinks:
|
||||||
|
$sourceLinks"
|
||||||
|
debug "targetLinks:
|
||||||
|
$targetLinks"
|
||||||
|
|
||||||
|
debug "sourceLinksDirsTarget:
|
||||||
|
$sourceLinksDirsTarget"
|
||||||
|
debug "targetLinksDirsTarget:
|
||||||
|
$targetLinksDirsTarget"
|
||||||
|
|
||||||
|
sourceSearchPath="$source $sourceLinksDirsTarget"
|
||||||
|
targetSearchPath="$target $targetLinksDirsTarget"
|
||||||
|
|
||||||
|
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 $targetSearchPath | 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"
|
||||||
|
mvDebug -f $file $sf1
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
echo "restored $file to $sf1"
|
||||||
|
else
|
||||||
|
debug "FAILED to restore $file to $sf1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "X$1" == "Xrpmorig" ] ; then
|
||||||
|
debug "$sf2 was NOT modified, removing possibly corrupted $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
|
||||||
|
rmDebug -f $sf2
|
||||||
|
# or its corresponding backup
|
||||||
|
rmDebug -f $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 $sourceSearchPath | grep "\\.rpmorig$"`
|
||||||
|
for file in $files ; do
|
||||||
|
rpmsaveTarget=`echo $file | sed "s/$srcName/$targetName/"`
|
||||||
|
debug "relocating $file to $rpmsaveTarget"
|
||||||
|
if [ -e $rpmsaveTarget ] ; then
|
||||||
|
rmDebug $file
|
||||||
|
else
|
||||||
|
mvDebug $file $rpmsaveTarget
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
debug "Working with rpmsave (1)"
|
||||||
|
files=`find $sourceSearchPath | grep "\\.rpmsave$"`
|
||||||
|
for file in $files ; do
|
||||||
|
rpmsaveTarget=`echo $file | sed "s/$srcName/$targetName/"`
|
||||||
|
debug "relocating $file to $rpmsaveTarget"
|
||||||
|
if [ -e $rpmsaveTarget ] ; then
|
||||||
|
rmDebug $file
|
||||||
|
else
|
||||||
|
mvDebug $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
|
||||||
|
#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
|
||||||
|
#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"
|
||||||
|
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 $sourceSearchPath -empty -type d -delete
|
||||||
|
else
|
||||||
|
find $sourceSearchPath -empty -type d -delete 2>/dev/null >/dev/null
|
||||||
|
fi
|
||||||
|
rmdirDebug $sourceSearchPath
|
||||||
|
|
||||||
|
# and remove placeholders
|
||||||
|
for blackdir in $blackdirs; do
|
||||||
|
if [ -e $blackdir ] ; then
|
||||||
|
debug "nasty $blackdir exists, cleaning placeholder"
|
||||||
|
rmDebug $blackdir/C-J-C_placeholder
|
||||||
|
else
|
||||||
|
debug "nasty $blackdir DONT exists, ignoring again"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
clean
|
||||||
|
|
||||||
|
exit 0
|
180
SPECS/copy-jdk-configs.spec
Normal file
180
SPECS/copy-jdk-configs.spec
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
%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
|
||||||
|
|
||||||
|
# hash relevant to version tag
|
||||||
|
%global htag 88d3ed89f30d8b0eb4877d860fa8d951f224f156
|
||||||
|
Version: 4.0
|
||||||
|
Release: 3%{?dist}
|
||||||
|
Summary: JDKs configuration files copier
|
||||||
|
|
||||||
|
License: BSD
|
||||||
|
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)
|
||||||
|
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
Requires: lua
|
||||||
|
Requires: lua-posix
|
||||||
|
# rh1965305 - copy-jdk-configs script uses find and xargs but RPM does not depend on them
|
||||||
|
Requires: findutils
|
||||||
|
OrderWithRequires: findutils
|
||||||
|
|
||||||
|
%description
|
||||||
|
Utility script to transfer JDKs configuration files between updates or for
|
||||||
|
archiving. With script to fix incorrectly created rpmnew files
|
||||||
|
|
||||||
|
%prep
|
||||||
|
cp -a %{SOURCE1} .
|
||||||
|
|
||||||
|
|
||||||
|
%build
|
||||||
|
#blob
|
||||||
|
|
||||||
|
%pretrans -p <lua>
|
||||||
|
function createPretransScript()
|
||||||
|
-- the sript must be available during pretrans, so multiply it to tmp
|
||||||
|
os.execute("mkdir -p %{rpm_state_dir}")
|
||||||
|
temp_path="%{rpm_state_dir}/%{file}"
|
||||||
|
-- print("generating " .. temp_path)
|
||||||
|
file = io.open(temp_path, "w")
|
||||||
|
file:write([[%{pretrans_install}]])
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- in netinst, the above call may fail. pcall should save instalation (as there is nothing to copy anyway)
|
||||||
|
-- https://bugzilla.redhat.com/show_bug.cgi?id=1295701
|
||||||
|
-- todo, decide whether to check for {rpm_state_dir} and skip on not-existing, or keep creating
|
||||||
|
if pcall(createPretransScript) then
|
||||||
|
-- ok
|
||||||
|
else
|
||||||
|
-- print("Error running %{name} pretrans.")
|
||||||
|
end
|
||||||
|
|
||||||
|
%install
|
||||||
|
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}
|
||||||
|
cp -a %{SOURCE0} $RPM_BUILD_ROOT/%{_libexecdir}/%{file}
|
||||||
|
cp -a %{SOURCE2} $RPM_BUILD_ROOT/%{_libexecdir}/%{fixFile}
|
||||||
|
|
||||||
|
%posttrans
|
||||||
|
# remove file created in pretrans
|
||||||
|
# echo "removing %{rpm_state_dir}/%{file}" || :
|
||||||
|
rm "%{rpm_state_dir}/%{file}" 2> /dev/null || :
|
||||||
|
|
||||||
|
%files
|
||||||
|
%{_libexecdir}/%{file}
|
||||||
|
%{_libexecdir}/%{fixFile}
|
||||||
|
%license LICENSE
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 4.0-3
|
||||||
|
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
|
||||||
|
Related: rhbz#1991688
|
||||||
|
|
||||||
|
* Tue Jun 08 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.0-1
|
||||||
|
- added requires and orderWithRequires of findutils to provide find and xargs (rh1965305)
|
||||||
|
|
||||||
|
* Thu Apr 29 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.0-0
|
||||||
|
- bumped to 4.0 to resolve remvoed rpm 4.17 removing arg from global table
|
||||||
|
|
||||||
|
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.7-8
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||||
|
|
||||||
|
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.7-7
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue Jun 30 2020 Andrew Hughes <gnu.andrew@redhat.com> - 3.7-6
|
||||||
|
- Rebuilt for lua 5.4.0.
|
||||||
|
|
||||||
|
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.7-5
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||||
|
|
||||||
|
* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.7-4
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.7-3
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.7-2
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||||
|
|
||||||
|
* Wed May 02 2018 Jiri Vanek <jvanek@redhat.com> - 3.7-1
|
||||||
|
- udpated to latst relase
|
||||||
|
- configurable blacklist
|
||||||
|
- listed all java keystores
|
||||||
|
|
||||||
|
* Wed May 02 2018 Jiri Vanek <jvanek@redhat.com> - 3.3-12
|
||||||
|
- blackidrs put on single line
|
||||||
|
|
||||||
|
* Wed May 02 2018 Jiri Vanek <jvanek@redhat.com> - 3.3-11
|
||||||
|
- added more files to balcklist based on oralce and ibm jdks
|
||||||
|
|
||||||
|
* Mon Apr 30 2018 Jiri Vanek <jvanek@redhat.com> - 3.3-10
|
||||||
|
- added javaws.policy and blacklist
|
||||||
|
|
||||||
|
* Tue Apr 03 2018 Jiri Vanek <jvanek@redhat.com> - 3.3-5
|
||||||
|
- fixed rhbz#1541838
|
||||||
|
|
||||||
|
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.3-3
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||||
|
|
||||||
|
* Wed Oct 18 2017 Jiri Vanek <jvanek@redhat.com> - 3.3-2
|
||||||
|
- added another subdirs for policies files
|
||||||
|
|
||||||
|
* Wed Oct 18 2017 Jiri Vanek <jvanek@redhat.com> - 3.3-1
|
||||||
|
- handled new paths for policies files
|
||||||
|
|
||||||
|
* Thu Oct 05 2017 Jiri Vanek <jvanek@redhat.com> - 3.1-1
|
||||||
|
- moved to newest release 3.1 whcih conf and lib/security as directories
|
||||||
|
|
||||||
|
* Thu Oct 05 2017 Jiri Vanek <jvanek@redhat.com> - 3.0-1
|
||||||
|
- moved to newest release 3.0 whcih support linked configs
|
||||||
|
|
||||||
|
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.3-2
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
|
||||||
|
|
||||||
|
* Wed Feb 22 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.3
|
||||||
|
- updated to latest head
|
||||||
|
|
||||||
|
* Wed Feb 22 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.2
|
||||||
|
- added "jre/lib/security/blacklisted.certs" to cared files
|
||||||
|
|
||||||
|
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.1-2
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
|
||||||
|
|
||||||
|
* Fri Feb 03 2017 Jiri Vanek <jvanek@redhat.com> - 2.1-1
|
||||||
|
- moved to newest release 2.1
|
||||||
|
|
||||||
|
* Fri Jan 20 2017 Jiri Vanek <jvanek@redhat.com> - 2.0-1
|
||||||
|
- moved to new upstream at pagure.io
|
||||||
|
- moved to newest release 2.0
|
||||||
|
- added new script of copy_jdk_configs_fixFiles.sh
|
||||||
|
- copy_jdk_configs.lua aligned to it
|
||||||
|
|
||||||
|
* Tue Aug 09 2016 Jiri Vanek <jvanek@redhat.com> - 1.2-1
|
||||||
|
- updated to 1,3 which fixing nss minor issue
|
||||||
|
|
||||||
|
* Tue Jul 12 2016 Jiri Vanek <jvanek@redhat.com> - 1.1-5
|
||||||
|
- posttrans silenced, the error is appearing only in state, when there is nothing to copy
|
||||||
|
|
||||||
|
* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.1-4
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
|
||||||
|
|
||||||
|
* Fri Jan 08 2016 Jiri Vanek <jvanek@redhat.com> - 1.1-3
|
||||||
|
- pretrasn lua call now done in pcall (protected call)
|
||||||
|
- also posttrans now always return 0
|
||||||
|
|
||||||
|
* Wed Dec 16 2015 Jiri Vanek <jvanek@redhat.com> - 1.1-2
|
||||||
|
- package now "installs" also during pretrans, so pretrasn scripts can use it
|
||||||
|
- pretrasn "install" is removed in postrans
|
||||||
|
|
||||||
|
* Wed Nov 25 2015 Jiri Vanek <jvanek@redhat.com> - 1.1-1
|
||||||
|
- initial package
|
Loading…
Reference in New Issue
Block a user