Cleanup typos and help output

- Related: RHEL-73278
This commit is contained in:
Andrew Hughes 2025-01-09 03:33:54 +00:00
parent 90e4cb8b7a
commit 08b48bc713
2 changed files with 36 additions and 29 deletions

View File

@ -8,7 +8,7 @@ Name: copy-jdk-configs
# hash relevant to version tag
%global htag 88d3ed89f30d8b0eb4877d860fa8d951f224f156
Version: 4.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: JDKs configuration files copier
License: BSD
@ -75,6 +75,10 @@ rm "%{rpm_state_dir}/%{file}" 2> /dev/null || :
%license LICENSE
%changelog
* Thu Jan 09 2025 Andrew Hughes <gnu.andrew@redhat.com> - 4.0-4
- Cleanup typos and help output
- Related: RHEL-73278
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 4.0-3
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688

View File

@ -53,20 +53,20 @@ local function dirWithParents(path)
s = s .. "/" .. d
local stat2 = posix.stat(s, "type");
if (stat2 == nil) then
debugOneLinePrint(s .. " does not exists, creating")
debugOneLinePrint(s .. " does not exist. Creating")
if (not dry) then
posix.mkdir(s)
end
else
debugOneLinePrint(s .. " exists,not creating")
debugOneLinePrint(s .. " exists. Not creating")
end
end
end
-- main function,
-- formelry main body
-- move to function resolved
-- formerly main body
-- moved to function resolved
-- https://bugzilla.redhat.com/show_bug.cgi?id=1892224
-- for readability not indented, todo, indent once tuned
@ -131,28 +131,31 @@ function M.mainProgram(arg)
for i = 1, #arg, 2 do
if (arg[i] == "--help" or arg[i] == "-h") then
print("all but jvmDestdir and debug are mandatory")
print("All but jvmDestdir and debug are mandatory")
print(" --currentjvm")
print(" NVRA of currently installed java")
print(" <name>-<version>-<release>.<arch> of currently installed java")
print(" --jvmdir")
print(" Directory where to find this kind of virtual machine. Generally /usr/lib/jvm")
print(" Directory where to find this virtual machine. Generally /usr/lib/jvm")
print(" --origname")
print(" convinient switch to determine jdk. Generally java-1.X.0-vendor")
print(" convenient switch to specify full name of the JDK. Generally java-<version>-vendor")
print(" --origjavaver")
print(" convinient switch to determine jdk's version. Generally 1.X.0")
print(" convenient switch to specify the JDK's version. Generally X or 1.X.0")
print(" --arch")
print(" convinient switch to determine jdk's arch")
print(" convenient switch to specify the JDK's architecture")
print(" --jvmDestdir")
print(" Migration/testing switch. Target Mostly same as jvmdir, but you may wont to copy ouside it.")
print(" Migration/testing switch. Target mostly the same as jvmdir, but you may want to copy outside it.")
print(" --debug or $debug")
print(" Enables printing out whats going on. true/false. False by default")
print(" Enables printing out what is 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(" true/false. If true, then no changes will be written to disk except one tmp file. False by default")
print(" **** Special Parameters ****")
print(" --list")
print(" if present on cmdline, list all cared files and exists")
print(" if present on cmdline, lists all cared files and exits")
print(" **** Example ****")
print(" --currentjvm java-1.8.0-openjdk-1.8.0.65-3.b17.fc22.x86_64 --jvmdir /usr/lib/jvm")
print(" --origname java-1.8.0-openjdk --origjavaver 1.8.0 --arch x86_64 --jvmDestdir /home/jvanek/Desktop")
os.exit(0)
end
if (arg[i] == "--currentjvm") then
@ -232,11 +235,11 @@ function M.mainProgram(arg)
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")
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")
print(p .. " matched but seems to be a debug variant. Skipping")
else
table.insert(jvms, p)
end
@ -246,11 +249,11 @@ function M.mainProgram(arg)
end
if (#jvms <= 0) then
debugOneLinePrint("no matching jdk in " .. jvmdir .. " exit")
debugOneLinePrint("No matching jdk in " .. jvmdir .. " exit")
return
end ;
debugOneLinePrint("matched " .. #jvms .. " jdk in " .. jvmdir)
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)
@ -284,7 +287,7 @@ function M.mainProgram(arg)
end)
if (debug) then
print("sorted lsit of jvms")
print("Sorted list of jvms")
for i, file in pairs(jvms) do
print(file)
end
@ -294,7 +297,7 @@ function M.mainProgram(arg)
if (temp ~= nil) then
src = jvmdir .. "/" .. latestjvm
debugOneLinePrint("temp declared as " .. temp .. " saving used dir of " .. src)
debugOneLinePrint("Temp declared as " .. temp .. ". Saving used dir of " .. src)
file = io.open(temp, "w")
file:write(src)
file:close()
@ -322,35 +325,35 @@ function M.mainProgram(arg)
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
-- replacing any NVRA by future NVRA (still expecting to have NVRA for any multiple-installable targets)
-- lua stubbornly consider dash as interval. 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!")
debugOneLinePrint("These are identical files. Nothing to do.")
else
local exe2 = "cp" .. " -ar " .. link .. " " .. linkDest
dirWithParents(linkDest)
debugOneLinePrint("executing " .. exe2)
debugOneLinePrint("Executing " .. exe2)
if (not dry) then
os.execute(exe2)
end
end
else
debugOneLinePrint("executing " .. exe)
debugOneLinePrint("Executing " .. exe)
if (not dry) then
os.execute(exe)
end
end
else
debugOneLinePrint(SOURCE .. " does not exists")
debugOneLinePrint(SOURCE .. " does not exist")
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
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