github.com/slspeek/camlistore_namedsearch@v0.0.0-20140519202248-ed6f70f7721a/clients/android/build-in-docker.pl (about) 1 #!/usr/bin/perl 2 3 use strict; 4 use File::Path qw(make_path); 5 6 die "This script is meant to be run within the camlistore/android Docker contain. Run 'make env' to build it.\n" 7 unless $ENV{IN_DOCKER}; 8 9 my $mode = shift || "debug"; 10 11 my $ANDROID = "/src/camlistore.org/clients/android"; 12 my $ASSETS = "$ANDROID/assets"; 13 my $GENDIR = "$ANDROID/gen/org/camlistore"; 14 15 umask 0; 16 make_path($GENDIR, { mode => 0755 }) unless -d $GENDIR; 17 18 $ENV{GOROOT} = "/usr/local/go"; 19 $ENV{GOBIN} = $GENDIR; 20 $ENV{GOPATH} = "/"; 21 $ENV{GOARCH} = "arm"; 22 print "Building ARM camlistore.org/cmd/camput\n"; 23 system("/usr/local/go/bin/go", "install", "camlistore.org/cmd/camput") 24 and die "Failed to build camput"; 25 26 system("cp", "-p", "$GENDIR/linux_arm/camput", "$ASSETS/camput.arm") 27 and die "cp failure"; 28 # TODO: build an x86 version too? if/when those Android devices matter. 29 30 { 31 open(my $vfh, ">$ASSETS/camput-version.txt") or die "open camput-version error: $!"; 32 # TODO(bradfitz): make these values automatic, and don't make the 33 # "Version" menu say "camput version" when it runs. Also maybe 34 # keep a history of these somewhere more convenient. 35 print $vfh "app 0.6.1 camput ccacf764 go 70499e5fbe5b"; 36 } 37 38 chdir $ASSETS or die "can't cd to assets dir"; 39 40 my $digest = `openssl sha1 camput.arm`; 41 chomp $digest; 42 print "ARM camput is $digest\n"; 43 die "No digest" unless $digest; 44 write_file("$GENDIR/ChildProcessConfig.java", "package org.camlistore; public final class ChildProcessConfig { // $digest\n}"); 45 46 print "Running ant $mode\n"; 47 chdir $ANDROID or die "can't cd to android dir"; 48 exec "ant", 49 "-Dsdk.dir=/usr/local/android-sdk-linux", 50 "-Dkey.store=/keys/android-camlistore.keystore", 51 "-Dkey.alias=camkey", 52 $mode; 53 54 sub write_file { 55 my ($file, $contents) = @_; 56 if (open(my $fh, $file)) { 57 my $cur = do { local $/; <$fh> }; 58 return if $cur eq $contents; 59 } 60 open(my $fh, ">$file") or die "Failed to open $file: $!"; 61 print $fh $contents; 62 close($fh) or die "Close: $!"; 63 print "Wrote $file\n"; 64 }