Skip to content

Commit 8704daa

Browse files
committed
Add Dockerfile for an Android build environment
// FREEBIE
1 parent e189862 commit 8704daa

File tree

3 files changed

+117
-1
lines changed

3 files changed

+117
-1
lines changed

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM ubuntu:14.04.3
2+
3+
RUN dpkg --add-architecture i386 && \
4+
apt-get update -y && \
5+
apt-get install -y software-properties-common && \
6+
add-apt-repository -y ppa:openjdk-r/ppa && \
7+
apt-get update -y && \
8+
apt-get install -y libc6:i386=2.19-0ubuntu6.7 libncurses5:i386=5.9+20140118-1ubuntu1 libstdc++6:i386=4.8.4-2ubuntu1~14.04.1 lib32z1=1:1.2.8.dfsg-1ubuntu1 wget openjdk-8-jdk=8u72-b15-1~trusty1 git unzip && \
9+
rm -rf /var/lib/apt/lists/* && \
10+
apt-get autoremove -y && \
11+
apt-get clean
12+
13+
ENV ANDROID_SDK_FILENAME android-sdk_r24.4.1-linux.tgz
14+
ENV ANDROID_SDK_URL https://dl.google.com/android/${ANDROID_SDK_FILENAME}
15+
ENV ANDROID_API_LEVELS android-22
16+
ENV ANDROID_BUILD_TOOLS_VERSION 22.0.1
17+
ENV ANDROID_HOME /usr/local/android-sdk-linux
18+
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
19+
RUN cd /usr/local/ && \
20+
wget -q ${ANDROID_SDK_URL} && \
21+
tar -xzf ${ANDROID_SDK_FILENAME} && \
22+
rm ${ANDROID_SDK_FILENAME}
23+
RUN echo y | android update sdk --no-ui -a --filter ${ANDROID_API_LEVELS}
24+
RUN echo y | android update sdk --no-ui -a --filter extra-android-m2repository,extra-android-support,extra-google-google_play_services,extra-google-m2repository
25+
RUN echo y | android update sdk --no-ui -a --filter tools,platform-tools,build-tools-${ANDROID_BUILD_TOOLS_VERSION}
26+
RUN rm -rf ${ANDROID_HOME}/tools && unzip ${ANDROID_HOME}/temp/*.zip -d ${ANDROID_HOME}

apkdiff/apkdiff.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#! /usr/bin/env python
2+
3+
import sys
4+
from zipfile import ZipFile
5+
6+
class ApkDiff:
7+
8+
IGNORE_FILES = ["META-INF/CERT.RSA", "META-INF/CERT.SF", "META-INF/MANIFEST.MF"]
9+
10+
def compare(self, sourceApk, destinationApk):
11+
sourceZip = ZipFile(sourceApk, 'r')
12+
destinationZip = ZipFile(destinationApk, 'r')
13+
14+
if self.compareManifests(sourceZip, destinationZip) and self.compareEntries(sourceZip, destinationZip) == True:
15+
print "APKs match!"
16+
else:
17+
print "APKs don't match!"
18+
19+
def compareManifests(self, sourceZip, destinationZip):
20+
sourceEntrySortedList = sorted(sourceZip.namelist())
21+
destinationEntrySortedList = sorted(destinationZip.namelist())
22+
23+
for ignoreFile in self.IGNORE_FILES:
24+
while ignoreFile in sourceEntrySortedList: sourceEntrySortedList.remove(ignoreFile)
25+
while ignoreFile in destinationEntrySortedList: destinationEntrySortedList.remove(ignoreFile)
26+
27+
if len(sourceEntrySortedList) != len(destinationEntrySortedList):
28+
print "Manifest lengths differ!"
29+
30+
for (sourceEntryName, destinationEntryName) in zip(sourceEntrySortedList, destinationEntrySortedList):
31+
if sourceEntryName != destinationEntryName:
32+
print "Sorted manifests don't match, %s vs %s" % (sourceEntryName, destinationEntryName)
33+
return False
34+
35+
return True
36+
37+
def compareEntries(self, sourceZip, destinationZip):
38+
sourceInfoList = filter(lambda sourceInfo: sourceInfo.filename not in self.IGNORE_FILES, sourceZip.infolist())
39+
destinationInfoList = filter(lambda destinationInfo: destinationInfo.filename not in self.IGNORE_FILES, destinationZip.infolist())
40+
41+
if len(sourceInfoList) != len(destinationInfoList):
42+
print "APK info lists of different length!"
43+
return False
44+
45+
for sourceEntryInfo in sourceInfoList:
46+
for destinationEntryInfo in list(destinationInfoList):
47+
if sourceEntryInfo.filename == destinationEntryInfo.filename:
48+
sourceEntry = sourceZip.open(sourceEntryInfo, 'r')
49+
destinationEntry = destinationZip.open(destinationEntryInfo, 'r')
50+
51+
if self.compareFiles(sourceEntry, destinationEntry) != True:
52+
print "APK entry %s does not match %s!" % (sourceEntryInfo.filename, destinationEntryInfo.filename)
53+
return False
54+
55+
destinationInfoList.remove(destinationEntryInfo)
56+
break
57+
58+
return True
59+
60+
def compareFiles(self, sourceFile, destinationFile):
61+
sourceChunk = sourceFile.read(1024)
62+
destinationChunk = destinationFile.read(1024)
63+
64+
while sourceChunk != "" and destinationChunk != "":
65+
if sourceChunk != destinationChunk:
66+
return False
67+
68+
sourceChunk = sourceFile.read(1024)
69+
destinationChunk = destinationFile.read(1024)
70+
71+
return True
72+
73+
if __name__ == '__main__':
74+
if len(sys.argv) != 3:
75+
print "Usage: apkdiff <pathToFirstApk> <pathToSecondApk>"
76+
sys.exit(1)
77+
78+
ApkDiff().compare(sys.argv[1], sys.argv[2])

build.gradle

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ android {
163163
minSdkVersion 9
164164
targetSdkVersion 22
165165

166-
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
166+
buildConfigField "long", "BUILD_TIMESTAMP", getLastCommitTimestamp() + "L"
167167
buildConfigField "String", "TEXTSECURE_URL", "\"https://textsecure-service.whispersystems.org\""
168168
buildConfigField "String", "USER_AGENT", "\"OWA\""
169169
buildConfigField "String", "REDPHONE_MASTER_URL", "\"https://redphone-master.whispersystems.org\""
@@ -249,6 +249,18 @@ tasks.whenTaskAdded { task ->
249249
}
250250
}
251251

252+
def getLastCommitTimestamp() {
253+
new ByteArrayOutputStream().withStream { os ->
254+
def result = exec {
255+
executable = 'git'
256+
args = ['log', '-1', '--pretty=format:%ct']
257+
standardOutput = os
258+
}
259+
260+
return os.toString() + "000"
261+
}
262+
}
263+
252264
def Properties props = new Properties()
253265
def propFile = new File('signing.properties')
254266

0 commit comments

Comments
 (0)