From 88b1aeb3472132166d558915dcf706c4d39d915e Mon Sep 17 00:00:00 2001 From: Jiri Date: Apr 29 2021 08:31:16 +0000 Subject: [PATCH 1/6] Adapted to nil arg in rpm 4.17 Moved main body to special function mainProgram. If the arg are present, then the mainProgram is called as usually (so it should be backward comaptible with previous scriptlets) if arg is not present, then nothing happens. User of arg-less environemnt, have to call mainProgram manually --- diff --git a/call-source.lua b/call-source.lua index 3e033f0..ad27ed5 100755 --- a/call-source.lua +++ b/call-source.lua @@ -1,6 +1,6 @@ #!/usr/bin/lua -- http://pkgs.fedoraproject.org/cgit/rpms/java-1.8.0-openjdk.git/tree/java-1.8.0-openjdk.spec#n1760 --- this file is about to be indlined in spec file, note that the copypaste in spec file may be more accurate then this one +-- this file is about to be inlined in spec file, note that the copypaste in spec file may be more accurate then this one local posix = require "posix" local debug = true diff --git a/copy_jdk_configs.lua b/copy_jdk_configs.lua index 3b851a5..dfa0160 100755 --- a/copy_jdk_configs.lua +++ b/copy_jdk_configs.lua @@ -4,6 +4,65 @@ --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 +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 + +local function mainProgram(arg) local caredFiles = {"jre/lib/calendars.properties", "jre/lib/content-types.properties", "jre/lib/flavormap.properties", @@ -145,65 +204,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") @@ -327,3 +333,11 @@ 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 + mainProgram(arg) +end From 640dae9b56619897d3e4b8c226c199d89679153c Mon Sep 17 00:00:00 2001 From: Jiri Date: Apr 29 2021 08:31:16 +0000 Subject: [PATCH 2/6] Converted to module --- diff --git a/copy_jdk_configs.lua b/copy_jdk_configs.lua index dfa0160..ab40de5 100755 --- a/copy_jdk_configs.lua +++ b/copy_jdk_configs.lua @@ -4,6 +4,9 @@ --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 +local M = {} + +local debug = false; local function debugOneLinePrint(string) if (debug) then print(string) @@ -62,7 +65,7 @@ end -- https://bugzilla.redhat.com/show_bug.cgi?id=1892224 -- for readability not indented, todo, indent once tuned -local function mainProgram(arg) +function M.mainProgram(arg) local caredFiles = {"jre/lib/calendars.properties", "jre/lib/content-types.properties", "jre/lib/flavormap.properties", @@ -117,7 +120,6 @@ local jvmDestdir = nil local origname = nil local origjavaver = nil local arch = nil -local debug = false; local temp = nil; local dry = false; @@ -339,5 +341,7 @@ 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 - mainProgram(arg) + M.mainProgram(arg) end + +return M From ad5a1e527bfa663897ba56c80c797e0dec267f29 Mon Sep 17 00:00:00 2001 From: Jiri Date: Apr 29 2021 11:29:26 +0000 Subject: [PATCH 3/6] Moved debug to be initiated from environemnt variale --- diff --git a/copy_jdk_configs.lua b/copy_jdk_configs.lua index ab40de5..94e7ed5 100755 --- a/copy_jdk_configs.lua +++ b/copy_jdk_configs.lua @@ -1,12 +1,17 @@ #!/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 = {} -local debug = false; +if (os.getenv("debug") == "true") then + debug = true; +else + debug = false; +end + local function debugOneLinePrint(string) if (debug) then print(string) @@ -66,6 +71,7 @@ end -- for readability not indented, todo, indent once tuned function M.mainProgram(arg) +debugOneLinePrint("lua debug on") local caredFiles = {"jre/lib/calendars.properties", "jre/lib/content-types.properties", "jre/lib/flavormap.properties", diff --git a/copy_jdk_configs_fixFiles.sh b/copy_jdk_configs_fixFiles.sh index 0fc771e..bfe56a8 100755 --- a/copy_jdk_configs_fixFiles.sh +++ b/copy_jdk_configs_fixFiles.sh @@ -2,14 +2,14 @@ config=$1 target=$2 -debug="false" - debug(){ if [ "x$debug" == "xtrue" ] ; then echo "$@" fi } +debug "debug is on" + cmdvDebug() { if [ "x$debug" == "xtrue" ] ; then "$@" -v From 4540d3a0592ee857e7d3da348cfb7d64d207fcdd Mon Sep 17 00:00:00 2001 From: Jiri Date: Apr 29 2021 11:36:07 +0000 Subject: [PATCH 4/6] Updated embedded scriptlet --- diff --git a/call-source.lua b/call-source.lua index ad27ed5..1f38663 100755 --- a/call-source.lua +++ b/call-source.lua @@ -1,11 +1,20 @@ -#!/usr/bin/lua --- http://pkgs.fedoraproject.org/cgit/rpms/java-1.8.0-openjdk.git/tree/java-1.8.0-openjdk.spec#n1760 --- this file is about to be inlined in spec file, note that the copypaste in spec file may be more accurate then this one +-- see https://bugzilla.redhat.com/show_bug.cgi?id=1038092 for whole issue +-- see https://bugzilla.redhat.com/show_bug.cgi?id=1290388 for pretrans over pre +-- if copy-jdk-configs is in transaction, it installs in pretrans to temp +-- if copy_jdk_configs is in temp, then it means that copy-jdk-configs is in transaction and so is +-- preferred over one in %%{_libexecdir}. If it is not in transaction, then depends +-- whether copy-jdk-configs is installed or not. If so, then configs are copied +-- (copy_jdk_configs from %%{_libexecdir} used) or not copied at all local posix = require "posix" -local debug = true -SOURCE1 = "/home/jvanek/hg/copy_jdk_configs/copy_jdk_configs.lua" -SOURCE2 = "/usr/libexec/copy_jdk_configs.lua" +if (os.getenv("debug") == "true") then + debug = true; +else + debug = false; +end + +SOURCE1 = "%{rpm_state_dir}/copy_jdk_configs.lua" +SOURCE2 = "%{_libexecdir}/copy_jdk_configs.lua" local stat1 = posix.stat(SOURCE1, "type"); local stat2 = posix.stat(SOURCE2, "type"); @@ -15,10 +24,10 @@ local stat2 = posix.stat(SOURCE2, "type"); print(SOURCE1 .." exists - copy-jdk-configs in transaction, using this one.") end; package.path = package.path .. ";" .. SOURCE1 -else +else if (stat2 ~= nil) then if (debug) then - print(SOURCE2 .." exists - copy-jdk-configs alrady installed and NOT in transation. Using.") + print(SOURCE2 .." exists - copy-jdk-configs already installed and NOT in transaction. Using.") end; package.path = package.path .. ";" .. SOURCE2 else @@ -27,9 +36,10 @@ else print(SOURCE2 .." does NOT exists") print("No config files will be copied") end - os.exit(0) + return end end --- run contetn of included file -arg = {"--debug true"} -require "copy_jdk_configs.lua" +-- run content of included file with fake args +cjc = require "copy_jdk_configs.lua" +arg = {"--currentjvm", "%{uniquesuffix %{nil}}", "--jvmdir", "%{_jvmdir %{nil}}", "--origname", "%{name}", "--origjavaver", "%{javaver}", "--arch", "%{_arch}", "--temp", "%{rpm_state_dir}/%{name}.%{_arch}"} +cjc.mainProgram(arg) diff --git a/java-10-super.spec b/java-10-super.spec index cef4b60..5c1032c 100644 --- a/java-10-super.spec +++ b/java-10-super.spec @@ -31,8 +31,6 @@ %define sdkbindir %{_jvmdir}/%{sdkdir}/bin %define jrebindir %{_jvmdir}/%{jredir}/bin -%define jvmjardir %{_jvmjardir}/%{uniquesuffix} - %define rpm_state_dir %{_localstatedir}/lib/rpm-state @@ -136,7 +134,6 @@ rm -rf $RPM_BUILD_ROOT # main files install -d -m 755 $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir} install -d -m 755 $RPM_BUILD_ROOT%{_jvmdir}/%{jredir} -install -d -m 755 $RPM_BUILD_ROOT%{jvmjardir} pushd $RPM_BUILD_ROOT%{_jvmdir} ln -s %{jredir} %{jrelnk_name} @@ -222,12 +219,17 @@ fi -- see https://bugzilla.redhat.com/show_bug.cgi?id=1038092 for whole issue -- see https://bugzilla.redhat.com/show_bug.cgi?id=1290388 for pretrans over pre -- if copy-jdk-configs is in transaction, it installs in pretrans to temp --- if copy_jdk_configs is in temp, then it means that copy-jdk-configs is in tranasction and so is --- preferred over one in %%{_libexecdir}. If it is not in transaction, then depends +-- if copy_jdk_configs is in temp, then it means that copy-jdk-configs is in transaction and so is +-- preferred over one in %%{_libexecdir}. If it is not in transaction, then depends -- whether copy-jdk-configs is installed or not. If so, then configs are copied -- (copy_jdk_configs from %%{_libexecdir} used) or not copied at all local posix = require "posix" -local debug = false + +if (os.getenv("debug") == "true") then + debug = true; +else + debug = false; +end SOURCE1 = "%{rpm_state_dir}/copy_jdk_configs.lua" SOURCE2 = "%{_libexecdir}/copy_jdk_configs.lua" @@ -240,10 +242,10 @@ local stat2 = posix.stat(SOURCE2, "type"); print(SOURCE1 .." exists - copy-jdk-configs in transaction, using this one.") end; package.path = package.path .. ";" .. SOURCE1 -else +else if (stat2 ~= nil) then if (debug) then - print(SOURCE2 .." exists - copy-jdk-configs alrady installed and NOT in transation. Using.") + print(SOURCE2 .." exists - copy-jdk-configs already installed and NOT in transaction. Using.") end; package.path = package.path .. ";" .. SOURCE2 else @@ -255,18 +257,17 @@ else return end end --- run contetn of included file with fake args -arg = {"--currentjvm", "%{uniquesuffix}", "--jvmdir", "%{_jvmdir}", "--origname", "%{name}", "--origjavaver", "%{javaver}", "--arch", "%{_arch}", "--temp", "%{rpm_state_dir}/%{name}.%{_arch}"} -require "copy_jdk_configs.lua" +-- run content of included file with fake args +cjc = require "copy_jdk_configs.lua" +arg = {"--currentjvm", "%{uniquesuffix %{nil}}", "--jvmdir", "%{_jvmdir %{nil}}", "--origname", "%{name}", "--origjavaver", "%{javaver}", "--arch", "%{_arch}", "--temp", "%{rpm_state_dir}/%{name}.%{_arch}"} +cjc.mainProgram(arg) %post devel #update-alternatives --install %{_bindir}/javac javac %{sdk_versionless_bindir}/javac %{priority} \ #--slave %{_jvmdir}/java java_sdk %{_jvmdir}/%{sdkdir} #update-alternatives --install %{_jvmdir}/java-%{origin} java_sdk_%{origin} %{_jvmdir}/%{sdklnk_versionless_name} %{priority} \ -#--slave %{_jvmjardir}/java-%{origin} java_sdk_%{origin}_exports %{_jvmjardir}/%{sdkdir} #update-alternatives --install %{_jvmdir}/java-%{javaver_alternatives} java_sdk_%{javaver_alternatives} %{_jvmdir}/%{sdklnk_versionless_name} %{priority} \ -#--slave %{_jvmjardir}/java-%{javaver_alternatives} java_sdk_%{javaver_alternatives}_exports %{_jvmjardir}/%{sdkdir} %postun #update-alternatives --remove java %{jre_versionless_bindir}/java @@ -291,7 +292,6 @@ require "copy_jdk_configs.lua" %dir %{_jvmdir}/%{jredir}/lib/security/ %dir %{_jvmdir}/%{jredir}/lib/ %{_jvmdir}/%{jrelnk_name} -%{jvmjardir} %config %{_jvmdir}/%{jredir}/lib/security/cacerts %config(noreplace) %{_jvmdir}/%{jredir}/lib/security/java.policy %config(noreplace) %{_jvmdir}/%{jredir}/lib/security/java.security From bf480d4217342a54d3f1103365d21f6e399c4932 Mon Sep 17 00:00:00 2001 From: Jiri Date: Apr 29 2021 14:34:34 +0000 Subject: [PATCH 5/6] Made debug on more laud --- diff --git a/call-source.lua b/call-source.lua index 1f38663..0ab6100 100755 --- a/call-source.lua +++ b/call-source.lua @@ -9,6 +9,7 @@ local posix = require "posix" if (os.getenv("debug") == "true") then debug = true; + print("cjc: in spec debug is on") else debug = false; end diff --git a/copy_jdk_configs.lua b/copy_jdk_configs.lua index 94e7ed5..62f393a 100755 --- a/copy_jdk_configs.lua +++ b/copy_jdk_configs.lua @@ -71,7 +71,7 @@ end -- for readability not indented, todo, indent once tuned function M.mainProgram(arg) -debugOneLinePrint("lua debug on") +debugOneLinePrint("cjc: lua debug on") local caredFiles = {"jre/lib/calendars.properties", "jre/lib/content-types.properties", "jre/lib/flavormap.properties", @@ -227,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 diff --git a/copy_jdk_configs_fixFiles.sh b/copy_jdk_configs_fixFiles.sh index bfe56a8..7e87be8 100755 --- a/copy_jdk_configs_fixFiles.sh +++ b/copy_jdk_configs_fixFiles.sh @@ -8,7 +8,7 @@ debug(){ fi } -debug "debug is on" +debug "cjc: bash debug is on" cmdvDebug() { if [ "x$debug" == "xtrue" ] ; then diff --git a/java-10-super.spec b/java-10-super.spec index 5c1032c..6972864 100644 --- a/java-10-super.spec +++ b/java-10-super.spec @@ -45,20 +45,14 @@ Group: Development/Interpreters Provides: jre-%{javaver}-%{origin} = %{epoch}:%{version}-%{release} Provides: jre-%{origin} = %{epoch}:%{version}-%{release} Provides: jre-%{javaver}, java-%{javaver}, jre = %{epoch}:%{javaver} -Provides: java-%{origin} = %{epoch}:%{version}-%{release} +Provides: java-%{origin} = %{epoch}:%{version}-%{release} Provides: java = %{epoch}:%{javaver} -Requires: /usr/sbin/update-alternatives -Requires: jpackage-utils >= 0:1.5.38 +Requires: /usr/sbin/update-alternatives BuildRequires: dos2unix, jpackage-utils >= 0:1.5.38, sed, %{_bindir}/perl -Requires(post): desktop-file-utils -Requires(postun): desktop-file-utils Requires(post): /usr/sbin/update-alternatives Requires(postun): /usr/sbin/update-alternatives -Requires(post): perl -Requires(postun): perl Requires: copy-jdk-configs >= 3.2 -BuildRequires: desktop-file-utils %description This package contains the Super Java Runtime Environment. @@ -227,6 +221,7 @@ local posix = require "posix" if (os.getenv("debug") == "true") then debug = true; + print("cjc: in spec debug is on") else debug = false; end From f10f5d21338020401ee1450147d4dd6bd52114ee Mon Sep 17 00:00:00 2001 From: Jiri Date: Apr 30 2021 06:17:32 +0000 Subject: [PATCH 6/6] Enahnced debug help also fro variable --- diff --git a/copy_jdk_configs.lua b/copy_jdk_configs.lua index 62f393a..748c14b 100755 --- a/copy_jdk_configs.lua +++ b/copy_jdk_configs.lua @@ -144,7 +144,7 @@ for i=1,#arg,2 do 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") + 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")