#!/bin/sh . $(dirname $0)/settings TIMESTAMP="`date +%Y%m%d%H%M%S`" # Expand $2 to $1 digits # Example: digits 3 4 # Result: 004 digits() { local i echo -n $( ( for i in `seq 1 $1`; do echo -n 0; done ; echo -n $2 ) | rev | cut -b1-$1 | rev) } # Determine the latest of a list of versions # Current assumptions for simplicity that might cause problems # in the future: Version numbers are fully numeric (no 1.2.3a), # and consist of at most 4 components of at most 3 digits each. # # Example: latest 1.2.3 1.2.3.1 1.1.4.99 0.99 1 # Result: 1.2.3.1 latest() { local LATEST=0 local LATESTID=0 local VERSION local VERSIONID for VERSION in "$@"; do VERSIONID=$(digits 3 $(echo $VERSION |cut -d. -f1))$(digits 3 $(echo $VERSION |cut -d. -f2))$(digits 3 $(echo $VERSION |cut -d. -f3))$(digits 3 $(echo $VERSION |cut -d. -f4)) [ $VERSIONID -lt $LATESTID ] && continue LATEST=$VERSION LATESTID=$VERSIONID done echo -n $LATEST } # Check out a Linaro AOSP git repository with # corresponding upstream checkout() { local D=$(dirname $1) local B=$(basename $1) [ -d $SRC ] || mkdir -p $SRC pushd $SRC mkdir -p $D cd $D rm -rf $B git clone ssh://$USER@android-review.linaro.org:29418/$1.git cd $B [ -n "$NAME" ] && git config user.name $NAME [ -n "$EMAIL" ] && git config user.email $EMAIL git remote add aosp https://android-review.googlesource.com/$1.git git fetch aosp || git remote rm aosp [ "$B" = "libpng" ] && git remote add upstream git://git.code.sf.net/p/libpng/code [ "$B" = "harfbuzz_ng" ] && git remote add upstream git://anongit.freedesktop.org/harfbuzz.git [ "$B" = "fio" ] && git remote add upstream git://git.kernel.dk/fio.git [ "$B" = "kmod" ] && git remote add upstream git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git git fetch --all git pull popd } # Display an error error() { echo "ERROR: $@" } # Display a warning warning() { echo "WARNING: $@" } # Display a notice notice() { echo "NOTICE: $@" } # Display something went ok ok() { echo "OK: $@" }