Chirayu Desai | 39cb878 | 2012-10-13 16:10:45 +0530 | [diff] [blame] | 1 | #!/bin/bash |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 2 | # |
| 3 | # Squish a CM otapackage for distribution |
| 4 | # cyanogen |
| 5 | # |
| 6 | |
Chirayu Desai | 39cb878 | 2012-10-13 16:10:45 +0530 | [diff] [blame] | 7 | . $ANDROID_BUILD_TOP/vendor/cm/tools/functions |
| 8 | |
Chris Cosby | 2d0feb5 | 2010-07-16 16:28:46 -0400 | [diff] [blame] | 9 | OUT_TARGET_HOST=`uname -a | grep Darwin` |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 10 | if [ -z "$OUT_TARGET_HOST" ] |
| 11 | then |
| 12 | OUT_TARGET_HOST=linux-x86 |
| 13 | MD5=md5sum |
Takuo Kitame | 9db7666 | 2010-10-29 09:55:59 +0900 | [diff] [blame] | 14 | XARGS="xargs --max-args=1 --max-procs `grep 'processor' /proc/cpuinfo|wc -l`" |
| 15 | SED=sed |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 16 | else |
| 17 | OUT_TARGET_HOST=darwin-x86 |
| 18 | MD5=md5 |
Takuo Kitame | 9db7666 | 2010-10-29 09:55:59 +0900 | [diff] [blame] | 19 | XARGS="xargs -n 1 -P `sysctl hw.ncpu | awk '{print $2}'`" |
| 20 | SED=gsed |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 21 | fi |
| 22 | |
Chris Cosby | 972e003 | 2010-07-16 11:13:35 -0400 | [diff] [blame] | 23 | if [ -z "$OUT" -o ! -d "$OUT" ]; then |
Chirayu Desai | 39cb878 | 2012-10-13 16:10:45 +0530 | [diff] [blame] | 24 | echo -e $CL_RED"ERROR: $0 only works with a full build environment. $OUT should exist."$CL_RST |
Chris Cosby | 972e003 | 2010-07-16 11:13:35 -0400 | [diff] [blame] | 25 | exit 1 |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 26 | fi |
| 27 | |
Chris Cosby | 972e003 | 2010-07-16 11:13:35 -0400 | [diff] [blame] | 28 | if [ ! -f "$OTAPACKAGE" ]; then |
Chirayu Desai | 39cb878 | 2012-10-13 16:10:45 +0530 | [diff] [blame] | 29 | echo -e $CL_RED"$OTAPACKAGE doesn't exist!"$CL_RST; |
Chris Cosby | 972e003 | 2010-07-16 11:13:35 -0400 | [diff] [blame] | 30 | exit 1 |
| 31 | fi |
| 32 | |
Koushik Dutta | 6ed2e1b | 2012-12-22 11:39:28 -0800 | [diff] [blame^] | 33 | # Determine what to name the new package |
| 34 | MODVERSION=`sed -n -e'/ro\.cm\.version/s/^.*=//p' $OUT/system/build.prop` |
Chirayu Desai | 39cb878 | 2012-10-13 16:10:45 +0530 | [diff] [blame] | 35 | echo -e $CL_CYN"MODVERSION: $MODVERSION"$CL_RST |
Koushik Dutta | 6ed2e1b | 2012-12-22 11:39:28 -0800 | [diff] [blame^] | 36 | OUTFILE=$OUT/cm-$MODVERSION.zip |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 37 | |
Koushik Dutta | 6ed2e1b | 2012-12-22 11:39:28 -0800 | [diff] [blame^] | 38 | cp $OTAPACKAGE $OUTFILE.tmp |
| 39 | mv $OUTFILE.tmp $OUTFILE |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 40 | |
Chris Cosby | 2d0feb5 | 2010-07-16 16:28:46 -0400 | [diff] [blame] | 41 | # Create a md5 checksum image of the repacked package |
Chris Cosby | 972e003 | 2010-07-16 11:13:35 -0400 | [diff] [blame] | 42 | ( |
| 43 | img=`basename $OUTFILE` |
| 44 | cd `dirname $OUTFILE` |
| 45 | $MD5 $img >$img.md5sum |
| 46 | echo |
Chirayu Desai | 39cb878 | 2012-10-13 16:10:45 +0530 | [diff] [blame] | 47 | echo -e $CL_GRN"Package complete: $OUTFILE"$CL_RST |
Chris Cosby | 972e003 | 2010-07-16 11:13:35 -0400 | [diff] [blame] | 48 | cat $img.md5sum |
| 49 | echo |
| 50 | ) |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 51 | |
Chris Cosby | 972e003 | 2010-07-16 11:13:35 -0400 | [diff] [blame] | 52 | exit 0 |