Bug 1258760 - Allow re-signing already signed APK files. r=gps
authorNick Alexander <nalexander@mozilla.com>
Tue, 15 Mar 2016 16:01:44 -0700
changeset 289768 8725d09652fb8c960b651acfc31496dad64425ed
parent 289767 8ae2e73a7d903b1ba90cb5c77ad89a852ab7f733
child 289769 1ddb71cf5d35e4d72bdcb232060e2587b700881d
push id30109
push userkwierso@gmail.com
push dateTue, 22 Mar 2016 23:29:46 +0000
treeherdermozilla-central@5453ae837f6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1258760
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1258760 - Allow re-signing already signed APK files. r=gps Gradle produces signed, unaligned APK files. We expect unsigned, unaligned APK files. This change discards any existing signature, turning a signed, unaligned APK into an unsigned, unaligned APK. Sadly |zip -q| does not silence a warning message about "nothing to do" so we pipe to /dev/null. MozReview-Commit-ID: DnSGJCvHsym
config/android-common.mk
--- a/config/android-common.mk
+++ b/config/android-common.mk
@@ -19,18 +19,25 @@ ifdef MOZ_SIGN_CMD
 RELEASE_JARSIGNER := $(MOZ_SIGN_CMD) -f jar
 else
 RELEASE_JARSIGNER := $(DEBUG_JARSIGNER)
 endif
 
 # $(1) is the full path to input:  foo-debug-unsigned-unaligned.apk.
 # $(2) is the full path to output: foo.apk.
 # Use this like: $(call RELEASE_SIGN_ANDROID_APK,foo-debug-unsigned-unaligned.apk,foo.apk)
+#
+# The |zip -d| there to handle re-signing previously signed APKs.  Gradle
+# produces signed, unaligned APK files, but this expects unsigned, unaligned
+# APK files.  The |zip -d| discards any existing signature, turning a signed,
+# unaligned APK into an unsigned, unaligned APK.  Sadly |zip -q| doesn't
+# silence a warning about "nothing to do" so we pipe to /dev/null.
 RELEASE_SIGN_ANDROID_APK = \
   cp $(1) $(2)-unaligned.apk && \
+  ($(ZIP) -d $(2)-unaligned.apk 'META-INF/*' > /dev/null || true) && \
   $(RELEASE_JARSIGNER) $(2)-unaligned.apk && \
   $(ZIPALIGN) -f -v 4 $(2)-unaligned.apk $(2) && \
   $(RM) $(2)-unaligned.apk
 
 # For Android, we default to 1.7
 ifndef JAVA_VERSION
   JAVA_VERSION = 1.7
 endif