Merge ~vpa1977/ubuntu/+source/android-platform-tools-base:ubuntu/devel into ubuntu/+source/android-platform-tools-base:ubuntu/devel

Proposed by Vladimir Petko
Status: Merged
Merged at revision: 3026345b2c4df8b9afcd1a7f2e63614a27ea65a4
Proposed branch: ~vpa1977/ubuntu/+source/android-platform-tools-base:ubuntu/devel
Merge into: ubuntu/+source/android-platform-tools-base:ubuntu/devel
Diff against target: 155 lines (+103/-2)
6 files modified
debian/changelog (+11/-0)
debian/control (+2/-1)
debian/patches/add-exports.patch (+1/-1)
debian/patches/bouncycastle177-compat.patch (+57/-0)
debian/patches/der-output-stream.patch (+30/-0)
debian/patches/series (+2/-0)
Reviewer Review Type Date Requested Status
Pushkar Kulkarni (community) Approve
git-ubuntu import Pending
Review via email: mp+461857@code.launchpad.net

Description of the change

This MP resolves ftbfs due to sun.security and BouncyCastle API changes.

PPA: ppa:vpa1977/plusone [1]

Changes:
 - resolve ftbfs due to BouncyCastle and internal Java API changes.

Testing:
 - package builds [2]
 - piuparts test [3]
 - rebuild kotlin (build-dep)[4]

[1] https://launchpad.net/~vpa1977/+archive/ubuntu/plusone
[2] https://launchpad.net/~vpa1977/+archive/ubuntu/plusone/+sourcepub/15840966/+listing-archive-extra
[3] https://bugs.launchpad.net/ubuntu/+source/android-platform-tools-base/+bug/2056088/comments/1
[4] https://launchpad.net/~vpa1977/+archive/ubuntu/plusone-rebuild/+build/27880378

To post a comment you must log in.
Revision history for this message
Pushkar Kulkarni (pushkarnk) wrote :

The changes LGTM.

The upstream release that we currently include seems to be quite old (2016) [1]. I couldn't find newer releases. Might make sense to check and confirm if we really need to maintain this package, going forward.

