blob: 4df40b6bb794e43ddad11688943356a9cda898c8 [file] [log] [blame]
Jackeagled6811aa2019-09-24 08:26:40 +02001function __print_bliss_functions_help() {
Michael Bestas3952f6c2016-08-26 01:12:08 +03002cat <<EOF
Jackeagled6811aa2019-09-24 08:26:40 +02003Additional BlissRoms functions:
Michael Bestas3952f6c2016-08-26 01:12:08 +03004- cout: Changes directory to out.
5- mmp: Builds all of the modules in the current directory and pushes them to the device.
6- mmap: Builds all of the modules in the current directory and its dependencies, then pushes the package to the device.
7- mmmp: Builds all of the modules in the supplied directories and pushes them to the device.
Jackeagled6811aa2019-09-24 08:26:40 +02008- blissgerrit: A Git wrapper that fetches/pushes patch from/to BlissRoms Gerrit Review.
9- blissrebase: Rebase a Gerrit change and push it again.
10- blissremote: Add git remote for BlissRoms Gerrit Review.
Michael Bestas3952f6c2016-08-26 01:12:08 +030011- aospremote: Add git remote for matching AOSP repository.
12- cafremote: Add git remote for matching CodeAurora repository.
Jackeagled6811aa2019-09-24 08:26:40 +020013- githubremote: Add git remote for BlissRoms Github.
Michael Bestas3952f6c2016-08-26 01:12:08 +030014- mka: Builds using SCHED_BATCH on all processors.
15- mkap: Builds the module(s) using mka and pushes them to the device.
16- cmka: Cleans and builds using mka.
17- repodiff: Diff 2 different branches or tags within the same repo
18- repolastsync: Prints date and time of last repo sync.
19- reposync: Parallel repo sync using ionice and SCHED_BATCH.
20- repopick: Utility to fetch changes from Gerrit.
21- installboot: Installs a boot.img to the connected device.
22- installrecovery: Installs a recovery.img to the connected device.
Jackeagle305db7c2020-01-23 10:35:22 +010023- blissify: Sets up build environment using breakfast(),
24 and then compiles using mka() against blissify target.
Michael Bestas3952f6c2016-08-26 01:12:08 +030025EOF
26}
27
Luca Stefani076c27b2017-08-17 20:30:00 +020028function mk_timer()
29{
30 local start_time=$(date +"%s")
31 $@
32 local ret=$?
33 local end_time=$(date +"%s")
34 local tdiff=$(($end_time-$start_time))
35 local hours=$(($tdiff / 3600 ))
36 local mins=$((($tdiff % 3600) / 60))
37 local secs=$(($tdiff % 60))
38 local ncolors=$(tput colors 2>/dev/null)
39 echo
40 if [ $ret -eq 0 ] ; then
41 echo -n "#### make completed successfully "
42 else
43 echo -n "#### make failed to build some targets "
44 fi
45 if [ $hours -gt 0 ] ; then
46 printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
47 elif [ $mins -gt 0 ] ; then
48 printf "(%02g:%02g (mm:ss))" $mins $secs
49 elif [ $secs -gt 0 ] ; then
50 printf "(%s seconds)" $secs
51 fi
52 echo " ####"
53 echo
54 return $ret
55}
56
Michael Bestas3952f6c2016-08-26 01:12:08 +030057function breakfast()
58{
59 target=$1
60 local variant=$2
Michael Bestas3952f6c2016-08-26 01:12:08 +030061
62 if [ $# -eq 0 ]; then
63 # No arguments, so let's have the full menu
64 lunch
65 else
66 echo "z$target" | grep -q "-"
67 if [ $? -eq 0 ]; then
68 # A buildtype was specified, assume a full device name
69 lunch $target
70 else
Jackeagled6811aa2019-09-24 08:26:40 +020071 # This is probably just the BlissRoms model name
Michael Bestas3952f6c2016-08-26 01:12:08 +030072 if [ -z "$variant" ]; then
73 variant="userdebug"
74 fi
Matt Mowered8c2482017-01-02 02:26:01 -060075
Jackeagled6811aa2019-09-24 08:26:40 +020076 lunch bliss_$target-$variant
Michael Bestas3952f6c2016-08-26 01:12:08 +030077 fi
78 fi
79 return $?
80}
81
82alias bib=breakfast
83
84function eat()
85{
86 if [ "$OUT" ] ; then
Jackeagled6811aa2019-09-24 08:26:40 +020087 ZIPPATH=`ls -tr "$OUT"/Bliss-*.zip | tail -1`
Michael Bestas3952f6c2016-08-26 01:12:08 +030088 if [ ! -f $ZIPPATH ] ; then
89 echo "Nothing to eat"
90 return 1
91 fi
Alessandro Astonecdf9ae82019-09-28 16:53:08 +020092 echo "Waiting for device..."
Luca Stefani3d548072020-03-11 12:24:26 +010093 adb wait-for-device-recovery
Alessandro Astonecdf9ae82019-09-28 16:53:08 +020094 echo "Found device"
Jackeagled6811aa2019-09-24 08:26:40 +020095 if (adb shell getprop ro.bliss.device | grep -q "$BLISS_BUILD"); then
Alessandro Astonecdf9ae82019-09-28 16:53:08 +020096 echo "Rebooting to sideload for install"
97 adb reboot sideload-auto-reboot
98 adb wait-for-sideload
99 adb sideload $ZIPPATH
Ethan Chenb69c2ff2016-12-31 13:23:56 -0800100 else
Jackeagled6811aa2019-09-24 08:26:40 +0200101 echo "The connected device does not appear to be $BLISS_BUILD, run away!"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300102 fi
Ethan Chenb69c2ff2016-12-31 13:23:56 -0800103 return $?
Michael Bestas3952f6c2016-08-26 01:12:08 +0300104 else
105 echo "Nothing to eat"
106 return 1
107 fi
Michael Bestas3952f6c2016-08-26 01:12:08 +0300108}
109
110function omnom()
111{
Jackeagle305db7c2020-01-23 10:35:22 +0100112 blissify $*
Michael Bestas3952f6c2016-08-26 01:12:08 +0300113 eat
114}
115
116function cout()
117{
118 if [ "$OUT" ]; then
119 cd $OUT
120 else
121 echo "Couldn't locate out directory. Try setting OUT."
122 fi
123}
124
125function dddclient()
126{
127 local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT)
128 local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED)
129 local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)
130 local OUT_VENDOR_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_VENDOR_SHARED_LIBRARIES_UNSTRIPPED)
131 local OUT_EXE_SYMBOLS=$(get_symbols_directory)
132 local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS)
133 local ARCH=$(get_build_var TARGET_ARCH)
134 local GDB
135 case "$ARCH" in
136 arm) GDB=arm-linux-androideabi-gdb;;
137 arm64) GDB=arm-linux-androideabi-gdb; GDB64=aarch64-linux-android-gdb;;
138 mips|mips64) GDB=mips64el-linux-android-gdb;;
139 x86) GDB=x86_64-linux-android-gdb;;
140 x86_64) GDB=x86_64-linux-android-gdb;;
141 *) echo "Unknown arch $ARCH"; return 1;;
142 esac
143
144 if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then
145 local EXE="$1"
146 if [ "$EXE" ] ; then
147 EXE=$1
148 if [[ $EXE =~ ^[^/].* ]] ; then
149 EXE="system/bin/"$EXE
150 fi
151 else
152 EXE="app_process"
153 fi
154
155 local PORT="$2"
156 if [ "$PORT" ] ; then
157 PORT=$2
158 else
159 PORT=":5039"
160 fi
161
162 local PID="$3"
163 if [ "$PID" ] ; then
164 if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
165 PID=`pid $3`
166 if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
167 # that likely didn't work because of returning multiple processes
168 # try again, filtering by root processes (don't contain colon)
169 PID=`adb shell ps | \grep $3 | \grep -v ":" | awk '{print $2}'`
170 if [[ ! "$PID" =~ ^[0-9]+$ ]]
171 then
172 echo "Couldn't resolve '$3' to single PID"
173 return 1
174 else
175 echo ""
176 echo "WARNING: multiple processes matching '$3' observed, using root process"
177 echo ""
178 fi
179 fi
180 fi
181 adb forward "tcp$PORT" "tcp$PORT"
182 local USE64BIT="$(is64bit $PID)"
183 adb shell gdbserver$USE64BIT $PORT --attach $PID &
184 sleep 2
185 else
186 echo ""
187 echo "If you haven't done so already, do this first on the device:"
188 echo " gdbserver $PORT /system/bin/$EXE"
189 echo " or"
190 echo " gdbserver $PORT --attach <PID>"
191 echo ""
192 fi
193
194 OUT_SO_SYMBOLS=$OUT_SO_SYMBOLS$USE64BIT
195 OUT_VENDOR_SO_SYMBOLS=$OUT_VENDOR_SO_SYMBOLS$USE64BIT
196
197 echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS"
198 echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS:$OUT_SO_SYMBOLS/hw:$OUT_SO_SYMBOLS/ssl/engines:$OUT_SO_SYMBOLS/drm:$OUT_SO_SYMBOLS/egl:$OUT_SO_SYMBOLS/soundfx:$OUT_VENDOR_SO_SYMBOLS:$OUT_VENDOR_SO_SYMBOLS/hw:$OUT_VENDOR_SO_SYMBOLS/egl"
199 echo >>"$OUT_ROOT/gdbclient.cmds" "source $ANDROID_BUILD_TOP/development/scripts/gdb/dalvik.gdb"
200 echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT"
201 # Enable special debugging for ART processes.
202 if [[ $EXE =~ (^|/)(app_process|dalvikvm)(|32|64)$ ]]; then
203 echo >> "$OUT_ROOT/gdbclient.cmds" "art-on"
204 fi
205 echo >>"$OUT_ROOT/gdbclient.cmds" ""
206
207 local WHICH_GDB=
208 # 64-bit exe found
209 if [ "$USE64BIT" != "" ] ; then
210 WHICH_GDB=$ANDROID_TOOLCHAIN/$GDB64
211 # 32-bit exe / 32-bit platform
212 elif [ "$(get_build_var TARGET_2ND_ARCH)" = "" ]; then
213 WHICH_GDB=$ANDROID_TOOLCHAIN/$GDB
214 # 32-bit exe / 64-bit platform
215 else
216 WHICH_GDB=$ANDROID_TOOLCHAIN_2ND_ARCH/$GDB
217 fi
218
219 ddd --debugger $WHICH_GDB -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
220 else
221 echo "Unable to determine build system output dir."
222 fi
223}
224
Jackeagled6811aa2019-09-24 08:26:40 +0200225function blissremote()
Michael Bestas3952f6c2016-08-26 01:12:08 +0300226{
227 if ! git rev-parse --git-dir &> /dev/null
228 then
229 echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
230 return 1
231 fi
Jackeagled6811aa2019-09-24 08:26:40 +0200232 git remote rm bliss 2> /dev/null
Michael Bestas9e6bde52018-04-02 19:54:45 +0300233 local REMOTE=$(git config --get remote.github.projectname)
Jackeagle305db7c2020-01-23 10:35:22 +0100234 local BLISS="true"
Michael Bestas9e6bde52018-04-02 19:54:45 +0300235 if [ -z "$REMOTE" ]
Michael Bestasaf3532b2017-08-23 17:40:40 +0300236 then
Michael Bestas9e6bde52018-04-02 19:54:45 +0300237 REMOTE=$(git config --get remote.aosp.projectname)
Jackeagle305db7c2020-01-23 10:35:22 +0100238 BLISS="false"
Michael Bestasaf3532b2017-08-23 17:40:40 +0300239 fi
Michael Bestas9e6bde52018-04-02 19:54:45 +0300240 if [ -z "$REMOTE" ]
241 then
242 REMOTE=$(git config --get remote.caf.projectname)
Jackeagle305db7c2020-01-23 10:35:22 +0100243 BLISS="false"
Michael Bestas9e6bde52018-04-02 19:54:45 +0300244 fi
245
Jackeagle305db7c2020-01-23 10:35:22 +0100246 if [ $BLISS = "false" ]
Michael Bestas9e6bde52018-04-02 19:54:45 +0300247 then
248 local PROJECT=$(echo $REMOTE | sed -e "s#platform/#android/#g; s#/#_#g")
Jackeagle305db7c2020-01-23 10:35:22 +0100249 local PFX="BLISS/"
Michael Bestas9e6bde52018-04-02 19:54:45 +0300250 else
251 local PROJECT=$REMOTE
252 fi
253
Jackeagle305db7c2020-01-23 10:35:22 +0100254 local BLISS_USER=$(git config --get review.review.blissroms.com.username)
255 if [ -z "$BLISS_USER" ]
Michael Bestas3952f6c2016-08-26 01:12:08 +0300256 then
Jackeagled6811aa2019-09-24 08:26:40 +0200257 git remote add bliss ssh://review.blissroms.com:29418/$PFX$PROJECT
Michael Bestas3952f6c2016-08-26 01:12:08 +0300258 else
Jackeagle305db7c2020-01-23 10:35:22 +0100259 git remote add bliss ssh://$BLISS_USER@review.blissroms.com:29418/$PFX$PROJECT
Michael Bestas3952f6c2016-08-26 01:12:08 +0300260 fi
Jackeagled6811aa2019-09-24 08:26:40 +0200261 echo "Remote 'bliss' created"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300262}
263
264function aospremote()
265{
266 if ! git rev-parse --git-dir &> /dev/null
267 then
268 echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
269 return 1
270 fi
271 git remote rm aosp 2> /dev/null
Michael Bestasad3a5702017-08-24 00:00:48 +0300272 local PROJECT=$(pwd -P | sed -e "s#$ANDROID_BUILD_TOP\/##; s#-caf.*##; s#\/default##")
Rashed Abdel-Tawabfd8b8292017-10-24 21:55:52 -0400273 # Google moved the repo location in Oreo
274 if [ $PROJECT = "build/make" ]
275 then
276 PROJECT="build"
277 fi
Michael Bestas3952f6c2016-08-26 01:12:08 +0300278 if (echo $PROJECT | grep -qv "^device")
279 then
Michael Bestasad3a5702017-08-24 00:00:48 +0300280 local PFX="platform/"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300281 fi
282 git remote add aosp https://android.googlesource.com/$PFX$PROJECT
283 echo "Remote 'aosp' created"
284}
285
286function cafremote()
287{
288 if ! git rev-parse --git-dir &> /dev/null
289 then
290 echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
291 return 1
292 fi
293 git remote rm caf 2> /dev/null
Michael Bestasad3a5702017-08-24 00:00:48 +0300294 local PROJECT=$(pwd -P | sed -e "s#$ANDROID_BUILD_TOP\/##; s#-caf.*##; s#\/default##")
Rashed Abdel-Tawabfd8b8292017-10-24 21:55:52 -0400295 # Google moved the repo location in Oreo
296 if [ $PROJECT = "build/make" ]
297 then
298 PROJECT="build"
299 fi
Rashed Abdel-Tawabb52c7082017-12-24 22:40:31 +0200300 if [[ $PROJECT =~ "qcom/opensource" ]];
301 then
302 PROJECT=$(echo $PROJECT | sed -e "s#qcom\/opensource#qcom-opensource#")
303 fi
Michael Bestas3952f6c2016-08-26 01:12:08 +0300304 if (echo $PROJECT | grep -qv "^device")
305 then
Michael Bestasad3a5702017-08-24 00:00:48 +0300306 local PFX="platform/"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300307 fi
Zhao Wei Liewfb4b8c52017-01-08 09:03:01 +0800308 git remote add caf https://source.codeaurora.org/quic/la/$PFX$PROJECT
Michael Bestas3952f6c2016-08-26 01:12:08 +0300309 echo "Remote 'caf' created"
310}
311
Michael Bestasa504aa42018-08-10 22:51:37 +0300312function githubremote()
313{
314 if ! git rev-parse --git-dir &> /dev/null
315 then
316 echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
317 return 1
318 fi
319 git remote rm github 2> /dev/null
320 local REMOTE=$(git config --get remote.aosp.projectname)
321
322 if [ -z "$REMOTE" ]
323 then
324 REMOTE=$(git config --get remote.caf.projectname)
325 fi
326
327 local PROJECT=$(echo $REMOTE | sed -e "s#platform/#android/#g; s#/#_#g")
328
329 git remote add github https://github.com/LineageOS/$PROJECT
330 echo "Remote 'github' created"
331}
332
Michael Bestas3952f6c2016-08-26 01:12:08 +0300333function installboot()
334{
Alessandro Astonef8f48772019-09-06 13:07:03 +0200335 if [ ! -e "$OUT/recovery/root/system/etc/recovery.fstab" ];
Michael Bestas3952f6c2016-08-26 01:12:08 +0300336 then
337 echo "No recovery.fstab found. Build recovery first."
338 return 1
339 fi
340 if [ ! -e "$OUT/boot.img" ];
341 then
342 echo "No boot.img found. Run make bootimage first."
343 return 1
344 fi
Alessandro Astonef8f48772019-09-06 13:07:03 +0200345 PARTITION=`grep "^\/boot" $OUT/recovery/root/system/etc/recovery.fstab | awk {'print $3'}`
Michael Bestas3952f6c2016-08-26 01:12:08 +0300346 if [ -z "$PARTITION" ];
347 then
348 # Try for RECOVERY_FSTAB_VERSION = 2
Alessandro Astonef8f48772019-09-06 13:07:03 +0200349 PARTITION=`grep "[[:space:]]\/boot[[:space:]]" $OUT/recovery/root/system/etc/recovery.fstab | awk {'print $1'}`
350 PARTITION_TYPE=`grep "[[:space:]]\/boot[[:space:]]" $OUT/recovery/root/system/etc/recovery.fstab | awk {'print $3'}`
Michael Bestas3952f6c2016-08-26 01:12:08 +0300351 if [ -z "$PARTITION" ];
352 then
353 echo "Unable to determine boot partition."
354 return 1
355 fi
356 fi
Luca Stefani3d548072020-03-11 12:24:26 +0100357 adb wait-for-device-recovery
Michael Bestas3952f6c2016-08-26 01:12:08 +0300358 adb root
Luca Stefani3d548072020-03-11 12:24:26 +0100359 adb wait-for-device-recovery
Jackeagled6811aa2019-09-24 08:26:40 +0200360 if (adb shell getprop ro.bliss.device | grep -q "$BLISS_BUILD");
Michael Bestas3952f6c2016-08-26 01:12:08 +0300361 then
362 adb push $OUT/boot.img /cache/
Michael Bestas3952f6c2016-08-26 01:12:08 +0300363 adb shell dd if=/cache/boot.img of=$PARTITION
Michael W2e203942018-01-14 18:46:02 +0100364 adb shell rm -rf /cache/boot.img
Michael Bestas3952f6c2016-08-26 01:12:08 +0300365 echo "Installation complete."
366 else
Jackeagled6811aa2019-09-24 08:26:40 +0200367 echo "The connected device does not appear to be $BLISS_BUILD, run away!"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300368 fi
369}
370
371function installrecovery()
372{
Alessandro Astonef8f48772019-09-06 13:07:03 +0200373 if [ ! -e "$OUT/recovery/root/system/etc/recovery.fstab" ];
Michael Bestas3952f6c2016-08-26 01:12:08 +0300374 then
375 echo "No recovery.fstab found. Build recovery first."
376 return 1
377 fi
378 if [ ! -e "$OUT/recovery.img" ];
379 then
380 echo "No recovery.img found. Run make recoveryimage first."
381 return 1
382 fi
Alessandro Astonef8f48772019-09-06 13:07:03 +0200383 PARTITION=`grep "^\/recovery" $OUT/recovery/root/system/etc/recovery.fstab | awk {'print $3'}`
Michael Bestas3952f6c2016-08-26 01:12:08 +0300384 if [ -z "$PARTITION" ];
385 then
386 # Try for RECOVERY_FSTAB_VERSION = 2
Alessandro Astonef8f48772019-09-06 13:07:03 +0200387 PARTITION=`grep "[[:space:]]\/recovery[[:space:]]" $OUT/recovery/root/system/etc/recovery.fstab | awk {'print $1'}`
388 PARTITION_TYPE=`grep "[[:space:]]\/recovery[[:space:]]" $OUT/recovery/root/system/etc/recovery.fstab | awk {'print $3'}`
Michael Bestas3952f6c2016-08-26 01:12:08 +0300389 if [ -z "$PARTITION" ];
390 then
391 echo "Unable to determine recovery partition."
392 return 1
393 fi
394 fi
Luca Stefani3d548072020-03-11 12:24:26 +0100395 adb wait-for-device-recovery
Michael Bestas3952f6c2016-08-26 01:12:08 +0300396 adb root
Luca Stefani3d548072020-03-11 12:24:26 +0100397 adb wait-for-device-recovery
Jackeagled6811aa2019-09-24 08:26:40 +0200398 if (adb shell getprop ro.bliss.device | grep -q "$BLISS_BUILD");
Michael Bestas3952f6c2016-08-26 01:12:08 +0300399 then
400 adb push $OUT/recovery.img /cache/
401 adb shell dd if=/cache/recovery.img of=$PARTITION
Michael W2e203942018-01-14 18:46:02 +0100402 adb shell rm -rf /cache/recovery.img
Michael Bestas3952f6c2016-08-26 01:12:08 +0300403 echo "Installation complete."
404 else
Jackeagled6811aa2019-09-24 08:26:40 +0200405 echo "The connected device does not appear to be $BLISS_BUILD, run away!"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300406 fi
407}
408
409function makerecipe() {
410 if [ -z "$1" ]
411 then
412 echo "No branch name provided."
413 return 1
414 fi
415 cd android
416 sed -i s/'default revision=.*'/'default revision="refs\/heads\/'$1'"'/ default.xml
417 git commit -a -m "$1"
418 cd ..
419
420 repo forall -c '
421
422 if [ "$REPO_REMOTE" = "github" ]
423 then
424 pwd
Jackeagled6811aa2019-09-24 08:26:40 +0200425 blissremote
426 git push bliss HEAD:refs/heads/'$1'
Michael Bestas3952f6c2016-08-26 01:12:08 +0300427 fi
428 '
429}
430
Jackeagled6811aa2019-09-24 08:26:40 +0200431function blissgerrit() {
Michael Bestas3952f6c2016-08-26 01:12:08 +0300432 if [ "$(__detect_shell)" = "zsh" ]; then
433 # zsh does not define FUNCNAME, derive from funcstack
434 local FUNCNAME=$funcstack[1]
435 fi
436
437 if [ $# -eq 0 ]; then
438 $FUNCNAME help
439 return 1
440 fi
Jackeagled6811aa2019-09-24 08:26:40 +0200441 local user=`git config --get review.review.blissroms.com.username`
Michael Bestas3952f6c2016-08-26 01:12:08 +0300442 local review=`git config --get remote.github.review`
443 local project=`git config --get remote.github.projectname`
444 local command=$1
445 shift
446 case $command in
447 help)
448 if [ $# -eq 0 ]; then
449 cat <<EOF
450Usage:
451 $FUNCNAME COMMAND [OPTIONS] [CHANGE-ID[/PATCH-SET]][{@|^|~|:}ARG] [-- ARGS]
452
453Commands:
454 fetch Just fetch the change as FETCH_HEAD
455 help Show this help, or for a specific command
456 pull Pull a change into current branch
457 push Push HEAD or a local branch to Gerrit for a specific branch
458
459Any other Git commands that support refname would work as:
460 git fetch URL CHANGE && git COMMAND OPTIONS FETCH_HEAD{@|^|~|:}ARG -- ARGS
461
462See '$FUNCNAME help COMMAND' for more information on a specific command.
463
464Example:
465 $FUNCNAME checkout -b topic 1234/5
466works as:
467 git fetch http://DOMAIN/p/PROJECT refs/changes/34/1234/5 \\
468 && git checkout -b topic FETCH_HEAD
469will checkout a new branch 'topic' base on patch-set 5 of change 1234.
470Patch-set 1 will be fetched if omitted.
471EOF
472 return
473 fi
474 case $1 in
475 __cmg_*) echo "For internal use only." ;;
476 changes|for)
Jackeagled6811aa2019-09-24 08:26:40 +0200477 if [ "$FUNCNAME" = "blissgerrit" ]; then
Michael Bestas3952f6c2016-08-26 01:12:08 +0300478 echo "'$FUNCNAME $1' is deprecated."
479 fi
480 ;;
481 help) $FUNCNAME help ;;
482 fetch|pull) cat <<EOF
483usage: $FUNCNAME $1 [OPTIONS] CHANGE-ID[/PATCH-SET]
484
485works as:
486 git $1 OPTIONS http://DOMAIN/p/PROJECT \\
487 refs/changes/HASH/CHANGE-ID/{PATCH-SET|1}
488
489Example:
490 $FUNCNAME $1 1234
491will $1 patch-set 1 of change 1234
492EOF
493 ;;
494 push) cat <<EOF
495usage: $FUNCNAME push [OPTIONS] [LOCAL_BRANCH:]REMOTE_BRANCH
496
497works as:
498 git push OPTIONS ssh://USER@DOMAIN:29418/PROJECT \\
499 {LOCAL_BRANCH|HEAD}:refs/for/REMOTE_BRANCH
500
501Example:
502 $FUNCNAME push fix6789:gingerbread
503will push local branch 'fix6789' to Gerrit for branch 'gingerbread'.
504HEAD will be pushed from local if omitted.
505EOF
506 ;;
507 *)
508 $FUNCNAME __cmg_err_not_supported $1 && return
509 cat <<EOF
510usage: $FUNCNAME $1 [OPTIONS] CHANGE-ID[/PATCH-SET][{@|^|~|:}ARG] [-- ARGS]
511
512works as:
513 git fetch http://DOMAIN/p/PROJECT \\
514 refs/changes/HASH/CHANGE-ID/{PATCH-SET|1} \\
515 && git $1 OPTIONS FETCH_HEAD{@|^|~|:}ARG -- ARGS
516EOF
517 ;;
518 esac
519 ;;
520 __cmg_get_ref)
521 $FUNCNAME __cmg_err_no_arg $command $# && return 1
522 local change_id patchset_id hash
523 case $1 in
524 */*)
525 change_id=${1%%/*}
526 patchset_id=${1#*/}
527 ;;
528 *)
529 change_id=$1
530 patchset_id=1
531 ;;
532 esac
533 hash=$(($change_id % 100))
534 case $hash in
535 [0-9]) hash="0$hash" ;;
536 esac
537 echo "refs/changes/$hash/$change_id/$patchset_id"
538 ;;
539 fetch|pull)
540 $FUNCNAME __cmg_err_no_arg $command $# help && return 1
541 $FUNCNAME __cmg_err_not_repo && return 1
542 local change=$1
543 shift
544 git $command $@ http://$review/p/$project \
545 $($FUNCNAME __cmg_get_ref $change) || return 1
546 ;;
547 push)
548 $FUNCNAME __cmg_err_no_arg $command $# help && return 1
549 $FUNCNAME __cmg_err_not_repo && return 1
550 if [ -z "$user" ]; then
551 echo >&2 "Gerrit username not found."
552 return 1
553 fi
554 local local_branch remote_branch
555 case $1 in
556 *:*)
557 local_branch=${1%:*}
558 remote_branch=${1##*:}
559 ;;
560 *)
561 local_branch=HEAD
562 remote_branch=$1
563 ;;
564 esac
565 shift
566 git push $@ ssh://$user@$review:29418/$project \
567 $local_branch:refs/for/$remote_branch || return 1
568 ;;
569 changes|for)
Jackeagled6811aa2019-09-24 08:26:40 +0200570 if [ "$FUNCNAME" = "blissgerrit" ]; then
Michael Bestas3952f6c2016-08-26 01:12:08 +0300571 echo >&2 "'$FUNCNAME $command' is deprecated."
572 fi
573 ;;
574 __cmg_err_no_arg)
575 if [ $# -lt 2 ]; then
576 echo >&2 "'$FUNCNAME $command' missing argument."
577 elif [ $2 -eq 0 ]; then
578 if [ -n "$3" ]; then
579 $FUNCNAME help $1
580 else
581 echo >&2 "'$FUNCNAME $1' missing argument."
582 fi
583 else
584 return 1
585 fi
586 ;;
587 __cmg_err_not_repo)
588 if [ -z "$review" -o -z "$project" ]; then
589 echo >&2 "Not currently in any reviewable repository."
590 else
591 return 1
592 fi
593 ;;
594 __cmg_err_not_supported)
595 $FUNCNAME __cmg_err_no_arg $command $# && return
596 case $1 in
597 #TODO: filter more git commands that don't use refname
598 init|add|rm|mv|status|clone|remote|bisect|config|stash)
599 echo >&2 "'$FUNCNAME $1' is not supported."
600 ;;
601 *) return 1 ;;
602 esac
603 ;;
604 #TODO: other special cases?
605 *)
606 $FUNCNAME __cmg_err_not_supported $command && return 1
607 $FUNCNAME __cmg_err_no_arg $command $# help && return 1
608 $FUNCNAME __cmg_err_not_repo && return 1
609 local args="$@"
610 local change pre_args refs_arg post_args
611 case "$args" in
612 *--\ *)
613 pre_args=${args%%-- *}
614 post_args="-- ${args#*-- }"
615 ;;
616 *) pre_args="$args" ;;
617 esac
618 args=($pre_args)
619 pre_args=
620 if [ ${#args[@]} -gt 0 ]; then
621 change=${args[${#args[@]}-1]}
622 fi
623 if [ ${#args[@]} -gt 1 ]; then
624 pre_args=${args[0]}
625 for ((i=1; i<${#args[@]}-1; i++)); do
626 pre_args="$pre_args ${args[$i]}"
627 done
628 fi
629 while ((1)); do
630 case $change in
631 ""|--)
632 $FUNCNAME help $command
633 return 1
634 ;;
635 *@*)
636 if [ -z "$refs_arg" ]; then
637 refs_arg="@${change#*@}"
638 change=${change%%@*}
639 fi
640 ;;
641 *~*)
642 if [ -z "$refs_arg" ]; then
643 refs_arg="~${change#*~}"
644 change=${change%%~*}
645 fi
646 ;;
647 *^*)
648 if [ -z "$refs_arg" ]; then
649 refs_arg="^${change#*^}"
650 change=${change%%^*}
651 fi
652 ;;
653 *:*)
654 if [ -z "$refs_arg" ]; then
655 refs_arg=":${change#*:}"
656 change=${change%%:*}
657 fi
658 ;;
659 *) break ;;
660 esac
661 done
662 $FUNCNAME fetch $change \
663 && git $command $pre_args FETCH_HEAD$refs_arg $post_args \
664 || return 1
665 ;;
666 esac
667}
668
Jackeagled6811aa2019-09-24 08:26:40 +0200669function blissrebase() {
Michael Bestas3952f6c2016-08-26 01:12:08 +0300670 local repo=$1
671 local refs=$2
672 local pwd="$(pwd)"
673 local dir="$(gettop)/$repo"
674
675 if [ -z $repo ] || [ -z $refs ]; then
Dan Pasanen03447712016-12-19 11:22:55 -0600676 echo "LineageOS Gerrit Rebase Usage: "
Jackeagled6811aa2019-09-24 08:26:40 +0200677 echo " blissrebase <path to project> <patch IDs on Gerrit>"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300678 echo " The patch IDs appear on the Gerrit commands that are offered."
679 echo " They consist on a series of numbers and slashes, after the text"
680 echo " refs/changes. For example, the ID in the following command is 26/8126/2"
681 echo ""
682 echo " git[...]ges_apps_Camera refs/changes/26/8126/2 && git cherry-pick FETCH_HEAD"
683 echo ""
684 return
685 fi
686
687 if [ ! -d $dir ]; then
688 echo "Directory $dir doesn't exist in tree."
689 return
690 fi
691 cd $dir
692 repo=$(cat .git/config | grep git://github.com | awk '{ print $NF }' | sed s#git://github.com/##g)
693 echo "Starting branch..."
694 repo start tmprebase .
695 echo "Bringing it up to date..."
696 repo sync .
697 echo "Fetching change..."
Jackeagled6811aa2019-09-24 08:26:40 +0200698 git fetch "https://review.blissroms.com/p/$repo" "refs/changes/$refs" && git cherry-pick FETCH_HEAD
Michael Bestas3952f6c2016-08-26 01:12:08 +0300699 if [ "$?" != "0" ]; then
700 echo "Error cherry-picking. Not uploading!"
701 return
702 fi
703 echo "Uploading..."
704 repo upload .
705 echo "Cleaning up..."
706 repo abandon tmprebase .
707 cd $pwd
708}
709
710function mka() {
Luca Stefani085af722017-08-17 20:34:44 +0200711 m -j "$@"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300712}
713
714function cmka() {
715 if [ ! -z "$1" ]; then
716 for i in "$@"; do
717 case $i in
718 bacon|otapackage|systemimage)
719 mka installclean
720 mka $i
721 ;;
722 *)
723 mka clean-$i
724 mka $i
725 ;;
726 esac
727 done
728 else
729 mka clean
730 mka
731 fi
732}
733
Michael Bestas3952f6c2016-08-26 01:12:08 +0300734function repolastsync() {
735 RLSPATH="$ANDROID_BUILD_TOP/.repo/.repo_fetchtimes.json"
736 RLSLOCAL=$(date -d "$(stat -c %z $RLSPATH)" +"%e %b %Y, %T %Z")
737 RLSUTC=$(date -d "$(stat -c %z $RLSPATH)" -u +"%e %b %Y, %T %Z")
738 echo "Last repo sync: $RLSLOCAL / $RLSUTC"
739}
740
741function reposync() {
Luca Stefani085af722017-08-17 20:34:44 +0200742 repo sync -j 4 "$@"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300743}
744
745function repodiff() {
746 if [ -z "$*" ]; then
747 echo "Usage: repodiff <ref-from> [[ref-to] [--numstat]]"
748 return
749 fi
750 diffopts=$* repo forall -c \
751 'echo "$REPO_PATH ($REPO_REMOTE)"; git diff ${diffopts} 2>/dev/null ;'
752}
753
754# Return success if adb is up and not in recovery
755function _adb_connected {
756 {
Alessandro Astonecdf9ae82019-09-28 16:53:08 +0200757 if [[ "$(adb get-state)" == device ]]
Michael Bestas3952f6c2016-08-26 01:12:08 +0300758 then
759 return 0
760 fi
761 } 2>/dev/null
762
763 return 1
764};
765
766# Credit for color strip sed: http://goo.gl/BoIcm
767function dopush()
768{
769 local func=$1
770 shift
771
772 adb start-server # Prevent unexpected starting server message from adb get-state in the next line
773 if ! _adb_connected; then
774 echo "No device is online. Waiting for one..."
775 echo "Please connect USB and/or enable USB debugging"
776 until _adb_connected; do
777 sleep 1
778 done
779 echo "Device Found."
780 fi
781
Jackeagled6811aa2019-09-24 08:26:40 +0200782 if (adb shell getprop ro.bliss.device | grep -q "$BLISS_BUILD") || [ "$FORCE_PUSH" = "true" ];
Michael Bestas3952f6c2016-08-26 01:12:08 +0300783 then
784 # retrieve IP and PORT info if we're using a TCP connection
Marc K2be9cac2016-10-20 10:27:35 +0200785 TCPIPPORT=$(adb devices \
786 | egrep '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]):[0-9]+[^0-9]+' \
Michael Bestas3952f6c2016-08-26 01:12:08 +0300787 | head -1 | awk '{print $1}')
788 adb root &> /dev/null
789 sleep 0.3
790 if [ -n "$TCPIPPORT" ]
791 then
792 # adb root just killed our connection
793 # so reconnect...
794 adb connect "$TCPIPPORT"
795 fi
796 adb wait-for-device &> /dev/null
Michael Bestas3952f6c2016-08-26 01:12:08 +0300797 adb remount &> /dev/null
798
799 mkdir -p $OUT
800 ($func $*|tee $OUT/.log;return ${PIPESTATUS[0]})
801 ret=$?;
802 if [ $ret -ne 0 ]; then
803 rm -f $OUT/.log;return $ret
804 fi
805
Rashed Abdel-Tawab01806642017-01-19 15:52:13 -0500806 is_gnu_sed=`sed --version | head -1 | grep -c GNU`
807
Michael Bestas3952f6c2016-08-26 01:12:08 +0300808 # Install: <file>
Rashed Abdel-Tawab01806642017-01-19 15:52:13 -0500809 if [ $is_gnu_sed -gt 0 ]; then
Marc K97b035d2016-10-20 10:27:44 +0200810 LOC="$(cat $OUT/.log | sed -r -e 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' -e 's/^\[ {0,2}[0-9]{1,3}% [0-9]{1,6}\/[0-9]{1,6}\] +//' \
811 | grep '^Install: ' | cut -d ':' -f 2)"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300812 else
Marc K97b035d2016-10-20 10:27:44 +0200813 LOC="$(cat $OUT/.log | sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" -E "s/^\[ {0,2}[0-9]{1,3}% [0-9]{1,6}\/[0-9]{1,6}\] +//" \
814 | grep '^Install: ' | cut -d ':' -f 2)"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300815 fi
816
817 # Copy: <file>
Rashed Abdel-Tawab01806642017-01-19 15:52:13 -0500818 if [ $is_gnu_sed -gt 0 ]; then
Marc K97b035d2016-10-20 10:27:44 +0200819 LOC="$LOC $(cat $OUT/.log | sed -r -e 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' -e 's/^\[ {0,2}[0-9]{1,3}% [0-9]{1,6}\/[0-9]{1,6}\] +//' \
820 | grep '^Copy: ' | cut -d ':' -f 2)"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300821 else
Marc K97b035d2016-10-20 10:27:44 +0200822 LOC="$LOC $(cat $OUT/.log | sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" -E 's/^\[ {0,2}[0-9]{1,3}% [0-9]{1,6}\/[0-9]{1,6}\] +//' \
823 | grep '^Copy: ' | cut -d ':' -f 2)"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300824 fi
825
826 # If any files are going to /data, push an octal file permissions reader to device
827 if [ -n "$(echo $LOC | egrep '(^|\s)/data')" ]; then
828 CHKPERM="/data/local/tmp/chkfileperm.sh"
829(
830cat <<'EOF'
831#!/system/xbin/sh
832FILE=$@
833if [ -e $FILE ]; then
834 ls -l $FILE | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o ",k);print}' | cut -d ' ' -f1
835fi
836EOF
837) > $OUT/.chkfileperm.sh
838 echo "Pushing file permissions checker to device"
839 adb push $OUT/.chkfileperm.sh $CHKPERM
840 adb shell chmod 755 $CHKPERM
841 rm -f $OUT/.chkfileperm.sh
842 fi
843
Sam Mortimerc3865952019-10-12 02:14:13 -0700844 RELOUT=$(echo $OUT | sed "s#^${ANDROID_BUILD_TOP}/##")
845
Michael Bestas3952f6c2016-08-26 01:12:08 +0300846 stop_n_start=false
Sam Mortimerc3865952019-10-12 02:14:13 -0700847 for TARGET in $(echo $LOC | tr " " "\n" | sed "s#.*${RELOUT}##" | sort | uniq); do
Roman Birgd51094c2018-03-28 09:47:30 -0700848 # Make sure file is in $OUT/system, $OUT/data, $OUT/odm, $OUT/oem, $OUT/product, $OUT/product_services or $OUT/vendor
Adrian DCa8e06d32018-06-17 00:15:00 +0200849 case $TARGET in
Roman Birgd51094c2018-03-28 09:47:30 -0700850 /system/*|/data/*|/odm/*|/oem/*|/product/*|/product_services/*|/vendor/*)
Adrian DCa8e06d32018-06-17 00:15:00 +0200851 # Get out file from target (i.e. /system/bin/adb)
852 FILE=$OUT$TARGET
Michael Bestas3952f6c2016-08-26 01:12:08 +0300853 ;;
854 *) continue ;;
855 esac
856
857 case $TARGET in
858 /data/*)
859 # fs_config only sets permissions and se labels for files pushed to /system
860 if [ -n "$CHKPERM" ]; then
861 OLDPERM=$(adb shell $CHKPERM $TARGET)
862 OLDPERM=$(echo $OLDPERM | tr -d '\r' | tr -d '\n')
863 OLDOWN=$(adb shell ls -al $TARGET | awk '{print $2}')
864 OLDGRP=$(adb shell ls -al $TARGET | awk '{print $3}')
865 fi
866 echo "Pushing: $TARGET"
867 adb push $FILE $TARGET
868 if [ -n "$OLDPERM" ]; then
869 echo "Setting file permissions: $OLDPERM, $OLDOWN":"$OLDGRP"
870 adb shell chown "$OLDOWN":"$OLDGRP" $TARGET
871 adb shell chmod "$OLDPERM" $TARGET
872 else
873 echo "$TARGET did not exist previously, you should set file permissions manually"
874 fi
875 adb shell restorecon "$TARGET"
876 ;;
877 /system/priv-app/SystemUI/SystemUI.apk|/system/framework/*)
878 # Only need to stop services once
879 if ! $stop_n_start; then
880 adb shell stop
881 stop_n_start=true
882 fi
883 echo "Pushing: $TARGET"
884 adb push $FILE $TARGET
885 ;;
886 *)
887 echo "Pushing: $TARGET"
888 adb push $FILE $TARGET
889 ;;
890 esac
891 done
892 if [ -n "$CHKPERM" ]; then
893 adb shell rm $CHKPERM
894 fi
895 if $stop_n_start; then
896 adb shell start
897 fi
898 rm -f $OUT/.log
899 return 0
900 else
Jackeagled6811aa2019-09-24 08:26:40 +0200901 echo "The connected device does not appear to be $BLISS_BUILD, run away!"
Michael Bestas3952f6c2016-08-26 01:12:08 +0300902 fi
903}
904
905alias mmp='dopush mm'
906alias mmmp='dopush mmm'
907alias mmap='dopush mma'
Zhao Wei Liew64fc5ae2016-12-10 16:48:27 +0800908alias mmmap='dopush mmma'
Michael Bestas3952f6c2016-08-26 01:12:08 +0300909alias mkap='dopush mka'
910alias cmkap='dopush cmka'
911
912function repopick() {
913 T=$(gettop)
Jackeagled6811aa2019-09-24 08:26:40 +0200914 $T/vendor/bliss/build/tools/repopick.py $@
Michael Bestas3952f6c2016-08-26 01:12:08 +0300915}
916
917function fixup_common_out_dir() {
918 common_out_dir=$(get_build_var OUT_DIR)/target/common
919 target_device=$(get_build_var TARGET_DEVICE)
Sam Mortimer55d6ec52019-09-10 11:40:34 -0700920 common_target_out=common-${target_device}
Jackeagle305db7c2020-01-23 10:35:22 +0100921 if [ ! -z $BLISS_FIXUP_COMMON_OUT ]; then
Michael Bestas3952f6c2016-08-26 01:12:08 +0300922 if [ -d ${common_out_dir} ] && [ ! -L ${common_out_dir} ]; then
923 mv ${common_out_dir} ${common_out_dir}-${target_device}
Sam Mortimer55d6ec52019-09-10 11:40:34 -0700924 ln -s ${common_target_out} ${common_out_dir}
Michael Bestas3952f6c2016-08-26 01:12:08 +0300925 else
926 [ -L ${common_out_dir} ] && rm ${common_out_dir}
927 mkdir -p ${common_out_dir}-${target_device}
Sam Mortimer55d6ec52019-09-10 11:40:34 -0700928 ln -s ${common_target_out} ${common_out_dir}
Michael Bestas3952f6c2016-08-26 01:12:08 +0300929 fi
930 else
931 [ -L ${common_out_dir} ] && rm ${common_out_dir}
932 mkdir -p ${common_out_dir}
933 fi
934}
Jackeagle305db7c2020-01-23 10:35:22 +0100935
936function blissify()
937{
Jon West6f429fa2021-04-24 18:09:38 -0400938 abt="$ANDROID_BUILD_TOP"
939 cd $abt
940 clean="n"
941 deviceclean="n"
942 export BLISS_BUILD_VARIANT=vanilla
943 while test $# -gt 0
944 do
945 case $1 in
946
947 # Normal option processing
948 -h | --help)
949 echo "Usage: $0 options deviceCodename "
950 echo "options: -h | --help: Shows this dialog"
951 echo " -c | --clean: Clean up before running the build"
952 echo " -d | --devclean: Clean up device tree before running the build"
953 echo " -v | --vanilla: Build with no added app store solution **default option** "
954 echo " -g | --gapps: Build with Google Play Services added"
955 echo " -f | --fossa: build with FOSS (arm64-v8a) app store solutions added"
956 echo " -F | --fossx: build with FOSS (x86_64) app store solutions added"
957 echo ""
958 echo "deviceCodename: "
959 echo "your device codename, without the 'bliss_' in front"
960 echo ""
961 ;;
962 -c | --clean)
963 clean="y";
964 echo "Cleaning build and device tree selected."
965 ;;
966 -d | --devclean)
967 deviceclean="y";
968 echo "Cleaning device tree selected."
969 ;;
970 -v | --vanilla)
971 echo "Building as stock (no gapps) **DEFAULT**"
972 export BLISS_BUILD_VARIANT=vanilla
973 ;;
974 -g | --gapps)
975 echo "Building with gapps"
976 export BLISS_BUILD_VARIANT=gapps
977 ;;
978 -f | --fossa)
979 echo "Building with FOSS apps for arm64-v8a support"
980 export BLISS_BUILD_VARIANT=foss
981 cd vendor/foss
982 bash update.sh 2
983 cd $abt
984 ;;
985 -F | --fossx)
986 echo "Building with FOSS apps for x86_64 support"
987 export BLISS_BUILD_VARIANT=foss
988 cd vendor/foss
989 bash update.sh 1
990 cd $abt
991 ;;
Jon West68fe7e52021-06-02 15:24:20 -0400992 -u | --userdebug)
993 echo "Building userdebug variant"
994 TARGET_BUILD_VARIANT=userdebug
995 ;;
996 -U | --user)
997 echo "Building user variant"
998 TARGET_BUILD_VARIANT=user
999 ;;
1000 -e | --eng)
1001 echo "Building eng variant"
1002 TARGET_BUILD_VARIANT=eng
1003 ;;
1004
Jon West6f429fa2021-04-24 18:09:38 -04001005
1006 # ...
1007
1008 # Special cases
1009 --)
1010 echo "Please use --help to verify correct usage"
1011 break
1012 ;;
1013 --*)
1014 # error unknown (long) option $1
1015 echo "Please use --help to verify correct usage"
1016 break
1017 ;;
1018 -?)
1019 echo "Please use --help to verify correct usage"
1020 # error unknown (short) option $1
1021 break
1022 ;;
1023
1024 # FUN STUFF HERE:
1025 # Split apart combined short options
1026 -*)
1027 split=$1
1028 shift
1029 set -- $(echo "$split" | cut -c 2- | sed 's/./-& /g') "$@"
1030 continue
1031 ;;
1032
1033 # Done with options
1034 *)
1035 break
1036 ;;
1037 esac
1038
1039 # for testing purposes:
1040 shift
1041 done
1042
1043 if [ $clean == "y" ];then
1044 echo "Cleaning up a bit"
1045 make clean && make clobber
1046 fi
1047
1048 if [ $deviceclean == "y" ];then
1049 echo "Doing some device cleanup"
1050 make deviceclean
1051 fi
1052
1053 if [ "$1" == "" ]; then
1054 echo "No device name specified. Please use --help to verify correct usage"
1055 return 0
1056 fi
1057
Jon West68fe7e52021-06-02 15:24:20 -04001058 # Breakfast extension
1059 if [ $TARGET_BUILD_VARIANT == "user" ];then
1060 breakfast $* user
1061 elif [ $TARGET_BUILD_VARIANT == "eng" ];then
1062 breakfast $* eng
1063 else
1064 breakfast $*
1065 fi
1066
Jackeagle305db7c2020-01-23 10:35:22 +01001067 if [ $? -eq 0 ]; then
1068 mka blissify
1069 else
Jon West6f429fa2021-04-24 18:09:38 -04001070 echo "No such item in brunch menu. Try 'breakfast' or verify your product is added to AndroidProducts.mk"
Jackeagle305db7c2020-01-23 10:35:22 +01001071 return 1
1072 fi
1073 return $?
1074}