$ dpkg -l | grep openjdk*
ii openjdk-8-jdk:amd64 8u121-b13-0ubuntu1.16.04.2 amd64 OpenJDK Development Kit (JDK)
ii openjdk-8-jdk-headless:amd64 8u121-b13-0ubuntu1.16.04.2 amd64 OpenJDK Development Kit (JDK) (headless)
ii openjdk-8-jre:amd64 8u121-b13-0ubuntu1.16.04.2 amd64 OpenJDK Java runtime, using Hotspot JIT
ii openjdk-8-jre-headless:amd64 8u121-b13-0ubuntu1.16.04.2 amd64 OpenJDK Java runtime, using Hotspot JIT (headless)
$ dpkg -l | grep jdk1*
ii default-jdk 2:1.8-56ubuntu2 amd64 Standard Java or Java compatible Development Kit
ii default-jdk-headless 2:1.8-56ubuntu2 amd64 Standard Java or Java compatible Development Kit (headless)
rH jdk1.8.0-121 1.8.0121-1 amd64 Java Platform Standard Edition Development Kit
ii openjdk-8-jdk:amd64 8u121-b13-0ubuntu1.16.04.2 amd64 OpenJDK Development Kit (JDK)
ii openjdk-8-jdk-headless:amd64 8u121-b13-0ubuntu1.16.04.2 amd64 OpenJDK Development Kit (JDK) (headless)
ii openjdk-8-jre:amd64 8u121-b13-0ubuntu1.16.04.2 amd64 OpenJDK Java runtime, using Hotspot JIT
ii openjdk-8-jre-headless:amd64 8u121-b13-0ubuntu1.16.04.2 amd64 OpenJDK Java runtime, using Hotspot JIT (headless)
$ cat /var/lib/dpkg/info/jdk1.8.0-121.postrm
#!/bin/bash
RPM_INSTALL_PREFIX=/usr/java
export RPM_INSTALL_PREFIX
#
# Make sure any new files are created with a secure access mask. Do not use
# chmod, since that would also change the rights of any existing files, and
# we are only interested in setting the rights for new files.
#
umask 022
#
# The package assumes that Gnome is either installed, or going to be
# installed, so if nothing currently exists, then install in the default
# location.
#
# NOTE: These variables must be defined before all the shell function macros
# are included.
#
if [ -z "${GNOMEDIR}" ]; then
GNOMEDIR=/usr
fi
#
# RPM_INSTALL_PREFIX doesn't seem to be set by "alien" so the following
# minor kludge allows some functionality on debian-like systems (such
# a Ubuntu) which don't support packages.
#
if [ -z "${RPM_INSTALL_PREFIX}" ]; then
RPM_INSTALL_PREFIX="/usr/java"
fi
#
# Gross kludge for old SuSE distros: Even though they set the environment
# variable GNOMEDIR to /opt/gnome, Gnome may really be in /opt/gnome2.
# Go figure,... (I feel so unclean....)
#
if [ "${GNOMEDIR}" = "/opt/gnome" ] && [ -d "/opt/gnome2" ]; then
GNOMEDIR="/opt/gnome2"
fi
#
# Add the shell function and related variables used by the post-uninstall.
#
NS_COMMENT1="#--Netscape Communications Corporation MIME Information"
NS_COMMENT2="#Do not delete the above line. It is used to identify the file type."
NS_COMMENT3="#mime types added by Netscape Helper"
UpdateMailcap() {
mailcap_file="$1"
mime_type="$2"
command="$3"
if [ -z "`grep -E \"^${mime_type}; ${command}$\" \"${mailcap_file}\" 2> /dev/null`" ]; then
mc_comment="# Java Web Start"
mc_text=
if [ -w "${mailcap_file}" ]; then
regexp="(${mime_type})|(${mc_comment})"
mc_text=`grep -Ev "${regexp}" "${mailcap_file}"`
fi
if [ -w "`dirname \"${mailcap_file}\"`" ]; then
mc_text="${mc_text:+${mc_text}\n}${mime_type}; ${command}"
echo -e "${mc_text}" > "${mailcap_file}"
else
echo "WARNING - cannot write to file:"
echo " ${mailcap_file}"
echo "Check permissions."
fi
fi
}
RemoveMailcap() {
mailcap_file="$1"
mime_type="$2"
mc_comment="# Java Web Start"
if [ -w "${mailcap_file}" ]; then
if [ -n "`grep \"${mime_type}\" \"${mailcap_file}\"`" ] ; then
regexp="(${mime_type})|(${mc_comment})"
mc_text=`grep -Ev "${regexp}" "${mailcap_file}"`
if [ `echo "${mc_text}" | tr -d '[:space:]' | wc -c` -gt 0 ]; then
echo "${mc_text}" > "${mailcap_file}"
else
rm -f "${mailcap_file}"
fi
fi
fi
}
UpdateMimeTypes() {
mime_file="$1"
mime_type="$2"
desc="$3"
shift 3
exts="$*"
JNLP_ENTRY="type=${mime_type} desc=\"${desc}\" exts=\"${exts}\""
if [ ! -w "${mime_file}" ]; then
if [ -w `dirname ${mime_file}` ]; then
echo "${NS_COMMENT1}" > "${mime_file}"
echo "${NS_COMMENT2}" >> "${mime_file}"
echo "${NS_COMMENT3}" >> "${mime_file}"
else
echo "WARNING - cannot write to file:"
echo " ${mime_file}"
echo "Check permissions."
return
fi
fi
if [ -z "`grep -E \"^[^#]*${mime_type}\" \"${mime_file}\"`" ]; then
echo ${JNLP_ENTRY} >> "${mime_file}"
fi
}
RemoveMimeTypes() {
mime_file="$1"
mime_type="$2"
if [ -w "${mime_file}" ]; then
if [ -n "`grep \"${mime_type}\" \"${mime_file}\"`" ]; then
regexp="(${mime_type})|(^${NS_COMMENT1}$)|(^${NS_COMMENT2}$)|(^${NS_COMMENT3}$)"
if [ `grep -Ev "${regexp}" "${mime_file}" | \
tr -d '[:space:]' | wc -c` -gt 0 ]
then
mt_text="`grep -v \"${mime_type}\" \"${mime_file}\"`"
echo "${mt_text}" > "${mime_file}"
else
rm -f "${mime_file}"
fi
fi
fi
}
MOST_DIGITS="[1-9]"
ALL_DIGITS="[0-9]"
COUNTING_NUMBER="${MOST_DIGITS}${ALL_DIGITS}*\|0"
VALID_NON_NUMERIC="[-_.a-zA-Z]"
VALID_CHARS="[-_.a-zA-Z0-9]"
MAJOR_RULE="\(${MOST_DIGITS}${ALL_DIGITS}*\)"
MINOR_RULE="\(${COUNTING_NUMBER}\)"
MICRO_RULE="\(${COUNTING_NUMBER}\)"
UPDATE_RULE="\(${MOST_DIGITS}${ALL_DIGITS}${ALL_DIGITS}\|${MOST_DIGITS}${ALL_DIGITS}\|0${ALL_DIGITS}\)"
NON_FCS_ID_RULE="\([a-zA-Z0-9]*\)"
MIN_VERSION_ID_RULE="${MAJOR_RULE}\.${MINOR_RULE}\.${MICRO_RULE}"
FCS_VERSION_ID_RULE="${MIN_VERSION_ID_RULE}\(_${UPDATE_RULE}\)\?"
VERSION_ID_RULE="${FCS_VERSION_ID_RULE}\(-${NON_FCS_ID_RULE}\)\?"
NAME_ID_RULE="${VALID_CHARS}*${VALID_NON_NUMERIC}"
KNOWN_GOOD_NAME_LIST="java jdk jre j2sdk j2re"
PRS_ERROR_BAD_PARAMS=2000
expand_version() {
status=0
if [ $# -eq 0 ]; then
read release remainder
status=$?
if [ ${status} -ne 0 ]; then
printf "Error(${status}: failed to read!\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
elif [ -z "${release}" ]; then
printf "Error: usage - function requires input!\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
elif [ -n "${remainder}" ]; then
printf "Error: too many words read:\n\n" >> /dev/stderr
printf "\t${release} ${remainder}\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
fi
elif [ $# -eq 1 ]; then
release=$1
else
printf "Error: usage - function takes 1 parameter:\n\n" >> /dev/stderr
printf "\t expand_version $*\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
fi
if [ ${status} -eq 0 ]; then
format="%d\t%d\t%d\t%d\n"
echo ${release} | sed -e "s/_/\./g" | \
awk -v format="${format}" 'BEGIN { FS = "." } { printf format, $1, $2, $3, $4 }'
fi
return ${status}
}
parse_release() {
status=0
if [ $# -eq 0 ]; then
read string remainder
status=$?
if [ ${status} -ne 0 ]; then
printf "Error(${status}: failed to read!\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
elif [ -z "${string}" ]; then
printf "Error: usage - function requires input!\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
elif [ -n "${remainder}" ]; then
printf "Error: too many words read:\n\n" >> /dev/stderr
printf "\t${string} ${remainder}\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
fi
elif [ $# -eq 1 ]; then
string=$1
else
printf "Error: usage - function takes 1 parameter:\n\n" >> /dev/stderr
printf "\t parse_release $*\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
fi
if [ ${status} -eq 0 ]; then
version_id=`expr "${string}" : "${NAME_ID_RULE}\(${VERSION_ID_RULE}\)\$"`
if [ -n "${version_id}" ]; then
name_id=`expr "${string}" : "\(${NAME_ID_RULE}\)${VERSION_ID_RULE}\$"`
fcs_part=`expr "${string}" : "${NAME_ID_RULE}\(${FCS_VERSION_ID_RULE}\).*\$"`
non_fcs_part=`expr "${version_id}" : "[^-]*-\(${NON_FCS_ID_RULE}\)\$"`
printf "${name_id}\t${fcs_part}\t${non_fcs_part}\n"
fi
fi
return ${status}
}
UNKNOWN_NAME_WEIGHT=1000
get_name_weight() {
status=0
if [ "$1" = "-" ]; then
read name good_names
status=$?
if [ ${status} -ne 0 ]; then
printf "Error(${status}: failed to read!\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
else
shift 1
if [ $# -gt 0 ]; then
good_names="$*"
fi
if [ -z "${name}" ]; then
printf "Error: usage - function requires input!\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
fi
fi
elif [ $# -gt 1 ]; then
name=$1
shift 1
good_names="$*"
else
printf "Error: usage - function takes 2+ parameters:\n\n" >> /dev/stderr
printf "\t get_name_weight $*\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
fi
if [ ${status} -eq 0 ]; then
if [ -n "${good_names}" ]; then
length=`expr length "${good_names}"`
pos=`expr "${good_names}" : ".*\<${name}\>"`
if [ ${pos} -gt 0 ]; then
expr substr "${good_names}" 1 ${pos} | wc -w | tr -d "[:space:]"
else
echo ${UNKNOWN_NAME_WEIGHT}
fi
else
echo ${UNKNOWN_NAME_WEIGHT}
fi
fi
return ${status}
}
HAS_FCS_WEIGHT=0
HAS_ODD_FCS_WEIGHT=1
HAS_RC_WEIGHT=100
HAS_ODD_RC_WEIGHT=101
HAS_BETA_WEIGHT=300
HAS_ODD_BETA_WEIGHT=301
HAS_EA_WEIGHT=500
HAS_ODD_EA_WEIGHT=501
HAS_INTRNAL_WEIGHT=2000
HAS_VERY_ODD_WEIGHT=9999
get_non_fcs_weight() {
status=0
if [ $# -eq 0 ]; then
read non_fcs_part remainder
status=$?
if [ ${status} -ne 0 ]; then
printf "Error(${status}: failed to read!\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
elif [ -n "${remainder}" ]; then
printf "Error: too many words read:\n\n" >> /dev/stderr
printf "\t${non_fcs_part} ${remainder}\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
fi
elif [ $# -eq 1 ]; then
non_fcs_part=$1
else
printf "Error: usage - function takes 1 parameter:\n\n" >> /dev/stderr
printf "\t get_non_fcs_weight $*\n" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
fi
if [ ${status} -eq 0 ]; then
if [ -z "${non_fcs_part}" ]; then
echo ${HAS_FCS_WEIGHT}
else
case "${non_fcs_part}" in
fcs)
echo ${HAS_ODD_FCS_WEIGHT}
;;
rc)
echo ${HAS_RC_WEIGHT}
;;
rc[0-9] | rc[0-9][0-9])
count=`expr "${non_fcs_part}" : "rc\([0-9]*\)$"`
echo `expr ${HAS_RC_WEIGHT} - ${count}`
;;
rc*)
echo ${HAS_ODD_RC_WEIGHT}
;;
beta)
echo ${HAS_BETA_WEIGHT}
;;
beta[0-9] | beta[0-9][0-9])
count=`expr "${non_fcs_part}" : "beta\([0-9]*\)$"`
echo `expr ${HAS_BETA_WEIGHT} - ${count}`
;;
beta*)
echo ${HAS_ODD_BETA_WEIGHT}
;;
ea)
echo ${HAS_EA_WEIGHT}
;;
ea[0-9] | ea[0-9][0-9])
count=`expr "${non_fcs_part}" : "ea\([0-9]*\)$"`
echo `expr ${HAS_EA_WEIGHT} - ${count}`
;;
ea*)
echo ${HAS_ODD_EA_WEIGHT}
;;
internal)
echo ${HAS_INTRNAL_WEIGHT}
;;
internal[0-9] | internal[0-9][0-9] | internal[0-9][0-9][0-9])
count=`expr "${non_fcs_part}" : "internal\([0-9]*\)$"`
echo `expr ${HAS_INTRNAL_WEIGHT} - ${count}`
;;
b[0-9] | b[0-9][0-9] | b[0-9][0-9][0-9])
count=`expr "${non_fcs_part}" : "b\([0-9]*\)$"`
echo `expr ${HAS_INTRNAL_WEIGHT} - ${count}`
;;
*)
echo ${HAS_VERY_ODD_WEIGHT}
;;
esac
fi
fi
return ${status}
}
get_path_weight() {
good_list="$1"
path=$2
release=`basename ${path}`
parts="`parse_release ${release}`"
if [ $? -eq 0 ]; then
name=`echo "${parts}" | cut -f1`
version=`echo "${parts}" | cut -f2`
non_fcs=`echo "${parts}" | cut -f3`
if [ -n "${version}" ]; then
v_weight=`echo ${version} | expand_version`
n_weight=`echo ${name} | get_name_weight - "${good_list}"`
o_weight=`echo ${non_fcs} | get_non_fcs_weight`
printf "%4d %4d %4d %4d %4d %4d %s\n" \
${v_weight} ${n_weight} ${o_weight} "${path}"
fi
fi
}
get_weighted_list() {
good_list=
verify=
stdio=
status=0
check=true
while [ -n "${check}" ]; do
if [ $# -gt 0 ]; then
case "$1" in
-g)
good_list="$2"
shift 2
;;
--good-list=*)
length=`expr length "$1"`
remove=`expr \( length "--good-list=" \) + 1`
good_list="`expr substr \"$1\" ${remove} ${length}`"
shift 1
;;
-v | --verify)
verify=true
shift 1
;;
--)
shift 1
check=
;;
-)
shift 1
stdio=true
;;
-*)
printf "Error: usage - unknown parameter:\n\n" \
>> /dev/stderr
printf "\t%s : %s\n" "$1" "$*" >> /dev/stderr
status=${PRS_ERROR_BAD_PARAMS}
check=
;;
*)
check=
;;
esac
else
check=
fi
done
if [ $# -eq 0 ] || [ -n "${stdio}" ]; then
read line
while [ -n "${line}" ]; do
if [ -z "${verify}" ] || [ -f ${line}/bin/java ]; then
get_path_weight "${good_list}" ${line}
fi
read line
done
fi
while [ $# -gt 0 ]; do
if [ -z "${verify}" ] || [ -f $1/bin/java ]; then
get_path_weight "${good_list}" $1
fi
shift 1
done
return ${status}
}
_compare_java_by_weight() {
compare=0
if [ $# -ne 0 ]; then
if [ $# -eq 1 ]; then
compare=1
else
left=$1
right=$2
shift 2
good="$*"
list=`get_weighted_list --good-list="${good}" \
${left} ${right} | sort -u -k1n -k2n -k3n -k4n -k5rn -k6rn`
if [ `echo "${list}" | wc -l | tr -d "[:space:]"` -ne 1 ]; then
compare=-1
latest=`echo "${list}" | tail -n 1 | cut -c 37-`
if [ "${left}" = "${latest}" ]; then
compare=1
fi
fi
fi
fi
echo ${compare}
}
compare_java_by_version() {
_compare_java_by_weight $1 $2
}
compare_java_by_release() {
_compare_java_by_weight $1 $2 ${KNOWN_GOOD_NAME_LIST}
}
find_latest_release() {
if [ -d /usr/java ]; then
latest_release=`find /usr/java/* -prune | \
get_weighted_list -v --good-list="${KNOWN_GOOD_NAME_LIST}" | \
sort -k1n -k2n -k3n -k4n -k5rn -k6rn | tail -n 1 | cut -c 37-`
fi
if [ -d "${RPM_INSTALL_PREFIX}" ] && \
[ "/usr/java" != "${RPM_INSTALL_PREFIX}" ]
then
prefix_release=`find ${RPM_INSTALL_PREFIX}/* -prune | \
get_weighted_list -v --good-list="${KNOWN_GOOD_NAME_LIST}" | \
sort -k1n -k2n -k3n -k4n -k5rn -k6rn | tail -n 1 | cut -c 37-`
if [ `compare_java_by_release ${latest_release} ${prefix_release}` -lt 0 ]; then
latest_release=${prefix_release}
fi
fi
echo ${latest_release}
}
get_javaws() {
path=$1
if [ `compare_java_by_version ${path} version-1.5.0` -ge 0 ] &&
[ -f ${path}/bin/javaws ]
then
path=${path}/bin/javaws
elif [ `compare_java_by_version ${path} version-1.4.2` -ge 0 ]; then
if [ -f ${path}/jre/javaws/javaws ]; then
path=${path}/jre/javaws/javaws
elif [ -f ${path}/javaws/javaws ]; then
path=${path}/javaws/javaws
else
path=
fi
else
path=
fi
echo ${path}
}
LINK_ERROR_BAD_PARAMS=3000
LINK_ERROR_DEAD_LINK=3001
LINK_ERROR_FILE_NOT_FOUND=3002
dereference() {
status=0
if [ "$1" = "-f" ] || [ "$1" = "--follow" ]; then
follow="--follow"
shift 1
fi
if [ $# -ge 1 ]; then
path="$*"
if [ -e "${path}" ]; then
parent="`cd \`dirname \"${path}\"\`; pwd`"
child="`basename \"${path}\"`"
if [ "${parent}" != "${child}" ]; then
path="${parent}/${child}"
fi
if [ -h "${path}" ]; then
path=`ls -l "${path}" | sed -e "s#^.*${path} -> ##"`
if [ "`expr substr \"${path}\" 1 1`" != "/" ]; then
path="${parent}/${path}"
fi
if [ -n "${follow}" ]; then
path="`dereference ${follow} ${path}`"
fi
fi
else
status=${LINK_ERROR_FILE_NOT_FOUND}
fi
fi
echo ${path}
return ${status}
}
setup_latest_link() {
latest=$1
link=$2
if [ -h "${link}" ]; then
reference="`dereference --follow ${link}`"
if [ $? -eq 0 ]; then
update=`compare_java_by_release "${latest}" "${reference}"`
else
update=1
fi
if [ ${update} -gt 0 ]; then
rm -f "${link}"
fi
fi
if [ ! -e "${link}" ]; then
ln -s "${latest}" "${link}"
fi
}
setup_default_links() {
if [ $# -ge 2 ]; then
latest_link="$1"
default_link="$2"
if [ ! -e "${default_link}" ]; then
ln -s "${latest_link}" "${default_link}"
fi
fi
if [ $# -gt 3 ]; then
bindir="$3"
shift 3
for file in $*; do
reference="`dereference --follow ${bindir}/${file}`"
if [ $? -ne 0 ]; then
rm -f "${bindir}/${file}"
fi
source="${default_link}/bin/${file}"
if [ "${file}" = "javaws" ]; then
source="`get_javaws \"${default_link}\"`"
fi
if [ -n "${source}" ] && [ ! -e "${bindir}/${file}" ]; then
ln -s "${source}" "${bindir}/${file}"
fi
done
fi
}
cleanup_default_links() {
if [ $# -ge 1 ]; then
default_link=$1
if [ $# -gt 2 ]; then
bindir="$2"
shift 2
for file in $*; do
reference="`dereference \"${bindir}/${file}\"`"
if [ $? -ne 0 ] ||
[ "${reference}" = "${default_link}/bin/${file}" ]
then
rm -f "${bindir}/${file}"
fi
done
fi
rm -f "${default_link}"
fi
}
alt_install_java() {
priority=$1
jrebindir=$2
jremandir=$3
/usr/sbin/alternatives --install \
/usr/bin/java java $jrebindir/java $priority \
--slave /usr/bin/ControlPanel ControlPanel $jrebindir/ControlPanel --slave /usr/bin/javaws javaws $jrebindir/javaws --slave /usr/bin/jcontrol jcontrol $jrebindir/jcontrol --slave /usr/bin/jjs jjs $jrebindir/jjs --slave /usr/bin/keytool keytool $jrebindir/keytool --slave /usr/bin/orbd orbd $jrebindir/orbd --slave /usr/bin/pack200 pack200 $jrebindir/pack200 --slave /usr/bin/policytool policytool $jrebindir/policytool --slave /usr/bin/rmid rmid $jrebindir/rmid --slave /usr/bin/rmiregistry rmiregistry $jrebindir/rmiregistry --slave /usr/bin/servertool servertool $jrebindir/servertool --slave /usr/bin/tnameserv tnameserv $jrebindir/tnameserv --slave /usr/bin/unpack200 unpack200 $jrebindir/unpack200 --slave /usr/share/man/man1/java.1 java.1 $jremandir/java.1 --slave /usr/share/man/man1/javaws.1 javaws.1 $jremandir/javaws.1 --slave /usr/share/man/man1/jjs.1 jjs.1 $jremandir/jjs.1 --slave /usr/share/man/man1/keytool.1 keytool.1 $jremandir/keytool.1 --slave /usr/share/man/man1/orbd.1 orbd.1 $jremandir/orbd.1 --slave /usr/share/man/man1/pack200.1 pack200.1 $jremandir/pack200.1 --slave /usr/share/man/man1/policytool.1 policytool.1 $jremandir/policytool.1 --slave /usr/share/man/man1/rmid.1 rmid.1 $jremandir/rmid.1 --slave /usr/share/man/man1/rmiregistry.1 rmiregistry.1 $jremandir/rmiregistry.1 --slave /usr/share/man/man1/servertool.1 servertool.1 $jremandir/servertool.1 --slave /usr/share/man/man1/tnameserv.1 tnameserv.1 $jremandir/tnameserv.1 --slave /usr/share/man/man1/unpack200.1 unpack200.1 $jremandir/unpack200.1
}
alt_remove_java() {
jrebindir=$1
/usr/sbin/alternatives --remove java $jrebindir/java
}
alt_install_javac() {
priority=$1
jdkbindir=$2
jdkmandir=$3
/usr/sbin/alternatives --install \
/usr/bin/javac javac $jdkbindir/javac $priority \
--slave /usr/bin/ControlPanel ControlPanel $jdkbindir/ControlPanel --slave /usr/bin/appletviewer appletviewer $jdkbindir/appletviewer --slave /usr/bin/extcheck extcheck $jdkbindir/extcheck --slave /usr/bin/idlj idlj $jdkbindir/idlj --slave /usr/bin/jar jar $jdkbindir/jar --slave /usr/bin/jarsigner jarsigner $jdkbindir/jarsigner --slave /usr/bin/java-rmi.cgi java-rmi.cgi $jdkbindir/java-rmi.cgi --slave /usr/bin/javadoc javadoc $jdkbindir/javadoc --slave /usr/bin/javafxpackager javafxpackager $jdkbindir/javafxpackager --slave /usr/bin/javah javah $jdkbindir/javah --slave /usr/bin/javap javap $jdkbindir/javap --slave /usr/bin/javapackager javapackager $jdkbindir/javapackager --slave /usr/bin/javaws javaws $jdkbindir/javaws --slave /usr/bin/jcmd jcmd $jdkbindir/jcmd --slave /usr/bin/jconsole jconsole $jdkbindir/jconsole --slave /usr/bin/jcontrol jcontrol $jdkbindir/jcontrol --slave /usr/bin/jdb jdb $jdkbindir/jdb --slave /usr/bin/jdeps jdeps $jdkbindir/jdeps --slave /usr/bin/jhat jhat $jdkbindir/jhat --slave /usr/bin/jinfo jinfo $jdkbindir/jinfo --slave /usr/bin/jjs jjs $jdkbindir/jjs --slave /usr/bin/jmap jmap $jdkbindir/jmap --slave /usr/bin/jmc jmc $jdkbindir/jmc --slave /usr/bin/jmc.ini jmc.ini $jdkbindir/jmc.ini --slave /usr/bin/jps jps $jdkbindir/jps --slave /usr/bin/jrunscript jrunscript $jdkbindir/jrunscript --slave /usr/bin/jsadebugd jsadebugd $jdkbindir/jsadebugd --slave /usr/bin/jstack jstack $jdkbindir/jstack --slave /usr/bin/jstat jstat $jdkbindir/jstat --slave /usr/bin/jstatd jstatd $jdkbindir/jstatd --slave /usr/bin/jvisualvm jvisualvm $jdkbindir/jvisualvm --slave /usr/bin/keytool keytool $jdkbindir/keytool --slave /usr/bin/native2ascii native2ascii $jdkbindir/native2ascii --slave /usr/bin/orbd orbd $jdkbindir/orbd --slave /usr/bin/pack200 pack200 $jdkbindir/pack200 --slave /usr/bin/policytool policytool $jdkbindir/policytool --slave /usr/bin/rmic rmic $jdkbindir/rmic --slave /usr/bin/rmid rmid $jdkbindir/rmid --slave /usr/bin/rmiregistry rmiregistry $jdkbindir/rmiregistry --slave /usr/bin/schemagen schemagen $jdkbindir/schemagen --slave /usr/bin/serialver serialver $jdkbindir/serialver --slave /usr/bin/servertool servertool $jdkbindir/servertool --slave /usr/bin/tnameserv tnameserv $jdkbindir/tnameserv --slave /usr/bin/unpack200 unpack200 $jdkbindir/unpack200 --slave /usr/bin/wsgen wsgen $jdkbindir/wsgen --slave /usr/bin/wsimport wsimport $jdkbindir/wsimport --slave /usr/bin/xjc xjc $jdkbindir/xjc --slave /usr/share/man/man1/appletviewer.1 appletviewer.1 $jdkmandir/appletviewer.1 --slave /usr/share/man/man1/extcheck.1 extcheck.1 $jdkmandir/extcheck.1 --slave /usr/share/man/man1/idlj.1 idlj.1 $jdkmandir/idlj.1 --slave /usr/share/man/man1/jar.1 jar.1 $jdkmandir/jar.1 --slave /usr/share/man/man1/jarsigner.1 jarsigner.1 $jdkmandir/jarsigner.1 --slave /usr/share/man/man1/java.1 java.1 $jdkmandir/java.1 --slave /usr/share/man/man1/javac.1 javac.1 $jdkmandir/javac.1 --slave /usr/share/man/man1/javadoc.1 javadoc.1 $jdkmandir/javadoc.1 --slave /usr/share/man/man1/javafxpackager.1 javafxpackager.1 $jdkmandir/javafxpackager.1 --slave /usr/share/man/man1/javah.1 javah.1 $jdkmandir/javah.1 --slave /usr/share/man/man1/javap.1 javap.1 $jdkmandir/javap.1 --slave /usr/share/man/man1/javapackager.1 javapackager.1 $jdkmandir/javapackager.1 --slave /usr/share/man/man1/javaws.1 javaws.1 $jdkmandir/javaws.1 --slave /usr/share/man/man1/jcmd.1 jcmd.1 $jdkmandir/jcmd.1 --slave /usr/share/man/man1/jconsole.1 jconsole.1 $jdkmandir/jconsole.1 --slave /usr/share/man/man1/jdb.1 jdb.1 $jdkmandir/jdb.1 --slave /usr/share/man/man1/jdeps.1 jdeps.1 $jdkmandir/jdeps.1 --slave /usr/share/man/man1/jhat.1 jhat.1 $jdkmandir/jhat.1 --slave /usr/share/man/man1/jinfo.1 jinfo.1 $jdkmandir/jinfo.1 --slave /usr/share/man/man1/jjs.1 jjs.1 $jdkmandir/jjs.1 --slave /usr/share/man/man1/jmap.1 jmap.1 $jdkmandir/jmap.1 --slave /usr/share/man/man1/jmc.1 jmc.1 $jdkmandir/jmc.1 --slave /usr/share/man/man1/jps.1 jps.1 $jdkmandir/jps.1 --slave /usr/share/man/man1/jrunscript.1 jrunscript.1 $jdkmandir/jrunscript.1 --slave /usr/share/man/man1/jsadebugd.1 jsadebugd.1 $jdkmandir/jsadebugd.1 --slave /usr/share/man/man1/jstack.1 jstack.1 $jdkmandir/jstack.1 --slave /usr/share/man/man1/jstat.1 jstat.1 $jdkmandir/jstat.1 --slave /usr/share/man/man1/jstatd.1 jstatd.1 $jdkmandir/jstatd.1 --slave /usr/share/man/man1/jvisualvm.1 jvisualvm.1 $jdkmandir/jvisualvm.1 --slave /usr/share/man/man1/keytool.1 keytool.1 $jdkmandir/keytool.1 --slave /usr/share/man/man1/native2ascii.1 native2ascii.1 $jdkmandir/native2ascii.1 --slave /usr/share/man/man1/orbd.1 orbd.1 $jdkmandir/orbd.1 --slave /usr/share/man/man1/pack200.1 pack200.1 $jdkmandir/pack200.1 --slave /usr/share/man/man1/policytool.1 policytool.1 $jdkmandir/policytool.1 --slave /usr/share/man/man1/rmic.1 rmic.1 $jdkmandir/rmic.1 --slave /usr/share/man/man1/rmid.1 rmid.1 $jdkmandir/rmid.1 --slave /usr/share/man/man1/rmiregistry.1 rmiregistry.1 $jdkmandir/rmiregistry.1 --slave /usr/share/man/man1/schemagen.1 schemagen.1 $jdkmandir/schemagen.1 --slave /usr/share/man/man1/serialver.1 serialver.1 $jdkmandir/serialver.1 --slave /usr/share/man/man1/servertool.1 servertool.1 $jdkmandir/servertool.1 --slave /usr/share/man/man1/tnameserv.1 tnameserv.1 $jdkmandir/tnameserv.1 --slave /usr/share/man/man1/unpack200.1 unpack200.1 $jdkmandir/unpack200.1 --slave /usr/share/man/man1/wsgen.1 wsgen.1 $jdkmandir/wsgen.1 --slave /usr/share/man/man1/wsimport.1 wsimport.1 $jdkmandir/wsimport.1 --slave /usr/share/man/man1/xjc.1 xjc.1 $jdkmandir/xjc.1
}
alt_remove_javac() {
jdkbindir=$1
/usr/sbin/alternatives --remove javac $jdkbindir/javac
}
#
# The RPM update command installs a given version of a package, and then
# uninstalls all other versions of a package.
#
# The command does the following:
#
# 1) Run the %pre for the package being installed
# 2) Install the new package's files
# 3) Run the %post for the package being installed
# 4) Run the %preun for each package being uninstalled
# 5) Delete any old files not overwitten by the package being installed
# 6) Run the %postun for each package being uninstalled
#
# Note: Because each version of Java installs into its own unique directory,
# the only files in step 5 that might not be deleted are the files in
# /usr/java/jdk1.8.0_121/.java/.systemPrefs that are used for the Preferences API.
#
# Note: The order described above is also the same order that occurs when a
# user installs a new version, then uninstalls an old version at a
# later date. The only difference is the ammount of time that passes
# between steps 3 and 4.
#
# Because of this order, all changes made to the system by the package
# being installed are made *before* any changes made by packages being
# uninstalled. This means that it is important that the %preun and %postun
# scriptlets are written in a way that does not break any integration just
# setup by the new package. This makes it very difficult to determine what
# should and shouldn't be removed during %preun and %postun scriptlets.
#
# Packages written in the past have no idea what the future will hold. This
# is obvious, but it doesn't make it easy. One option is to assume users
# will always install newer versions over older versions, and will never
# keep multiple versions of the same package installed at the same time.
# This is actually the assumption that RPM is designed upon.
#
# However, the --force option can be used to force RPM to install an older
# package; a so called downgrade. In the past, Java RPM packages have
# always attempted to provide special support for downgrades. This can
# cause a lot of trouble given the design of RPM.
#
# This spec follows the recomended RPM practice. If the version being
# uninstalled is not the latest version, then nothing is done. However, if
# the version being uninstalled is the latest, then anything setup by the
# %post scriptlet that is not also tracked by the RPM database is removed.
#
# Unfortunately there are two damned kinds of Java installations for every
# given release, i.e. a JDK and a JRE. Because of this, it is possible that
# this version being uninstalled is the latest version, and that the version
# being left behind is the *same* version as this!
#
# In this case, it is necessary to fix anything just broken by the %preun
# scriptlet. This will only happen when the JDK is uninstalled, and the
# JRE of the same version is still on the system. For this, all that needs
# to be done is to repair the default and latest links.
#
# Determine if a new latest link should be created. This is done if
# there is still an installed version of Java that is 1.6 up to the
# the version of this package.
#
LATEST_JAVA_PATH="`find_latest_release`"
if [ -n "${LATEST_JAVA_PATH}" ] &&
[ `compare_java_by_version ${LATEST_JAVA_PATH} \
version-1.8.0_121` -lt 0 ]
then
#
# Only maintain the latest link if the latest version left on
# the system is the ugly stepsister to this one, i.e. this is
# the JDK, and the JRE of the same version remains.
#
# Note: if the latest is higher than the version of this
# package, then latest will either A) already exist,
# so there is nothing that needs to be done, or B) the
# latest link is no longer supported buy those versions,
# so this package shouldn't set it up.
#
setup_latest_link "${LATEST_JAVA_PATH}" "/usr/java/latest"
fi
#
# RPM_INSTALL_PREFIX is used since the package may have been relocated using
# --prefix of rpm.
#
rm -rf "${RPM_INSTALL_PREFIX}/jdk1.8.0_121" 2> /dev/null
if [ -e "/usr/java/latest" ]; then
#
# If the latest link exists, then make sure the default link exists.
#
# Note: instead of trying to determine whether or not the current latest
# installation is a JDK or a JRE, just assume it's a JDK.
#
setup_default_links "/usr/java/latest" "/usr/java/default" \
"/usr/bin" "java javaws jcontrol javac jar javadoc"
#
# If there is still an init script kicking around then restart/reinstall
# it in case it was stopped/uninstalled during %preun.
#
if [ -x /usr/java/jdk1.8.0_121/.java/init.d/jexec ]; then
#
# Try to register the init script to the various run levels. If
# possible this is accomplished using an LSB defined install tool.
# If that isn't available, then try to use chkconfig, which is
# supported by Red Hat and Debian. Otherwise it is up to the user
# to get the script setup for their distribution.
#
if [ -x /usr/lib/lsb/install_initd ]; then
/usr/lib/lsb/install_initd jexec > /dev/null 2>&1
# start the service for the current session
/usr/java/jdk1.8.0_121/.java/init.d/jexec start > /dev/null 2>&1
elif [ -x /sbin/chkconfig ]; then
/sbin/chkconfig --add jexec > /dev/null 2>&1
# start the service for the current session
/usr/java/jdk1.8.0_121/.java/init.d/jexec start > /dev/null 2>&1
fi
fi
fi
#
# Remove java and javac alternatives
#
if [ 1 = 1 ]; then
alt_remove_java "${RPM_INSTALL_PREFIX}/jdk1.8.0_121/jre/bin"
alt_remove_javac "${RPM_INSTALL_PREFIX}/jdk1.8.0_121/bin"
else
alt_remove_java "${RPM_INSTALL_PREFIX}/jdk1.8.0_121/bin"
$ java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)