[1] https://android.googlesource.com/platform/tools/base/+/refs/tags/studio-2.2.2

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 175b081..c11c862 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,14 @@
6+android-platform-tools-base (2.2.2-4ubuntu1) noble; urgency=medium
7+
8+ * Resolve the failure to build from source (LP: #2056088):
9+ - d/p/{der-output-stream.patch, add-exports.patch}: sun.security
10+ PKCS7 class now only supports encoding to DerOutputStream.
11+ Explicitly instantiate it.
12+ - d/p/bouncycastle177-compat.patch: use ASN1OutputStream instead
13+ of remove DerOutputStream.
14+
15+ -- Vladimir Petko <vladimir.petko@canonical.com> Wed, 06 Mar 2024 13:16:37 +1300
16+
17 android-platform-tools-base (2.2.2-4) unstable; urgency=medium
18
19 * Team upload.
20diff --git a/debian/control b/debian/control
21index 76cb394..95e3524 100644
22--- a/debian/control
23+++ b/debian/control
24@@ -1,7 +1,8 @@
25 Source: android-platform-tools-base
26 Section: java
27 Priority: optional
28-Maintainer: Android Tools Maintainers <android-tools-devel@lists.alioth.debian.org>
29+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
30+XSBC-Original-Maintainer: Android Tools Maintainers <android-tools-devel@lists.alioth.debian.org>
31 Uploaders: Hans-Christoph Steiner <hans@eds.org>,
32 Build-Depends:
33 antlr3,
34diff --git a/debian/patches/add-exports.patch b/debian/patches/add-exports.patch
35index 6d46ed2..9705b7e 100644
36--- a/debian/patches/add-exports.patch
37+++ b/debian/patches/add-exports.patch
38@@ -5,7 +5,7 @@
39 }
40
41 +compileJava {
42-+ options.compilerArgs << '--add-exports' << 'java.base/sun.security.pkcs=ALL-UNNAMED' << '--add-exports' << 'java.base/sun.security.x509=ALL-UNNAMED'
43++ options.compilerArgs << '--add-exports' << 'java.base/sun.security.pkcs=ALL-UNNAMED' << '--add-exports' << 'java.base/sun.security.x509=ALL-UNNAMED' << '--add-exports' << 'java.base/sun.security.util=ALL-UNNAMED'
44 +}
45 +
46 task initSdkForTests(type: JavaExec) {
47diff --git a/debian/patches/bouncycastle177-compat.patch b/debian/patches/bouncycastle177-compat.patch
48new file mode 100644
49index 0000000..60d6038
50--- /dev/null
51+++ b/debian/patches/bouncycastle177-compat.patch
52@@ -0,0 +1,57 @@
53+Description: bouncycastle 1.77 compatibility patch
54+ Remove usages of DerOutputStream that is no longer public.
55+Author: Vladimir Petko <vladimir.petko@canonical.com>
56+Bug-Ubuntu: https://bugs.launchpad.net/debian/+source/android-platform-tools-base/+bug/2056088
57+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1058331
58+Forwarded: not-needed
59+Last-Update: 2024-03-06
60+
61+--- a/build-system/builder/src/main/java/com/android/builder/internal/packaging/sign/SignatureExtension.java
62++++ b/build-system/builder/src/main/java/com/android/builder/internal/packaging/sign/SignatureExtension.java
63+@@ -29,7 +29,8 @@
64+
65+ import org.apache.commons.codec.binary.Base64;
66+ import org.bouncycastle.asn1.ASN1InputStream;
67+-import org.bouncycastle.asn1.DEROutputStream;
68++import org.bouncycastle.asn1.ASN1OutputStream;
69++import org.bouncycastle.asn1.ASN1Encoding;
70+ import org.bouncycastle.cert.jcajce.JcaCertStore;
71+ import org.bouncycastle.cms.CMSException;
72+ import org.bouncycastle.cms.CMSProcessableByteArray;
73+@@ -610,12 +611,12 @@
74+ /*
75+ * DEROutputStream is not closeable! OMG!
76+ */
77+- DEROutputStream dos = null;
78++ ASN1OutputStream dos = null;
79+ try (ASN1InputStream asn1 = new ASN1InputStream(sigData.getEncoded())) {
80+- dos = new DEROutputStream(outputBytes);
81++ dos = ASN1OutputStream.create(outputBytes, ASN1Encoding.DER);
82+ dos.writeObject(asn1.readObject());
83+
84+- DEROutputStream toClose = dos;
85++ ASN1OutputStream toClose = dos;
86+ dos = null;
87+ toClose.close();
88+ } catch (IOException e) {
89+--- a/build-system/builder/src/main/java/com/android/builder/signing/SignedJarApkCreator.java
90++++ b/build-system/builder/src/main/java/com/android/builder/signing/SignedJarApkCreator.java
91+@@ -33,7 +33,8 @@
92+ import com.google.common.io.Files;
93+
94+ import org.bouncycastle.asn1.ASN1InputStream;
95+-import org.bouncycastle.asn1.DEROutputStream;
96++import org.bouncycastle.asn1.ASN1OutputStream;
97++import org.bouncycastle.asn1.ASN1Encoding;
98+ import org.bouncycastle.cert.jcajce.JcaCertStore;
99+ import org.bouncycastle.cms.CMSException;
100+ import org.bouncycastle.cms.CMSProcessableByteArray;
101+@@ -400,7 +401,7 @@
102+ CMSSignedData sigData = gen.generate(data, false);
103+
104+ try (ASN1InputStream asn1 = new ASN1InputStream(sigData.getEncoded())) {
105+- DEROutputStream dos = new DEROutputStream(mOutputJar);
106++ ASN1OutputStream dos = ASN1OutputStream.create(mOutputJar, ASN1Encoding.DER);
107+ try {
108+ dos.writeObject(asn1.readObject());
109+ } finally {
110diff --git a/debian/patches/der-output-stream.patch b/debian/patches/der-output-stream.patch
111new file mode 100644
112index 0000000..d711939
113--- /dev/null
114+++ b/debian/patches/der-output-stream.patch
115@@ -0,0 +1,30 @@
116+Description: workaround removal of pkcs7.encodeSignedData(OutputStream)
117+ pkcs7.encodeSignedData(OutputStream) was removed in Java 21.
118+ Explicitly instantiate DerOutputStream to encode pkcs7 contents.
119+Author: Vladimir Petko <vladimir.petko@canonical.com>
120+Bug-Ubuntu: https://bugs.launchpad.net/debian/+source/android-platform-tools-base/+bug/2056088
121+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1058331
122+Forwarded: not-needed
123+Last-Update: 2024-03-06
124+
125+--- a/sdklib/src/main/java/com/android/sdklib/internal/build/SignedJarBuilder.java
126++++ b/sdklib/src/main/java/com/android/sdklib/internal/build/SignedJarBuilder.java
127+@@ -25,6 +25,7 @@
128+ import sun.security.pkcs.SignerInfo;
129+ import sun.security.x509.AlgorithmId;
130+ import sun.security.x509.X500Name;
131++import sun.security.util.DerOutputStream;
132+
133+ import java.io.BufferedOutputStream;
134+ import java.io.ByteArrayOutputStream;
135+@@ -394,6 +395,9 @@
136+ new X509Certificate[] { publicKey },
137+ new SignerInfo[] { signerInfo });
138+
139+- pkcs7.encodeSignedData(mOutputJar);
140++ try (DerOutputStream derout = new DerOutputStream()) {
141++ pkcs7.encodeSignedData(derout);
142++ mOutputJar.write(derout.toByteArray());
143++ }
144+ }
145+ }
146diff --git a/debian/patches/series b/debian/patches/series
147index 2961d30..387aeb9 100644
148--- a/debian/patches/series
149+++ b/debian/patches/series
150@@ -22,3 +22,5 @@ gradle-compatibility.patch
151 ecj-compatibility.patch
152 asm-dependency.patch
153 add-exports.patch
154+der-output-stream.patch
155+bouncycastle177-compat.patch

Subscribers

People subscribed via source and target branches