. $(dirname $0)/functions # SQLite is a special beast -- its source is maintained in regular # C files, but it is distributed (and maintained in Android in that # form) in concatenated files. # # Grabbing it from fossil (its SCM) is not as useful as with other # projects -- so let's parse its website for updates. # # Also, its release numbering scheme doesn't quite match that of the # rest of the world (The release is 3.8.10.1, but the filename is # 3081001 -- 3.8.10 becomes 3081000...) idtoversion() { local VERSIONID=$1 local MAJORLEN=$((${#VERSIONID}-6)) local V1=$(echo $VERSIONID |cut -b1-${MAJORLEN} | sed -e 's,^0*,,') local V2=$(echo $VERSIONID |cut -b$((MAJORLEN+1))-$((MAJORLEN+2)) | sed -e 's,^0,,') local V3=$(echo $VERSIONID |cut -b$((MAJORLEN+3))-$((MAJORLEN+4)) | sed -e 's,^0,,') local V4=$(echo $VERSIONID |cut -b$((MAJORLEN+5))-$((MAJORLEN+6)) | sed -e 's,^0*,,') local V="$V1.$V2.$V3" [ -n "$V4" ] && V="$V.$V4" echo -n $V } versiontoid() { echo -n $(echo $1 |cut -d. -f1)$(digits 2 $(echo $1 |cut -d. -f2))$(digits 2 $(echo $1 |cut -d. -f3))$(digits 2 $(echo $1 |cut -d. -f4)) } LATEST=`curl http://www.sqlite.org/download.html |grep /sqlite-amalgamation |cut -d\' -f4 |grep -v snapshot` if ! echo $LATEST |grep -qE '[0-9][0-9][0-9][0-9]/sqlite-amalgamation-[0-9]+\.zip'; then error "SQLite download page changed its format." exit 1 fi VERSIONID=`echo $LATEST |cut -d- -f3 |sed -e 's,\..*,,'` V=`idtoversion $VERSIONID` checkout platform/external/sqlite cd $SRC/platform/external/sqlite if git branch -a |grep -q linaro-upstream-$V; then ok "SQLite is up to date." exit 0 fi git checkout -b linaro-upstream-work-$TIMESTAMP aosp/master # We can't rely on dist/version - upstream frequently forgets to update it AOSPVER=`grep -E 'SQLITE_VERSION.*"[0-9].*"' dist/sqlite3.h |cut -d\" -f2` if [ "$V" = "$AOSPVER" ]; then notice "SQLite is up to date in AOSP master, copying its work" else notice "Updating SQLite to $V" cd dist LANG=C diff -rud orig . |grep -v "Only in" >Android.patch cd .. wget http://www.sqlite.org/$LATEST ZIPFILE=`basename $LATEST` unzip $ZIPFILE cp -f `basename $ZIPFILE .zip`/* dist/ mv `basename $ZIPFILE .zip`/* dist/orig/ cd dist if patch -p1 version LANG=C diff -rud orig . |grep -v "Only in" >Android.patch git commit -asm "Update to SQLite $V" git clean -d -f -x else error "Couldn't auto-update SQLite - patch failed to apply." error "Please fix manually and commit to a branch called" error "linaro-upstream-$V." exit 1 fi cd .. fi git push origin linaro-upstream-work-$TIMESTAMP:linaro-upstream-$V git pull git checkout -b linaro-upstream-$V origin/linaro-upstream-$V git branch -D linaro-upstream-work-$TIMESTAMP pwd