blob: 3c0b6004847adf067e7c560177d9fe74ee1836f7 [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 Dutta6ed2e1b2012-12-22 11:39:28 -080038cp $OTAPACKAGE $OUTFILE.tmp
39mv $OUTFILE.tmp $OUTFILE
Steve Kondikae76c842010-06-28 11:47:26 -040040
Chris Cosby2d0feb52010-07-16 16:28:46 -040041# Create a md5 checksum image of the repacked package
Chris Cosby972e0032010-07-16 11:13:35 -040042(
43img=`basename $OUTFILE`
44cd `dirname $OUTFILE`
45$MD5 $img >$img.md5sum
46echo
Chirayu Desai39cb8782012-10-13 16:10:45 +053047echo -e $CL_GRN"Package complete: $OUTFILE"$CL_RST
Chris Cosby972e0032010-07-16 11:13:35 -040048cat $img.md5sum
49echo
50)
Steve Kondikae76c842010-06-28 11:47:26 -040051
Chris Cosby972e0032010-07-16 11:13:35 -040052exit 0