-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-script
More file actions
120 lines (112 loc) · 4.22 KB
/
build-script
File metadata and controls
120 lines (112 loc) · 4.22 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
SCRIPTNAME=$(basename $BASH_SOURCE)
if [ -z $1 ]
then exit 2
fi
## import vars
source build-config.txt
## setup environment
source $HOME/.profile
cd $BUILDDIR
source build/envsetup.sh
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
export CCACHE_DIR=$CCACHEPATH
ccache -M 32G
export CCACHE_COMPRESS=1
if [ "$1" = "purge" ]
then
echo "--clean--$OUT" >> $LOGDIR/$LOG
make clobber >> $LOGDIR/$LOG 2>&1; cd $SCRIPTPATH
exit 0
fi
## sync repos
if [ -z $2 ]
then echo no repo sync, variable not set
else
if [ "$2" = "sync" ]
then
reporepeat=1
echo syncing repo
while [ 1 ]
do
repo sync -c --force-sync --no-clone-bundle --no-tags --no-repo-verify -j8
status=$?
if [ "$status" -ne "0" ] && [ "$reporepeat" -ne "3" ]
then
(( reporepeat++ ))
else
if [ "$reporepeat" = "3" ]
then
echo !!!repo sync failed!!! && break
else
echo repo synced && break
fi
fi
done
else echo no repo sync or fix typo: $2
fi
fi
## begin build process and write duration stats to logfile
echo "begining build process for $1" >> $LOGDIR/$LOG 2>&1
breakfast $1
if [ -z $3 ]
then ( time mka bacon -j$THREADS ) >> $LOGDIR/$LOG 2>&1
else mka bacon -j$THREADS
fi
## detect if zip was created, then move to HOME
if [ -e "$OUT"/lineage-*.zip ]
then
## get array from filename for version, date, device etc
cd $OUT && BUILD=`ls lineage-*.zip` && FILENAME=${BUILD,,} && cd $T
## generate recovery image name from build.zip
IFS='-' && read -a name_array <<< "$FILENAME" && unset IFS
FILENAME_IMG="${name_array[0]}-${name_array[1]}-${name_array[2]}-recovery-$1.img"
if [ -z $3 ]
then
## move zip and img
echo "moving ROM zip and RECOVERY image"
mv $OUT/lineage-*zip "$ROMDIR/$FILENAME"
if [ -f "$OUT/recovery.img" ]
then mv $OUT/recovery.img "$ROMDIR/$FILENAME_IMG"
elif [ -f "$OUT/obj/PACKAGING/target_files_intermediates/lineage_bluejay-target_files-eng.krazey/IMAGES/vendor_boot.img" ]
then mv $OUT/obj/PACKAGING/target_files_intermediates/lineage_bluejay-target_files-eng.krazey/IMAGES/vendor_boot.img "$ROMDIR/$FILENAME_IMG"
else mv $OUT/boot.img "$ROMDIR/$FILENAME_IMG"
fi
## log data
date -d ${name_array[2]} +%Y-%m-%d >> $TMPDIR/$1.txt
BUILD_DATE_UNIXTIME="$(cat $T/out/build_date.txt)"
echo $BUILD_DATE_UNIXTIME >> $TMPDIR/$1.txt
sha256sum $ROMDIR/$FILENAME | awk '{print $1}' >> $TMPDIR/$1.txt
du -b $ROMDIR/$FILENAME | awk '{print $1}' >> $TMPDIR/$1.txt
echo $FILENAME >> $TMPDIR/$1.txt
sha256sum $ROMDIR/$FILENAME_IMG | awk '{print $1}' >> $TMPDIR/$1.txt
du -b $ROMDIR/$FILENAME_IMG | awk '{print $1}' >> $TMPDIR/$1.txt
echo $FILENAME_IMG >> $TMPDIR/$1.txt
cp $TMPDIR/$1.txt $TMPDIR/re_$1.txt
ex -s +%g/^/m0 +wq $TMPDIR/re_$1.txt
## remove builds from the same day in $1.txt
BUILD_DATE="$(sed -n '8 p' $TMPDIR/re_$1.txt)"
BUILD_DATE_OLD="$(sed -n '16 p' $TMPDIR/re_$1.txt)"
if [ $BUILD_DATE = $BUILD_DATE_OLD ]
then
echo "removing builds from the same day" >> $LOGDIR/$LOG
sed "9,16d" $TMPDIR/re_$1.txt > "$TMPDIR/re_$1_temp.txt"
cp $TMPDIR/re_$1_temp.txt $TMPDIR/re_$1.txt
cp $TMPDIR/re_$1.txt $TMPDIR/$1.txt
ex -s +%g/^/m0 +wq $TMPDIR/$1.txt
fi
else
echo test-build, no logging: $TMPDIR/$1.txt
## move zip and img
echo "moving ROM zip and RECOVERY image to $TESTDIR"
mv $OUT/lineage-*zip "$TESTDIR/$FILENAME"
if [ -f "$OUT/recovery.img" ]
then mv $OUT/recovery.img "$TESTDIR/$FILENAME_IMG"
elif [ -f "$OUT/obj/PACKAGING/target_files_intermediates/lineage_bluejay-target_files-eng.krazey/IMAGES/vendor_boot.img" ]
then mv $OUT/obj/PACKAGING/target_files_intermediates/lineage_bluejay-target_files-eng.krazey/IMAGES/vendor_boot.img "$TESTDIR/$FILENAME_IMG"
else mv $OUT/boot.img "$TESTDIR/$FILENAME_IMG"
fi
fi
fi
mka installclean target-files-package otatools && cd $SCRIPTPATH