1#!/bin/bash 2# 3# Copyright 2016 The Android Open Source Project. 4# 5# Retrieves the specified version of libphonenumber into the 6# external/libphonenumber directory 7# 8# Does not create a GIT commit. 9if [ $# -ne 1 ]; then 10 echo "usage: $0 <version>" 11 echo " where <version> is the version number, e.g. 7.7.3" 12 exit 1 13fi 14if [ -z "$ANDROID_BUILD_TOP" ]; then 15 echo "Missing environment variables. Did you run build/envsetup.sh and lunch?" 1>&2 16 exit 1 17fi 18 19VERSION=$1 20TAG=v$VERSION 21SOURCE="https://github.com/googlei18n/libphonenumber/" 22DIR=$ANDROID_BUILD_TOP/external/libphonenumber 23tmp=$(mktemp -d) 24trap "echo Removing temporary directory; rm -fr $tmp" EXIT 25echo "Fetching source into $tmp" 26(cd $tmp; git clone -q -b $TAG --depth 1 $SOURCE source) 27for i in $(ls $tmp/source/java) 28do 29 echo "Updating $i" 30 rm -fr $DIR/$i 31 cp -r $tmp/source/java/$i $DIR/$i 32 (cd $DIR; git add $i) 33done 34for i in README.version README.android 35do 36 echo "Updating $i" 37 cp $DIR/$i $tmp 38 sed "s|Version: .*$|Version: $VERSION|" < $tmp/$i > $DIR/$i 39 (cd $DIR; git add $i) 40done 41${DIR}/srcgen/generate_android_src.sh 42git add repackaged 43