Merge ~vpa1977/ubuntu/+source/ca-certificates-java:dpkg-trigger into ubuntu/+source/ca-certificates-java:ubuntu/devel

Proposed by Vladimir Petko
Status: Merged
Merged at revision: 1a1275024ad4cbf1cea8fd74dfc78dce54e62806
Proposed branch: ~vpa1977/ubuntu/+source/ca-certificates-java:dpkg-trigger
Merge into: ubuntu/+source/ca-certificates-java:ubuntu/devel
Diff against target: 249 lines (+124/-31)
9 files modified
debian/ca-certificates-java.postinst (+19/-26)
debian/ca-certificates-java.triggers (+2/-3)
debian/changelog (+18/-0)
debian/control (+9/-2)
debian/tests/can-convert-keystore (+24/-0)
debian/tests/can-install-jre (+26/-0)
debian/tests/can-install-libreoffice (+4/-0)
debian/tests/can-install-multiple-jdks (+13/-0)
debian/tests/control (+9/-0)
Reviewer Review Type Date Requested Status
Steve Langasek (community) Approve
git-ubuntu import Pending
Review via email: mp+438150@code.launchpad.net

Description of the change

NOTE: Please do not merge this until all OpenJDK package updates are performed. This package breaks existing OpenJDK packages.

This change depends on openjdk-jre-headless triggering certificate updates in the postinst script. Prerequisite updates:
 - openjdk-8 [1] (merged)
 - openjdk-lts [2] (merged)
 - openjdk-17 [3] (merged)
 - openjdk-18 [4] (merged)
 - openjdk-19 [5] (merged)
 - openjdk-20 [6] (merged)
 - openjdk-21 [7] (merged)
