diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2010-04-22 13:24:15 -0700 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2010-04-23 07:04:27 -0700 |
commit | 711cb30f723a126f1119d60288c74e058e26717e (patch) | |
tree | bd6d0447af9c4cc6761ffbd751d9b154c908ec72 | |
parent | d29f32426321107e0b9134132f7e011ddfcef254 (diff) | |
download | common-711cb30f723a126f1119d60288c74e058e26717e.tar.gz |
Blob-handling-script-generator
Change-Id: If1f83a2512c78cf74bc1ff88c8076d7c3154b20d
-rwxr-xr-x | generate-blob-scripts.sh | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/generate-blob-scripts.sh b/generate-blob-scripts.sh new file mode 100755 index 0000000..0fe4654 --- /dev/null +++ b/generate-blob-scripts.sh @@ -0,0 +1,209 @@ +#!/usr/bin/env bash + +# Copyright (C) 2010 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script auto-generates the scripts that manage the handling of the +# proprietary blobs necessary to build the Android Open-Source Project code +# for dream, passion and sapphire targets + +# It needs to be run from the root of a source tree that can repo sync, +# runs builds with and without the vendor tree, and uses the difference +# to generate the scripts. + +# It can optionally upload the results to a Gerrit server for review. + +# WARNING: It destroys the vendor tree. Don't leave anything precious there. + +# Caveat: this script does 6 full builds (2 per device). It takes a while +# to run. It's best # suited for overnight runs on multi-CPU machines +# with a lot of RAM. + +# Syntax: device/htc/common/generate-blob-scripts.sh -f|--force [server branch] +# +# If the server and branch paramters are both present, the script will upload +# new files (if there's been any change) to the mentioned Gerrit server, +# in the specified branch. + +if test "$1" != "-f" -a "$1" != "--force" +then + echo This script must be run with the --force option + exit 1 +fi +shift + +ARCHIVEDIR=archive-$(date +%s) +mkdir $ARCHIVEDIR + +repo sync +repo sync +. build/envsetup.sh +rm -rf out +lunch full_dream-user +make -j8 +cat out/target/product/dream/installed-files.txt | cut -b 15- | sort > dream-with.txt +rm -rf out +lunch full_sapphire-user +make -j8 +cat out/target/product/sapphire/installed-files.txt | cut -b 15- | sort > sapphire-with.txt +rm -rf out +lunch full_passion-user +make -j8 +cat out/target/product/passion/installed-files.txt | cut -b 15- | sort > passion-with.txt +rm -rf vendor +rm -rf out +lunch full_dream-user +make -j8 +cat out/target/product/dream/installed-files.txt | cut -b 15- | sort > dream-without.txt +rm -rf out +lunch full_sapphire-user +make -j8 +cat out/target/product/sapphire/installed-files.txt | cut -b 15- | sort > sapphire-without.txt +rm -rf out +lunch full_passion-user +make -j8 +cat out/target/product/passion/installed-files.txt | cut -b 15- | sort > passion-without.txt + +for DEVICENAME in dream passion sapphire +do + cp $DEVICENAME-with.txt $DEVICENAME-without.txt $ARCHIVEDIR + for FILESTYLE in extract unzip + do + ( + echo '#!/bin/sh' + echo + echo '# Copyright (C) 2010 The Android Open Source Project' + echo '#' + echo '# Licensed under the Apache License, Version 2.0 (the "License");' + echo '# you may not use this file except in compliance with the License.' + echo '# You may obtain a copy of the License at' + echo '#' + echo '# http://www.apache.org/licenses/LICENSE-2.0' + echo '#' + echo '# Unless required by applicable law or agreed to in writing, software' + echo '# distributed under the License is distributed on an "AS IS" BASIS,' + echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' + echo '# See the License for the specific language governing permissions and' + echo '# limitations under the License.' + echo + echo '# This file is generated by device/htc/common/generate-blob-scripts.sh - DO NOT EDIT' + echo + echo DEVICE=$DEVICENAME + echo + echo 'mkdir -p ../../../vendor/htc/$DEVICE/proprietary' + + diff $DEVICENAME-without.txt $DEVICENAME-with.txt | + grep '>' | + cut -b 3- | + while read FULLPATH + do + if test $FILESTYLE = extract + then + echo adb pull $FULLPATH ../../../vendor/htc/\$DEVICE/proprietary/$(basename $FULLPATH) + else + echo unzip -j -o ../../../\${DEVICE}_update.zip $(echo $FULLPATH | cut -b 2-) -d ../../../vendor/htc/\$DEVICE/proprietary + fi + if test $(basename $FULLPATH) = akmd -o $(basename $FULLPATH) = mm-venc-omx-test -o $(basename $FULLPATH) = parse_radio_log + then + echo chmod 755 ../../../vendor/htc/\$DEVICE/proprietary/$(basename $FULLPATH) + fi + done + echo + + echo -n '(cat << EOF) | sed s/__DEVICE__/$DEVICE/g > ../../../vendor/htc/$DEVICE/' + if test $DEVICENAME = dream -o $DEVICENAME = sapphire + then + echo -n device_ + fi + echo '$DEVICE-vendor-blobs.mk' + + echo '# Copyright (C) 2010 The Android Open Source Project' + echo '#' + echo '# Licensed under the Apache License, Version 2.0 (the "License");' + echo '# you may not use this file except in compliance with the License.' + echo '# You may obtain a copy of the License at' + echo '#' + echo '# http://www.apache.org/licenses/LICENSE-2.0' + echo '#' + echo '# Unless required by applicable law or agreed to in writing, software' + echo '# distributed under the License is distributed on an "AS IS" BASIS,' + echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' + echo '# See the License for the specific language governing permissions and' + echo '# limitations under the License.' + echo + echo -n '# This file is generated by device/htc/__DEVICE__/' + echo -n $FILESTYLE + echo '-files.sh - DO NOT EDIT' + + FOUND=false + diff $DEVICENAME-without.txt $DEVICENAME-with.txt | + grep '>' | + cut -b 3- | + while read FULLPATH + do + if test $(basename $FULLPATH) = libgps.so -o $(basename $FULLPATH) = libcamera.so + then + if test $FOUND = false + then + echo + echo '# Prebuilt libraries that are needed to build open-source libraries' + echo 'PRODUCT_COPY_FILES := \\' + else + echo \ \\\\ + fi + FOUND=true + echo -n \ \ \ \ vendor/htc/__DEVICE__/proprietary/$(basename $FULLPATH):obj/lib/$(basename $FULLPATH) + fi + done + echo + + FOUND=false + diff $DEVICENAME-without.txt $DEVICENAME-with.txt | + grep '>' | + cut -b 3- | + while read FULLPATH + do + if test $FOUND = false + then + echo + echo -n '# All the blobs necessary for ' + echo $DEVICENAME + echo 'PRODUCT_COPY_FILES += \\' + else + echo \ \\\\ + fi + FOUND=true + echo -n \ \ \ \ vendor/htc/__DEVICE__/proprietary/$(basename $FULLPATH):$(echo $FULLPATH | cut -b 2-) + done + echo + echo 'EOF' + echo + echo './setup-makefiles.sh' + + ) > $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh + cp $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh device/htc/$DEVICENAME/$FILESTYLE-files.sh + done + + ( + cd device/htc/$DEVICENAME + git commit -a -m "auto-generated blob-handling scripts" + if test "$1" != "" -a "$2" != "" + then + echo uploading to server $1 branch $2 + git push ssh://$1:29418/device/htc/$DEVICENAME.git HEAD:refs/for/$2 + fi + ) + +done + |