-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbkp.sh
More file actions
executable file
·89 lines (70 loc) · 1.89 KB
/
bkp.sh
File metadata and controls
executable file
·89 lines (70 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
#
# Build a kernel flashable package (from CM10).
#
# STATIC COLORS
RESET=$(tput sgr0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
CYAN=$(tput setaf 6)
ROOT=`pwd`
BT_ROOT=`readlink -f buildtools`
BKP_TMP=`readlink -f $BT_ROOT/bkp-tmp`
BKP_COMMON=`readlink -f $BT_ROOT/bkp-common`
BKP_OUT=`readlink -f $BT_ROOT/out`
DEVICE=$1
if [ ! -z "$2" ]; then
BKP_ZIP=$2.zip
echo "${BLUE}Package will be named $BKP_ZIP${RESET}"
echo
fi
if [ ! -d "buildtools" ]; then
echo "buildtools must be placed inside of the CM10 root folder,"
echo "and ran from there."
echo
echo "Example: ./buildtools/bkp.sh <device> <outname>"
exit 1
fi
if [ ! -n "$DEVICE" ]; then
DEVICE=vibrantmtd
fi
BKP_DEVICE=`readlink -f $BT_ROOT/bkp-${DEVICE}`
if [ ! -e $BKP_DEVICE ]; then
echo "${RED}Device not supported!${RESET}"
exit 1
fi
BKP_ZIP_BASE=tmp_kernel_${DEVICE}_
BKP_ZIP=$BKP_ZIP_BASE`date +%Y-%m-%d`.zip
. build/envsetup.sh
breakfast ${DEVICE}
BUILD_OUT=$ANDROID_PRODUCT_OUT
echo "${CYAN}Cleaning up...${RESET}"
rm -f $BUILD_OUT/boot.img
rm -rf $BUILD_OUT/obj/KERNEL_OBJ
rm -rf $BUILD_OUT/ramdisk*
rm -f $BUILD_OUT/system/lib/modules/*
if ! mka $BUILD_OUT/boot.img; then
echo "${RED}Build failed! Please correct the errors above.${RESET}"
exit 1
fi
if [ ! -e $BUILD_OUT/boot.img ]; then
echo "${RED}Build succeeded but no build.img was produced!${RESET}"
exit 1
fi
echo "${GREEN}Build succeeded!${RESET}"
rm -rf $BKP_TMP
cp -r $BKP_COMMON $BKP_TMP
cp -r $BKP_DEVICE/* $BKP_TMP
cp $BUILD_OUT/boot.img $BKP_TMP/
if [ ! -d $BKP_TMP/system/lib/modules ]; then
mkdir -p $BKP_TMP/system/lib/modules
fi
cp $BUILD_OUT/system/lib/modules/* $BKP_TMP/system/lib/modules/
# Flush out previous zips for this device
rm -rf $BKP_OUT/$BKP_ZIP_BASE*
cd $BKP_TMP
zip -r $BKP_OUT/$BKP_ZIP .
cd $ROOT
echo "${GREEN}Target package: $BKP_ZIP${RESET}"