diff --git a/clients/android/Makefile b/clients/android/Makefile index f5e6957ee..5cab0c3ff 100644 --- a/clients/android/Makefile +++ b/clients/android/Makefile @@ -7,10 +7,11 @@ install: ./check-environment.pl ant debug -dockerdebug: +env: docker build -t camlistore/android devenv - docker run -v $(GOPATH)/src/camlistore.org/clients/android:/src/camlistore -w /src/camlistore camlistore/android ant -Dsdk.dir=/usr/local/android-sdk-linux debug + +dockerdebug: + docker run -v $(GOPATH)/src/camlistore.org:/src/camlistore.org camlistore/android /src/camlistore.org/clients/android/build-in-docker.pl debug dockerrelease: - docker build -t camlistore/android devenv - docker run -i -t -v $(GOPATH)/src/camlistore.org/clients/android:/src/camlistore -v $(HOME)/keys/android-camlistore:/keys -w /src/camlistore camlistore/android ant -Dsdk.dir=/usr/local/android-sdk-linux -Dkey.store=/keys/android-camlistore.keystore -Dkey.alias=camkey release + docker run -i -t -v $(GOPATH)/src/camlistore.org:/src/camlistore.org -v $(HOME)/keys/android-camlistore:/keys camlistore/android /src/camlistore.org/clients/android/build-in-docker.pl release diff --git a/clients/android/assets/camput.arm.oldworks b/clients/android/assets/camput.arm.oldworks deleted file mode 100755 index 810fbdcef..000000000 Binary files a/clients/android/assets/camput.arm.oldworks and /dev/null differ diff --git a/clients/android/build-in-docker.pl b/clients/android/build-in-docker.pl new file mode 100755 index 000000000..50d8c9339 --- /dev/null +++ b/clients/android/build-in-docker.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl + +use strict; +use File::Path qw(make_path); + +die "This script is meant to be run within the camlistore/android Docker contain. Run 'make env' to build it.\n" + unless $ENV{IN_DOCKER}; + +my $mode = shift || "debug"; + +my $ANDROID = "/src/camlistore.org/clients/android"; +my $ASSETS = "$ANDROID/assets"; +my $GENDIR = "$ANDROID/gen/org/camlistore"; + +umask 0; +make_path($GENDIR, { mode => 0755 }) unless -d $GENDIR; + +$ENV{GOROOT} = "/usr/local/go"; +$ENV{GOBIN} = $GENDIR; +$ENV{GOPATH} = "/"; +$ENV{GOARCH} = "arm"; +print "Building ARM camlistore.org/cmd/camput\n"; +system("/usr/local/go/bin/go", "install", "camlistore.org/cmd/camput") + and die "Failed to build camput"; + +system("cp", "-p", "$GENDIR/linux_arm/camput", "$ASSETS/camput.arm") + and die "cp failure"; +# TODO: build an x86 version too? if/when those Android devices matter. + +chdir $ASSETS or die "can't cd to assets dir"; + +my $digest = `openssl sha1 camput.arm`; +chomp $digest; +print "ARM camput is $digest\n"; +die "No digest" unless $digest; +write_file("$GENDIR/ChildProcessConfig.java", "package org.camlistore; public final class ChildProcessConfig { // $digest\n}"); + +print "Running ant $mode\n"; +chdir $ANDROID or die "can't cd to android dir"; +exec "ant", + "-Dsdk.dir=/usr/local/android-sdk-linux", + "-Dkey.store=/keys/android-camlistore.keystore", + "-Dkey.alias=camkey", + $mode; + +sub write_file { + my ($file, $contents) = @_; + if (open(my $fh, $file)) { + my $cur = do { local $/; <$fh> }; + return if $cur eq $contents; + } + open(my $fh, ">$file") or die "Failed to open $file: $!"; + print $fh $contents; + close($fh) or die "Close: $!"; + print "Wrote $file\n"; +} diff --git a/clients/android/devenv/Dockerfile b/clients/android/devenv/Dockerfile index 45bf68f0d..fcd40cec4 100644 --- a/clients/android/devenv/Dockerfile +++ b/clients/android/devenv/Dockerfile @@ -3,6 +3,18 @@ FROM wasabeef/android MAINTAINER bradfitz +# Don't need this, since we're just using the archive URL to fetch Go. +# But it's possible we may want to switch to using hg, in which case: +# RUN yum -y install mercurial + +ENV GOVERS ec5195954667 +RUN cd /usr/local && curl -O http://go.googlecode.com/archive/$GOVERS.zip +RUN cd /usr/local && unzip -q $GOVERS.zip +RUN cd /usr/local && mv go-$GOVERS go +RUN chmod 0755 /usr/local/go/src/make.bash +RUN echo $GOVERS > /usr/local/go/VERSION +RUN GOROOT=/usr/local/go GOARCH=arm bash -c "cd /usr/local/go/src && ./make.bash" + # Found these from: android list sdk -u -e RUN echo y | android update sdk -u -t android-17 RUN echo y | android update sdk -u -t build-tools-19.0.1 @@ -15,3 +27,4 @@ ENV PATH $PATH:$ANDROID_HOME/platform-tools ENV PATH $PATH:$ANT_HOME/bin ENV PATH $PATH:$MAVEN_HOME/bin ENV PATH $PATH:$GRADLE_HOME/bin +ENV IN_DOCKER 1