Summary of changes:

  * Resolve circular JRE dependency (LP: #2003750, LP: #1999103, LP: #2004061)
    - debian/ca-certificates-java.postinst: remove setup_path, remove
      update_cacerts from "configure" stage.
    - debian/ca-certificates-java.postinst: do "fresh" update if cacerts file is not found. Certificates are refreshed only in response to the trigger activated by OpenJDK packages.
    - debian/ca-certificates-java.postinst: fix cacert enumeration command for Java 8.
    - debian/control: remove JRE dependency.
    - debian/control: add Breaks condition.
    - debian/tests: add smoke tests.
    - debian/ca-certificates-java.triggers: remove file trigger /usr/jvm.

PPA: ppa:vpa1977/ca-certificates-java-dpkg [8]

Steps to test:
   autopackage tests should pass

Autopackage test results:
autopkgtest [08:33:54]: @@@@@@@@@@@@@@@@@@@@ summary
can-convert-keystore PASS
can-install-jre PASS
can-install-multiple-jdks PASS
can-install-libreoffice PASS

[1] https://code.launchpad.net/~vpa1977/ubuntu/+source/openjdk-8/+git/openjdk-8/+merge/438158
[2] https://code.launchpad.net/~vpa1977/ubuntu/+source/openjdk-lts/+git/openjdk-lts/+merge/438159
[3] https://code.launchpad.net/~vpa1977/ubuntu/+source/openjdk-17/+git/openjdk-17/+merge/438151
[4] https://code.launchpad.net/~vpa1977/ubuntu/+source/openjdk-18/+git/openjdk-18/+merge/438160
[5] https://code.launchpad.net/~vpa1977/ubuntu/+source/openjdk-19/+git/openjdk-19/+merge/438187
[6] https://code.launchpad.net/~vpa1977/ubuntu/+source/openjdk-20/+git/openjdk-20/+merge/438161
[7] https://code.launchpad.net/~vpa1977/ubuntu/+source/openjdk-21/+git/openjdk-21/+merge/438162
[8] https://launchpad.net/~vpa1977/+archive/ubuntu/ca-certificates-java-dpkg

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :

> This package breaks existing OpenJDK packages.

Well currently debian/control lists the Breaks but they are commented out! Provided we actually land the Breaks: correctly, we don't have to wait for all openjdk updates before landing this (though it will make each of those JREs uninstallable in -proposed and break builds of anything build-depending on them, so we should make sure *default*-jre is sorted before landing this.)

Revision history for this message
Vladimir Petko (vpa1977) wrote (last edit ):

> Well currently debian/control lists the Breaks but they are commented out!
> Provided we actually land the Breaks: correctly, we don't have to wait for all
> openjdk updates before landing this (though it will make each of those JREs
> uninstallable in -proposed and break builds of anything build-depending on
> them, so we should make sure *default*-jre is sorted before landing this.)

I will wait for the ppa to finish building OpenJDK 18 and will uncomment the Breaks section.
We will have to land all the JDKs first so that they could build themselves from unbroken build.

Revision history for this message
Steve Langasek (vorlon) :
review: Needs Fixing
Revision history for this message
Vladimir Petko (vpa1977) wrote :

Uncommented Breaks, uploaded new version of openjdk-19. Once it builds I will update autopkgtest results.

Revision history for this message
Vladimir Petko (vpa1977) wrote :

> Uncommented Breaks, uploaded new version of openjdk-19. Once it builds I will
> update autopkgtest results.

updated tests results

Revision history for this message
Steve Langasek (vorlon) :
review: Needs Fixing
Revision history for this message
Steve Langasek (vorlon) wrote :

closing the version number gaps in the Breaks: is the last thing to change before sponsoring.

Revision history for this message
Steve Langasek (vorlon) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/ca-certificates-java.postinst b/debian/ca-certificates-java.postinst
2index 94c6c03..f53c4ee 100644
3--- a/debian/ca-certificates-java.postinst
4+++ b/debian/ca-certificates-java.postinst
5@@ -18,30 +18,6 @@ LOCALCERTSDIR=/usr/local/share/ca-certificates
6 ETCCERTSDIR=/etc/ssl/certs
7 CACERTS=$ETCCERTSDIR/java/cacerts
8
9-setup_path()
10-{
11- for version in 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
12- for jvm in \
13- java-${version}-openjdk-${arch} \
14- java-${version}-openjdk \
15- oracle-java${version}-jre-${arch} \
16- oracle-java${version}-server-jre-${arch} \
17- oracle-java${version}-jdk-${arch}
18- do
19- if [ -x /usr/lib/jvm/$jvm/bin/java ]; then
20- export JAVA_HOME=/usr/lib/jvm/$jvm
21- PATH=$JAVA_HOME/bin:$PATH
22- break 2
23- fi
24- done
25- done
26-
27- if ! which java >/dev/null; then
28- echo "No JRE found. Skipping Java certificates setup."
29- exit 0
30- fi
31-}
32-
33 check_proc()
34 {
35 if ! mountpoint -q /proc; then
36@@ -90,7 +66,10 @@ update_cacerts()
37 exit 0
38 fi
39
40- setup_path
41+ if ! which java >/dev/null; then
42+ echo "No JRE found. Skipping Java certificates setup."
43+ exit 0
44+ fi
45
46 if [ -f /var/lib/ca-certificates-java/convert_pkcs12_keystore_to_jks ]; then
47 convert_pkcs12_keystore_to_jks
48@@ -103,7 +82,17 @@ update_cacerts()
49
50 if [ -f "$CACERTS" ]; then
51 check_proc
52- cacerts_aliases=$(keytool -cacerts -storepass "$storepass" -list -rfc | sed -n 's/^Alias name: *debian://ip' | tr '\n' ' ')
53+
54+ # Java 8 does not have -cacerts option
55+ if java -version 2>&1 | grep "1.8" > /dev/null ;
56+ then
57+ castore="-keystore ${CACERTS}"
58+ else
59+ castore="-cacerts"
60+ fi
61+
62+ cacerts_aliases=$(keytool ${castore} -storepass "$storepass" -list -rfc | sed -n 's/^Alias name: *debian://ip' | tr '\n' ' ')
63+
64 etc_ssl_certs_aliases=$(for pem in $pem_files ; do echo -n "$(basename "$pem" | tr A-Z a-z) "; done)
65 for alias in $cacerts_aliases ; do
66 case " $etc_ssl_certs_aliases " in
67@@ -177,5 +166,9 @@ if [ "$1" = "triggered" ]; then
68 ;;
69 esac
70
71+ if [ ! -f $CACERTS ]; then
72+ touch /var/lib/ca-certificates-java/fresh
73+ fi
74+
75 update_cacerts
76 fi
77diff --git a/debian/ca-certificates-java.triggers b/debian/ca-certificates-java.triggers
78index bde4336..e97bbf5 100644
79--- a/debian/ca-certificates-java.triggers
80+++ b/debian/ca-certificates-java.triggers
81@@ -1,3 +1,2 @@
82-interest update-ca-certificates-java
83-interest update-ca-certificates-java-fresh
84-interest /usr/lib/jvm
85+interest-await update-ca-certificates-java
86+interest-await update-ca-certificates-java-fresh
87diff --git a/debian/changelog b/debian/changelog
88index c316775..b92bc31 100644
89--- a/debian/changelog
90+++ b/debian/changelog
91@@ -1,3 +1,21 @@
92+ca-certificates-java (20230103ubuntu1) lunar; urgency=medium
93+
94+ * Resolve circular JRE dependency (LP: #2003750, LP: #1999103, LP: #2004061)
95+ - debian/ca-certificates-java.postinst: remove setup_path from "configure"
96+ stage.
97+ - debian/ca-certificates-java.postinst: do "fresh" update if cacerts file is
98+ not found. Certificates are refreshed only in response to the trigger
99+ activated by OpenJDK packages.
100+ - debian/ca-certificates-java.postinst: fix cacert enumeration command for
101+ Java 8.
102+ - debian/control: remove JRE dependency.
103+ - debian/control: add Breaks condition.
104+ - debian/tests: add smoke tests.
105+ - debian/ca-certificates-java.triggers: remove file trigger /usr/jvm,
106+ explicitly declare triggers as -await.
107+
108+ -- Vladimir Petko <vladimir.petko@canonical.com> Wed, 01 Mar 2023 13:31:58 +1300
109+
110 ca-certificates-java (20230103) unstable; urgency=medium
111
112 * Promote again the JRE recommendation to a dependency. Otherwise
113diff --git a/debian/control b/debian/control
114index 87cfc5f..5545acd 100644
115--- a/debian/control
116+++ b/debian/control
117@@ -1,7 +1,8 @@
118 Source: ca-certificates-java
119 Section: java
120 Priority: optional
121-Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
122+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
123+XSBC-Original-Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
124 Uploaders: Matthias Klose <doko@ubuntu.com>,
125 James Page <james.page@ubuntu.com>
126 Build-Depends:
127@@ -20,7 +21,13 @@ Multi-Arch: foreign
128 Depends:
129 ca-certificates (>= 20210120),
130 ${misc:Depends},
131- default-jre-headless (>= 2:1.8) | java8-runtime-headless,
132+Breaks: openjdk-8-jre-headless (<<8u362-ga-0ubuntu2~),
133+ openjdk-11-jre-headless (<<11.0.18+10-0ubuntu3~),
134+ openjdk-17-jre-headless (<<17.0.6+10-1ubuntu1~),
135+ openjdk-18-jre-headless (<<18.0.2+9-2ubuntu1~),
136+ openjdk-19-jre-headless (<<19.0.2+7-0ubuntu4~),
137+ openjdk-20-jre-headless (<<20~26ea-1ubuntu1~),
138+ openjdk-21-jre-headless (<<21~7ea-1ubuntu1~)
139 Description: Common CA certificates (JKS keystore)
140 This package uses the hooks of the ca-certificates package to update the
141 cacerts JKS keystore used for many java runtimes.
142diff --git a/debian/tests/can-convert-keystore b/debian/tests/can-convert-keystore
143new file mode 100644
144index 0000000..041189b
145--- /dev/null
146+++ b/debian/tests/can-convert-keystore
147@@ -0,0 +1,24 @@
148+#!/bin/bash
149+set -e
150+# GIVEN a PKCS12 Java keystore
151+ETCCERTSDIR=/etc/ssl/certs
152+CACERTS=$ETCCERTSDIR/java/cacerts
153+rm $CACERTS
154+keytool -importcert -noprompt -alias Amazon -file /etc/ssl/certs/Amazon_Root_CA_1.pem -trustcacerts -storepass changeit -storetype PKCS12 -keystore test.store 2> /dev/null
155+apt-get remove -y ca-certificates-java
156+
157+mkdir -p /etc/ssl/certs/java/
158+mkdir -p /var/lib/ca-certificates-java/
159+mv test.store $CACERTS
160+# WHEN ca-certificates-java is requested to convert the keystore
161+touch /var/lib/ca-certificates-java/convert_pkcs12_keystore_to_jks
162+
163+# THEN conversion is successful
164+output=`mktemp`
165+apt-get install -y openjdk-8-jre-headless | tee ${output}
166+
167+if [[ $(grep -L "Entry for alias amazon successfully imported." ${output}) ]];
168+then
169+ echo "Certificates were not imported !!!"
170+ exit 255
171+fi
172diff --git a/debian/tests/can-install-jre b/debian/tests/can-install-jre
173new file mode 100644
174index 0000000..fd27d6e
175--- /dev/null
176+++ b/debian/tests/can-install-jre
177@@ -0,0 +1,26 @@
178+#!/bin/bash
179+set -e
180+versions=$(apt-cache search jre-headless | awk '{print $1}')
181+for version in ${versions}
182+do
183+# WHEN openjdk-jre-headless package is installed from scratch
184+
185+ # Java 18 is EOL 09.2022 but is present in Lunar so that we could do clean
186+ # builds. Ignore it in certificate tests
187+ if [[ ${version} == "openjdk-18-jre-headless" ]];
188+ then
189+ continue
190+ fi
191+ output=`mktemp`
192+ echo "installing ${version}"
193+ apt-get install -y ${version} | tee ${output}
194+# THEN installation is successfull
195+# AND certificates are updated
196+ if [[ $(grep -L "Adding debian:Amazon_Root_CA_1.pem" ${output}) ]]; then
197+ echo "Certificates were not imported !!!"
198+ exit 255
199+ fi
200+ rm $output
201+ # purge in order to remove keytstore
202+ apt-get purge -y ca-certificates-java ${version}
203+done
204\ No newline at end of file
205diff --git a/debian/tests/can-install-libreoffice b/debian/tests/can-install-libreoffice
206new file mode 100755
207index 0000000..b1d9937
208--- /dev/null
209+++ b/debian/tests/can-install-libreoffice
210@@ -0,0 +1,4 @@
211+#!/bin/bash
212+set -e
213+
214+apt-get install -y libreoffice
215\ No newline at end of file
216diff --git a/debian/tests/can-install-multiple-jdks b/debian/tests/can-install-multiple-jdks
217new file mode 100755
218index 0000000..614a9f6
219--- /dev/null
220+++ b/debian/tests/can-install-multiple-jdks
221@@ -0,0 +1,13 @@
222+#!/bin/bash
223+set -e
224+
225+output=`mktemp`
226+# WHEN multiple JDKs are installed
227+apt-get install -y openjdk-11-jdk openjdk-17-jdk openjdk-8-jdk | tee ${output}
228+
229+# THEN installation is successful
230+if [[ $(grep -L "Adding debian:Amazon_Root_CA_1.pem" ${output}) ]]; then
231+ echo "Certificates were not imported !!!"
232+ exit 255
233+fi
234+rm $output
235diff --git a/debian/tests/control b/debian/tests/control
236new file mode 100644
237index 0000000..17f2dac
238--- /dev/null
239+++ b/debian/tests/control
240@@ -0,0 +1,9 @@
241+Tests: can-convert-keystore
242+Depends: default-jre-headless
243+Restrictions: needs-root
244+
245+Tests: can-install-jre, can-install-multiple-jdks, can-install-libreoffice
246+# No depends, this is a test for a clean install
247+Depends:
248+Restrictions: needs-root
249+

Subscribers

People subscribed via source and target branches