PRETRANS
<lua>
-- see https://bugzilla.redhat.com/show_bug.cgi?id=1038092 for whole issue
local posix = require "posix"
local currentjvm = "java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386"
local jvmdir = "/usr/lib/jvm"
local jvmDestdir = jvmdir
local origname = "java-1.8.0-openjdk"
local origjavaver = "1.8.0"
--trasnform substitute names to lua patterns
--all percentages must be doubled for case of RPM escapingg
local name = string.gsub(string.gsub(origname, "%-", "%%-"), "%.", "%%.")
local javaver = string.gsub(origjavaver, "%.", "%%.")
local arch ="i386"
local debug = false;
local jvms = { }
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/java.policy",
"jre/lib/security/java.security",
"jre/lib/security/local_policy.jar",
"jre/lib/security/nss.cfg,",
"jre/lib/ext"}
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
if (debug) then
print("started")
end;
foundJvms = posix.dir(jvmdir);
if (foundJvms == nil) then
if (debug) then
print("no, or nothing in "..jvmdir.." exit")
end;
return
end
if (debug) then
print("found "..#foundJvms.."jvms")
end;
for i,p in pairs(foundJvms) do
-- regex similar to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0*i386 bash command
--all percentages must be doubled for case of RPM escapingg
if (string.find(p, name.."%-"..javaver..".*"..arch) ~= nil ) then
if (debug) then
print("matched: "..p)
end;
if (currentjvm == p) then
if (debug) then
print("this jdk is already installed. exiting lua script")
end;
return
end ;
table.insert(jvms, p)
else
if (debug) then
print("NOT matched: "..p)
end;
end
end
if (#jvms <=0) then
if (debug) then
print("no matching jdk in "..jvmdir.." exit")
end;
return
end;
if (debug) then
print("matched "..#jvms.." jdk in "..jvmdir)
end;
--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]
for i,file in pairs(caredFiles) do
local SOURCE=jvmdir.."/"..latestjvm.."/"..file
local DEST=jvmDestdir.."/"..currentjvm.."/"..file
if (debug) then
print("going to copy "..SOURCE)
print("to "..DEST)
end;
local stat1 = posix.stat(SOURCE, "type");
if (stat1 ~= nil) then
if (debug) then
print(SOURCE.." exists")
end;
local s = ""
local dirs = splitToTable(DEST, "[^/]+")
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
if (debug) then
print(s.." does not exists, creating")
end;
posix.mkdir(s)
else
if (debug) then
print(s.." exists,not creating")
end;
end
end
-- Copy with -a to keep everything intact
local exe = "cp".." -ar "..SOURCE.." "..DEST
if (debug) then
print("executing "..exe)
end;
os.execute(exe)
else
if (debug) then
print(SOURCE.." does not exists")
end;
end
end
POSTIN
/bin/sh
# FIXME: identical binaries are copied, not linked. This needs to be
# fixed upstream.
# The pretrans lua scriptlet prevents an unmodified java.security
# from being replaced via an update. It gets created as
# java.security.rpmnew instead. This invalidates the patch of
# JDK-8061210 of the January 2015 CPU or JDK-8043201 of the
# July 2015 CPU. We fix this via a post scriptlet which runs on updates.
if [ "$1" -gt 1 ]; then
javasecurity="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/lib/security/java.security"
sum=$(md5sum "${javasecurity}" | cut -d' ' -f1)
# This is the md5sum of an unmodified java.security file
if [ "${sum}" = '1690ac33955594f71dc952c9e83fd396' -o \
"${sum}" = 'b138695d0c0ea947e64a21a627d973ba' -o \
"${sum}" = 'd17958676bdb9f9d941c8a59655311fb' ]; then
if [ -f "${javasecurity}.rpmnew" ]; then
mv -f "${javasecurity}.rpmnew" "${javasecurity}"
fi
fi
fi
# MetaspaceShared::generate_vtable_methods not implemented for PPC JIT
#see https://bugzilla.redhat.com/show_bug.cgi?id=513605
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/java -Xshare:dump >/dev/null 2>/dev/null
ext=.xz
alternatives \
--install /usr/bin/java java /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/java 1800060 \
--slave /usr/lib/jvm/jre jre /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre \
--slave /usr/lib/jvm-exports/jre jre_exports /usr/lib/jvm-exports/jre-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386 \
--slave /usr/bin/jjs jjs /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/jjs \
--slave /usr/bin/keytool keytool /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/keytool \
--slave /usr/bin/orbd orbd /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/orbd \
--slave /usr/bin/pack200 pack200 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/pack200 \
--slave /usr/bin/rmid rmid /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/rmid \
--slave /usr/bin/rmiregistry rmiregistry /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/rmiregistry \
--slave /usr/bin/servertool servertool /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/servertool \
--slave /usr/bin/tnameserv tnameserv /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/tnameserv \
--slave /usr/bin/unpack200 unpack200 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/unpack200 \
--slave /usr/share/man/man1/java.1$ext java.1$ext \
/usr/share/man/man1/java-java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386.1$ext \
--slave /usr/share/man/man1/jjs.1$ext jjs.1$ext \
/usr/share/man/man1/jjs-java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386.1$ext \
--slave /usr/bin/policytool policytool /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/policytool \
--slave /usr/share/man/man1/keytool.1$ext keytool.1$ext \
/usr/share/man/man1/keytool-java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386.1$ext \
--slave /usr/share/man/man1/orbd.1$ext orbd.1$ext \
/usr/share/man/man1/orbd-java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386.1$ext \
--slave /usr/share/man/man1/pack200.1$ext pack200.1$ext \
/usr/share/man/man1/pack200-java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386.1$ext \
--slave /usr/share/man/man1/rmid.1$ext rmid.1$ext \
/usr/share/man/man1/rmid-java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386.1$ext \
--slave /usr/share/man/man1/rmiregistry.1$ext rmiregistry.1$ext \
/usr/share/man/man1/rmiregistry-java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386.1$ext \
--slave /usr/share/man/man1/servertool.1$ext servertool.1$ext \
/usr/share/man/man1/servertool-java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386.1$ext \
--slave /usr/share/man/man1/tnameserv.1$ext tnameserv.1$ext \
/usr/share/man/man1/tnameserv-java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386.1$ext \
--slave /usr/share/man/man1/unpack200.1$ext unpack200.1$ext \
/usr/share/man/man1/unpack200-java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386.1$ext
for X in openjdk 1.8.0 ; do
alternatives \
--install /usr/lib/jvm/jre-"$X" \
jre_"$X" /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre 1800060 \
--slave /usr/lib/jvm-exports/jre-"$X" \
jre_"$X"_exports /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre
done
update-alternatives --install /usr/lib/jvm/jre-1.8.0-openjdk jre_1.8.0_openjdk /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386 1800060 \
--slave /usr/lib/jvm-exports/jre-1.8.0 jre_1.8.0_openjdk_exports /usr/lib/jvm-exports/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386
update-desktop-database /usr/share/applications &> /dev/null || :
/bin/touch --no-create /usr/share/icons/hicolor &>/dev/null || :
exit 0
POSTUN
/bin/sh
alternatives --remove java /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre/bin/java
alternatives --remove jre_openjdk /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre
alternatives --remove jre_1.8.0 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386/jre
alternatives --remove jre_1.8.0_openjdk /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.60-1.b27.1.mga5.i386