Bumped to 4.0.0.0.pre.0.4540d3a0592ee857e7d3da348cfb7d64d207fcdd
To solve Packaging scriptlets assume global 'arg' in Lua environment https://bugzilla.redhat.com/show_bug.cgi?id=1892224
This commit is contained in:
parent
0327d7e42b
commit
988593295e
@ -6,9 +6,9 @@
|
||||
Name: copy-jdk-configs
|
||||
|
||||
# hash relevant to version tag
|
||||
%global htag 1d18ce8b5dec47a0468136ab6cdadfb93defe2c4
|
||||
Version: 3.7
|
||||
Release: 8%{?dist}
|
||||
%global htag bf480d4217342a54d3f1103365d21f6e399c4932
|
||||
Version: 3.9
|
||||
Release: 4.0.pre.0.bf480d4217342a54d3f1103365d21f6e399c4932%{?dist}
|
||||
Summary: JDKs configuration files copier
|
||||
|
||||
License: BSD
|
||||
@ -72,6 +72,9 @@ rm "%{rpm_state_dir}/%{file}" 2> /dev/null || :
|
||||
%license LICENSE
|
||||
|
||||
%changelog
|
||||
* Thu Apr 29 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.9-4.0.pre.0.bf480d4217342a54d3f1103365d21f6e399c4932%{?dist}
|
||||
- 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
|
||||
|
||||
|
@ -1,9 +1,77 @@
|
||||
#!/usr/bin/lua
|
||||
-- rpm call
|
||||
-- lua -- copy_jdk_configs.lua --currentjvm "%{uniquesuffix %{nil}}" --jvmdir "%{_jvmdir %{nil}}" --origname "%{name}" --origjavaver "%{javaver}" --arch "%{_arch}" --debug true
|
||||
-- debug=true lua -- copy_jdk_configs.lua --currentjvm "%{uniquesuffix %{nil}}" --jvmdir "%{_jvmdir %{nil}}" --origname "%{name}" --origjavaver "%{javaver}" --arch "%{_arch}"
|
||||
--test call
|
||||
--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" --debug true --jvmDestdir /home/jvanek/Desktop
|
||||
-- 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",
|
||||
@ -35,6 +103,7 @@ local caredFiles = {"jre/lib/calendars.properties",
|
||||
"jre/lib/ext",
|
||||
"jre/lib/security/blacklist",
|
||||
"jre/lib/security/javaws.policy",
|
||||
"jre/lib/security/nss.fips.cfg",
|
||||
"lib/security",
|
||||
"conf",
|
||||
"lib/ext"}
|
||||
@ -57,7 +126,6 @@ local jvmDestdir = nil
|
||||
local origname = nil
|
||||
local origjavaver = nil
|
||||
local arch = nil
|
||||
local debug = false;
|
||||
local temp = nil;
|
||||
local dry = false;
|
||||
|
||||
@ -144,65 +212,12 @@ if (debug) then
|
||||
print(debug);
|
||||
end
|
||||
|
||||
local function debugOneLinePrint(string)
|
||||
if (debug) then
|
||||
print(string)
|
||||
end;
|
||||
end
|
||||
|
||||
|
||||
--trasnform substitute names to lua patterns
|
||||
local name = string.gsub(string.gsub(origname, "%-", "%%-"), "%.", "%%.")
|
||||
local javaver = string.gsub(origjavaver, "%.", "%%.")
|
||||
|
||||
local jvms = { }
|
||||
|
||||
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
|
||||
|
||||
|
||||
debugOneLinePrint("started")
|
||||
|
||||
|
||||
@ -212,7 +227,7 @@ if (foundJvms == nil) then
|
||||
return
|
||||
end
|
||||
|
||||
debugOneLinePrint("found "..#foundJvms.."jvms")
|
||||
debugOneLinePrint("found "..#foundJvms.." jvms")
|
||||
|
||||
for i,p in pairs(foundJvms) do
|
||||
-- regex similar to %{_jvmdir}/%{name}-%{javaver}*%{_arch} bash command
|
||||
@ -326,3 +341,13 @@ for i,file in pairs(caredFiles) do
|
||||
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
|
||||
|
@ -2,23 +2,38 @@
|
||||
config=$1
|
||||
target=$2
|
||||
|
||||
debug="false"
|
||||
|
||||
rma=""
|
||||
if [ "x$debug" == "xtrue" ] ; then
|
||||
rma="-v"
|
||||
fi
|
||||
|
||||
debug(){
|
||||
if [ "x$debug" == "xtrue" ] ; then
|
||||
echo "$1"
|
||||
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"
|
||||
rm -rf $config
|
||||
rmDebug -rf $config
|
||||
}
|
||||
|
||||
if [ "x" == "x$config" ] ; then
|
||||
@ -133,23 +148,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 +184,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 +196,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
|
||||
|
||||
@ -211,20 +226,21 @@ done
|
||||
debug "cleaning legacy leftowers"
|
||||
if [ "x$debug" == "xtrue" ] ; then
|
||||
find $sourceSearchPath -empty -type d -delete
|
||||
rmdir $rma $sourceSearchPath
|
||||
else
|
||||
find $sourceSearchPath -empty -type d -delete 2>/dev/null >/dev/null
|
||||
rmdir $rma $sourceSearchPath 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"
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user