blob: e3b8251434539edbd3ec65d13a370d4000a596cf [file] [log] [blame]
Chirayu Desai39cb8782012-10-13 16:10:45 +05301#!/bin/bash
Steve Kondikae76c842010-06-28 11:47:26 -04002#
3# Squish a CM otapackage for distribution
4# cyanogen
5#
6
Chirayu Desai39cb8782012-10-13 16:10:45 +05307. $ANDROID_BUILD_TOP/vendor/cm/tools/functions
8
Chris Cosby2d0feb52010-07-16 16:28:46 -04009OUT_TARGET_HOST=`uname -a | grep Darwin`
Steve Kondikae76c842010-06-28 11:47:26 -040010if [ -z "$OUT_TARGET_HOST" ]
11then
12 OUT_TARGET_HOST=linux-x86
13 MD5=md5sum
Takuo Kitame9db76662010-10-29 09:55:59 +090014 XARGS="xargs --max-args=1 --max-procs `grep 'processor' /proc/cpuinfo|wc -l`"
15 SED=sed
Steve Kondikae76c842010-06-28 11:47:26 -040016else
17 OUT_TARGET_HOST=darwin-x86
18 MD5=md5
Takuo Kitame9db76662010-10-29 09:55:59 +090019 XARGS="xargs -n 1 -P `sysctl hw.ncpu | awk '{print $2}'`"
20 SED=gsed
Steve Kondikae76c842010-06-28 11:47:26 -040021fi
22
Chris Cosby972e0032010-07-16 11:13:35 -040023if [ -z "$OUT" -o ! -d "$OUT" ]; then
Chirayu Desai39cb8782012-10-13 16:10:45 +053024 echo -e $CL_RED"ERROR: $0 only works with a full build environment. $OUT should exist."$CL_RST
Chris Cosby972e0032010-07-16 11:13:35 -040025 exit 1
Steve Kondikae76c842010-06-28 11:47:26 -040026fi
27
Chris Cosby972e0032010-07-16 11:13:35 -040028if [ ! -f "$OTAPACKAGE" ]; then
Chirayu Desai39cb8782012-10-13 16:10:45 +053029 echo -e $CL_RED"$OTAPACKAGE doesn't exist!"$CL_RST;
Chris Cosby972e0032010-07-16 11:13:35 -040030 exit 1
31fi
32
Koushik Dutta6ed2e1b2012-12-22 11:39:28 -080033# Determine what to name the new package
34MODVERSION=`sed -n -e'/ro\.cm\.version/s/^.*=//p' $OUT/system/build.prop`
Chirayu Desai39cb8782012-10-13 16:10:45 +053035echo -e $CL_CYN"MODVERSION: $MODVERSION"$CL_RST
Koushik Dutta6ed2e1b2012-12-22 11:39:28 -080036OUTFILE=$OUT/cm-$MODVERSION.zip
Steve Kondikae76c842010-06-28 11:47:26 -040037
Koushik Duttabd404d22012-12-22 19:45:54 -080038ln -f $OTAPACKAGE $OUTFILE
Steve Kondikae76c842010-06-28 11:47:26 -040039
Chris Cosby2d0feb52010-07-16 16:28:46 -040040# Create a md5 checksum image of the repacked package
Chris Cosby972e0032010-07-16 11:13:35 -040041(
42img=`basename $OUTFILE`
43cd `dirname $OUTFILE`
44$MD5 $img >$img.md5sum
45echo
Chirayu Desai39cb8782012-10-13 16:10:45 +053046echo -e $CL_GRN"Package complete: $OUTFILE"$CL_RST
KhasMek901e8852012-12-12 00:53:35 +010047echo -e $CL_GRN"md5: $(cat $img.md5sum | awk '{ print $1 }')"$CL_RST
Chris Cosby972e0032010-07-16 11:13:35 -040048echo
49)
Steve Kondikae76c842010-06-28 11:47:26 -040050
Chris Cosby972e0032010-07-16 11:13:35 -040051exit 0