Date: Sunday, September 27, 2015 @ 13:03:44 Author: anatolik Revision: 141686
archrelease: copy trunk to community-testing-i686, community-testing-x86_64 Added: android-tools/repos/community-testing-i686/ android-tools/repos/community-testing-i686/Makefile (from rev 141685, android-tools/trunk/Makefile) android-tools/repos/community-testing-i686/PKGBUILD (from rev 141685, android-tools/trunk/PKGBUILD) android-tools/repos/community-testing-i686/bash_completion (from rev 141685, android-tools/trunk/bash_completion) android-tools/repos/community-testing-x86_64/ android-tools/repos/community-testing-x86_64/Makefile (from rev 141685, android-tools/trunk/Makefile) android-tools/repos/community-testing-x86_64/PKGBUILD (from rev 141685, android-tools/trunk/PKGBUILD) android-tools/repos/community-testing-x86_64/bash_completion (from rev 141685, android-tools/trunk/bash_completion) ------------------------------------------+ community-testing-i686/Makefile | 101 ++++++++++++++ community-testing-i686/PKGBUILD | 41 +++++ community-testing-i686/bash_completion | 203 +++++++++++++++++++++++++++++ community-testing-x86_64/Makefile | 101 ++++++++++++++ community-testing-x86_64/PKGBUILD | 41 +++++ community-testing-x86_64/bash_completion | 203 +++++++++++++++++++++++++++++ 6 files changed, 690 insertions(+) Copied: android-tools/repos/community-testing-i686/Makefile (from rev 141685, android-tools/trunk/Makefile) =================================================================== --- community-testing-i686/Makefile (rev 0) +++ community-testing-i686/Makefile 2015-09-27 11:03:44 UTC (rev 141686) @@ -0,0 +1,101 @@ +all: mkbootimg fastboot adb + +install: + install -m755 -d $(DESTDIR)/usr/bin + install -m755 -t $(DESTDIR)/usr/bin mkbootimg fastboot adb + +clean: + rm -f **/*.o + +.PHONY: clean + + + + +MKBOOTIMG_SRCS += $(wildcard core/libmincrypt/*.c) +MKBOOTIMG_SRCS += core/mkbootimg/mkbootimg.c + +MKBOOTIMG_CFLAGS += -Icore/include + +mkbootimg: $(MKBOOTIMG_SRCS) + $(CC) -o $@ $(CFLAGS) $(MKBOOTIMG_CFLAGS) $(LDFLAGS) $(MKBOOTIMG_LIBS) $(MKBOOTIMG_SRCS) + + + + +ADB_SRCS += core/adb/adb.c +ADB_SRCS += core/adb/adb_auth_host.c +ADB_SRCS += core/adb/adb_client.c +ADB_SRCS += core/adb/commandline.c +ADB_SRCS += core/adb/console.c +ADB_SRCS += core/adb/fdevent.c +ADB_SRCS += core/adb/file_sync_client.c +ADB_SRCS += core/adb/get_my_path_linux.c +ADB_SRCS += core/adb/services.c +ADB_SRCS += core/adb/sockets.c +ADB_SRCS += core/adb/transport.c +ADB_SRCS += core/adb/transport_local.c +ADB_SRCS += core/adb/transport_usb.c +ADB_SRCS += core/adb/usb_linux.c +ADB_SRCS += core/adb/usb_vendors.c +ADB_SRCS += core/libcutils/load_file.c +ADB_SRCS += core/libcutils/socket_inaddr_any_server.c +ADB_SRCS += core/libcutils/socket_local_client.c +ADB_SRCS += core/libcutils/socket_local_server.c +ADB_SRCS += core/libcutils/socket_loopback_client.c +ADB_SRCS += core/libcutils/socket_loopback_server.c +ADB_SRCS += core/libcutils/socket_network_client.c +ADB_SRCS += core/libzipfile/centraldir.c +ADB_SRCS += core/libzipfile/zipfile.c + +ADB_CFLAGS += -DADB_HOST=1 -DHAVE_FORKEXEC=1 -DHAVE_OFF64_T=1 -DHAVE_TERMIO_H -I core/include -I core/adb +ADB_LIBS += -lcrypto -lpthread -lz + +adb: $(ADB_SRCS) + $(CC) -o $@ $(CFLAGS) $(ADB_CFLAGS) $(LDFLAGS) $(ADB_SRCS) $(ADB_LIBS) + + + +FASTBOOT_SRCS += core/fastboot/bootimg.c +FASTBOOT_SRCS += core/fastboot/engine.c +FASTBOOT_SRCS += core/fastboot/fastboot.c +FASTBOOT_SRCS += core/fastboot/protocol.c +FASTBOOT_SRCS += core/fastboot/usb_linux.c +FASTBOOT_SRCS += core/fastboot/util_linux.c +FASTBOOT_SRCS += core/fastboot/util.c +FASTBOOT_SRCS += core/fastboot/fs.c +FASTBOOT_SRCS += core/libsparse/backed_block.c +FASTBOOT_SRCS += core/libsparse/output_file.c +FASTBOOT_SRCS += core/libsparse/sparse.c +FASTBOOT_SRCS += core/libsparse/sparse_crc32.c +FASTBOOT_SRCS += core/libsparse/sparse_err.c +FASTBOOT_SRCS += core/libsparse/sparse_read.c +FASTBOOT_SRCS += core/libzipfile/centraldir.c +FASTBOOT_SRCS += core/libzipfile/zipfile.c +FASTBOOT_SRCS += extras/ext4_utils/allocate.c +FASTBOOT_SRCS += extras/ext4_utils/contents.c +FASTBOOT_SRCS += extras/ext4_utils/crc16.c +FASTBOOT_SRCS += extras/ext4_utils/ext4_utils.c +FASTBOOT_SRCS += extras/ext4_utils/ext4_sb.c +FASTBOOT_SRCS += extras/ext4_utils/extent.c +FASTBOOT_SRCS += extras/ext4_utils/indirect.c +FASTBOOT_SRCS += extras/ext4_utils/make_ext4fs.c +FASTBOOT_SRCS += extras/ext4_utils/sha1.c +FASTBOOT_SRCS += extras/ext4_utils/uuid.c +FASTBOOT_SRCS += extras/ext4_utils/wipe.c +FASTBOOT_SRCS += extras/f2fs_utils/f2fs_utils.c +FASTBOOT_SRCS += extras/f2fs_utils/f2fs_dlutils.c +FASTBOOT_SRCS += extras/f2fs_utils/f2fs_ioutils.c +FASTBOOT_SRCS += libselinux/src/callbacks.c +FASTBOOT_SRCS += libselinux/src/check_context.c +FASTBOOT_SRCS += libselinux/src/freecon.c +FASTBOOT_SRCS += libselinux/src/init.c +FASTBOOT_SRCS += libselinux/src/label.c +FASTBOOT_SRCS += libselinux/src/label_android_property.c +FASTBOOT_SRCS += libselinux/src/label_file.c + +FASTBOOT_CFLAGS += -DHAVE_OFF64_T=1 -std=gnu99 -I core/mkbootimg -I core/libsparse/include -I core/include -I extras/ext4_utils -I extras/f2fs_utils -I libselinux/include -I f2fs-tools/include -I f2fs-tools/mkfs +FASTBOOT_LIBS += -lz -ldl -lpcre + +fastboot: $(FASTBOOT_SRCS) + $(CC) -o $@ $(CFLAGS) $(FASTBOOT_CFLAGS) $(LDFLAGS) $(FASTBOOT_SRCS) $(FASTBOOT_LIBS) Copied: android-tools/repos/community-testing-i686/PKGBUILD (from rev 141685, android-tools/trunk/PKGBUILD) =================================================================== --- community-testing-i686/PKGBUILD (rev 0) +++ community-testing-i686/PKGBUILD 2015-09-27 11:03:44 UTC (rev 141686) @@ -0,0 +1,41 @@ +# $Id$ +# Maintainer: Anatol Pomozov +# Contributor: 謝致邦 <yek...@red54.com> +# Contributor: Alucryd <alucryd at gmail dot com> + +pkgname=android-tools +pkgver=5.1.1_r18 +pkgrel=1 +pkgdesc='Android platform tools' +arch=(i686 x86_64) +url='http://tools.android.com/' +license=(Apache MIT) +depends=(openssl pcre) +makedepends=(git) +source=(git+https://android.googlesource.com/platform/system/core#tag=android-$pkgver + git+https://android.googlesource.com/platform/system/extras#tag=android-$pkgver + git+https://android.googlesource.com/platform/external/libselinux#tag=android-$pkgver + git+https://android.googlesource.com/platform/external/f2fs-tools#tag=android-$pkgver + Makefile + bash_completion) # Bash completion file was taken from https://github.com/mbrubeck/android-completion +sha1sums=('SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + '67baba7465ba6a65c206e8373656e5fe1d85f188' + 'e1bd94fd4dd260af3c068496071d67738d431aec') + +prepare() { + # another way to fix the compilation error is to add #include <stddef.h> + sed -e 's/f2fs_sparse_file = NULL/f2fs_sparse_file = 0/g' -i extras/f2fs_utils/f2fs_utils.c +} + +build() { + make +} + +package(){ + make DESTDIR="$pkgdir" install + + install -Dm 644 bash_completion "$pkgdir"/etc/bash_completion.d/$pkgname +} Copied: android-tools/repos/community-testing-i686/bash_completion (from rev 141685, android-tools/trunk/bash_completion) =================================================================== --- community-testing-i686/bash_completion (rev 0) +++ community-testing-i686/bash_completion 2015-09-27 11:03:44 UTC (rev 141686) @@ -0,0 +1,203 @@ +## Bash completion for the Android SDK tools. +## +## Copyright (c) 2009 Matt Brubeck +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included in +## all copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +## THE SOFTWARE. + + +function _adb() +{ + local cur prev opts cmds c subcommand device_selected + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="-d -e -s -p" + cmds="devices push pull sync shell emu logcat forward jdwp install sideload \ + uninstall bugreport help version wait-for-device start-server \ + reboot reboot-bootloader \ + connect disconnect \ + kill-server get-state get-serialno status-window remount root ppp backup restore" + cmds_not_need_device="devices help version start-server kill-server connect disconnect" + subcommand="" + device_selected="" + + # Look for the subcommand. + c=1 + while [ $c -lt $COMP_CWORD ]; do + word="${COMP_WORDS[c]}" + if [ "$word" = "-d" -o "$word" = "-e" -o "$word" = "-s" ]; then + device_selected=true + opts="-p" + fi + for cmd in $cmds; do + if [ "$cmd" = "$word" ]; then + subcommand="$word" + fi + done + c=$((++c)) + done + + case "${subcommand}" in + '') + case "${prev}" in + -p) + return 0; + ;; + -s) + # Use 'adb devices' to list serial numbers. + COMPREPLY=( $(compgen -W "$(adb devices | + awk '/(device|recovery|sideload)$/{print $1}')" -- ${cur} ) ) + return 0 + ;; + esac + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) + return 0 + ;; + esac + if [ -z "$device_selected" ]; then + local num_devices=$(( $(adb devices 2>/dev/null|wc -l) - 2 )) + if [ "$num_devices" -gt "1" ]; then + # With multiple devices, you must choose a device first. + COMPREPLY=( $(compgen -W "${opts} ${cmds_not_need_device}" -- ${cur}) ) + return 0 + fi + fi + COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) ) + return 0 + ;; + install) + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "-l -r -s" -- ${cur}) ) + return 0 + ;; + esac + ;; + forward) + # Filename or installation option. + COMPREPLY=( $(compgen -W "tcp: localabstract: localreserved: localfilesystem: dev: jdwp:" -- ${cur}) ) + return 0 + ;; + uninstall) + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "-k" -- ${cur}) ) + return 0 + ;; + esac + ;; + logcat) + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "-v -b -c -d -f -g -n -r -s" -- ${cur}) ) + return 0 + ;; + esac + case "${prev}" in + -v) + COMPREPLY=( $(compgen -W "brief process tag thread raw time long" -- ${cur}) ) + return 0 + ;; + -b) + COMPREPLY=( $(compgen -W "radio events main" -- ${cur}) ) + return 0 + ;; + esac + ;; + backup) + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "-f -apk -noapk -obb -noobb -shared -noshared -all -system -nosystem" -- ${cur}) ) + return 0 + ;; + esac + ;; + esac +} +complete -o default -F _adb adb + +function _fastboot() +{ + local cur prev opts cmds c subcommand device_selected + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="-w -s -p -c -i -b -n" + cmds="update flashall flash erase getvar boot devices \ + reboot reboot-bootloader oem continue" + subcommand="" + partition_list="boot recovery system userdata bootloader radio" + device_selected="" + + # Look for the subcommand. + c=1 + while [ $c -lt $COMP_CWORD ]; do + word="${COMP_WORDS[c]}" + if [ "$word" = "-s" ]; then + device_selected=true + fi + for cmd in $cmds; do + if [ "$cmd" = "$word" ]; then + subcommand="$word" + fi + done + c=$((++c)) + done + + case "${subcommand}" in + '') + case "${prev}" in + -s) + # Use 'fastboot devices' to list serial numbers. + COMPREPLY=( $(compgen -W "$(fastboot devices|cut -f1)" -- ${cur} ) ) + return 0 + ;; + esac + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) + return 0 + ;; + esac + if [ -z "$device_selected" ]; then + local num_devices=$(( $(fastboot devices 2>/dev/null|wc -l) )) + if [ "$num_devices" -gt "1" ]; then + # With multiple devices, you must choose a device first. + COMPREPLY=( $(compgen -W "-s" -- ${cur}) ) + return 0 + fi + fi + COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) ) + return 0 + ;; + flash) + # partition name + COMPREPLY=( $(compgen -W "${partition_list}" -- ${cur}) ) + return 0 + ;; + erase) + # partition name + COMPREPLY=( $(compgen -W "${partition_list}" -- ${cur}) ) + return 0 + ;; + esac +} +complete -o default -F _fastboot fastboot Copied: android-tools/repos/community-testing-x86_64/Makefile (from rev 141685, android-tools/trunk/Makefile) =================================================================== --- community-testing-x86_64/Makefile (rev 0) +++ community-testing-x86_64/Makefile 2015-09-27 11:03:44 UTC (rev 141686) @@ -0,0 +1,101 @@ +all: mkbootimg fastboot adb + +install: + install -m755 -d $(DESTDIR)/usr/bin + install -m755 -t $(DESTDIR)/usr/bin mkbootimg fastboot adb + +clean: + rm -f **/*.o + +.PHONY: clean + + + + +MKBOOTIMG_SRCS += $(wildcard core/libmincrypt/*.c) +MKBOOTIMG_SRCS += core/mkbootimg/mkbootimg.c + +MKBOOTIMG_CFLAGS += -Icore/include + +mkbootimg: $(MKBOOTIMG_SRCS) + $(CC) -o $@ $(CFLAGS) $(MKBOOTIMG_CFLAGS) $(LDFLAGS) $(MKBOOTIMG_LIBS) $(MKBOOTIMG_SRCS) + + + + +ADB_SRCS += core/adb/adb.c +ADB_SRCS += core/adb/adb_auth_host.c +ADB_SRCS += core/adb/adb_client.c +ADB_SRCS += core/adb/commandline.c +ADB_SRCS += core/adb/console.c +ADB_SRCS += core/adb/fdevent.c +ADB_SRCS += core/adb/file_sync_client.c +ADB_SRCS += core/adb/get_my_path_linux.c +ADB_SRCS += core/adb/services.c +ADB_SRCS += core/adb/sockets.c +ADB_SRCS += core/adb/transport.c +ADB_SRCS += core/adb/transport_local.c +ADB_SRCS += core/adb/transport_usb.c +ADB_SRCS += core/adb/usb_linux.c +ADB_SRCS += core/adb/usb_vendors.c +ADB_SRCS += core/libcutils/load_file.c +ADB_SRCS += core/libcutils/socket_inaddr_any_server.c +ADB_SRCS += core/libcutils/socket_local_client.c +ADB_SRCS += core/libcutils/socket_local_server.c +ADB_SRCS += core/libcutils/socket_loopback_client.c +ADB_SRCS += core/libcutils/socket_loopback_server.c +ADB_SRCS += core/libcutils/socket_network_client.c +ADB_SRCS += core/libzipfile/centraldir.c +ADB_SRCS += core/libzipfile/zipfile.c + +ADB_CFLAGS += -DADB_HOST=1 -DHAVE_FORKEXEC=1 -DHAVE_OFF64_T=1 -DHAVE_TERMIO_H -I core/include -I core/adb +ADB_LIBS += -lcrypto -lpthread -lz + +adb: $(ADB_SRCS) + $(CC) -o $@ $(CFLAGS) $(ADB_CFLAGS) $(LDFLAGS) $(ADB_SRCS) $(ADB_LIBS) + + + +FASTBOOT_SRCS += core/fastboot/bootimg.c +FASTBOOT_SRCS += core/fastboot/engine.c +FASTBOOT_SRCS += core/fastboot/fastboot.c +FASTBOOT_SRCS += core/fastboot/protocol.c +FASTBOOT_SRCS += core/fastboot/usb_linux.c +FASTBOOT_SRCS += core/fastboot/util_linux.c +FASTBOOT_SRCS += core/fastboot/util.c +FASTBOOT_SRCS += core/fastboot/fs.c +FASTBOOT_SRCS += core/libsparse/backed_block.c +FASTBOOT_SRCS += core/libsparse/output_file.c +FASTBOOT_SRCS += core/libsparse/sparse.c +FASTBOOT_SRCS += core/libsparse/sparse_crc32.c +FASTBOOT_SRCS += core/libsparse/sparse_err.c +FASTBOOT_SRCS += core/libsparse/sparse_read.c +FASTBOOT_SRCS += core/libzipfile/centraldir.c +FASTBOOT_SRCS += core/libzipfile/zipfile.c +FASTBOOT_SRCS += extras/ext4_utils/allocate.c +FASTBOOT_SRCS += extras/ext4_utils/contents.c +FASTBOOT_SRCS += extras/ext4_utils/crc16.c +FASTBOOT_SRCS += extras/ext4_utils/ext4_utils.c +FASTBOOT_SRCS += extras/ext4_utils/ext4_sb.c +FASTBOOT_SRCS += extras/ext4_utils/extent.c +FASTBOOT_SRCS += extras/ext4_utils/indirect.c +FASTBOOT_SRCS += extras/ext4_utils/make_ext4fs.c +FASTBOOT_SRCS += extras/ext4_utils/sha1.c +FASTBOOT_SRCS += extras/ext4_utils/uuid.c +FASTBOOT_SRCS += extras/ext4_utils/wipe.c +FASTBOOT_SRCS += extras/f2fs_utils/f2fs_utils.c +FASTBOOT_SRCS += extras/f2fs_utils/f2fs_dlutils.c +FASTBOOT_SRCS += extras/f2fs_utils/f2fs_ioutils.c +FASTBOOT_SRCS += libselinux/src/callbacks.c +FASTBOOT_SRCS += libselinux/src/check_context.c +FASTBOOT_SRCS += libselinux/src/freecon.c +FASTBOOT_SRCS += libselinux/src/init.c +FASTBOOT_SRCS += libselinux/src/label.c +FASTBOOT_SRCS += libselinux/src/label_android_property.c +FASTBOOT_SRCS += libselinux/src/label_file.c + +FASTBOOT_CFLAGS += -DHAVE_OFF64_T=1 -std=gnu99 -I core/mkbootimg -I core/libsparse/include -I core/include -I extras/ext4_utils -I extras/f2fs_utils -I libselinux/include -I f2fs-tools/include -I f2fs-tools/mkfs +FASTBOOT_LIBS += -lz -ldl -lpcre + +fastboot: $(FASTBOOT_SRCS) + $(CC) -o $@ $(CFLAGS) $(FASTBOOT_CFLAGS) $(LDFLAGS) $(FASTBOOT_SRCS) $(FASTBOOT_LIBS) Copied: android-tools/repos/community-testing-x86_64/PKGBUILD (from rev 141685, android-tools/trunk/PKGBUILD) =================================================================== --- community-testing-x86_64/PKGBUILD (rev 0) +++ community-testing-x86_64/PKGBUILD 2015-09-27 11:03:44 UTC (rev 141686) @@ -0,0 +1,41 @@ +# $Id$ +# Maintainer: Anatol Pomozov +# Contributor: 謝致邦 <yek...@red54.com> +# Contributor: Alucryd <alucryd at gmail dot com> + +pkgname=android-tools +pkgver=5.1.1_r18 +pkgrel=1 +pkgdesc='Android platform tools' +arch=(i686 x86_64) +url='http://tools.android.com/' +license=(Apache MIT) +depends=(openssl pcre) +makedepends=(git) +source=(git+https://android.googlesource.com/platform/system/core#tag=android-$pkgver + git+https://android.googlesource.com/platform/system/extras#tag=android-$pkgver + git+https://android.googlesource.com/platform/external/libselinux#tag=android-$pkgver + git+https://android.googlesource.com/platform/external/f2fs-tools#tag=android-$pkgver + Makefile + bash_completion) # Bash completion file was taken from https://github.com/mbrubeck/android-completion +sha1sums=('SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + '67baba7465ba6a65c206e8373656e5fe1d85f188' + 'e1bd94fd4dd260af3c068496071d67738d431aec') + +prepare() { + # another way to fix the compilation error is to add #include <stddef.h> + sed -e 's/f2fs_sparse_file = NULL/f2fs_sparse_file = 0/g' -i extras/f2fs_utils/f2fs_utils.c +} + +build() { + make +} + +package(){ + make DESTDIR="$pkgdir" install + + install -Dm 644 bash_completion "$pkgdir"/etc/bash_completion.d/$pkgname +} Copied: android-tools/repos/community-testing-x86_64/bash_completion (from rev 141685, android-tools/trunk/bash_completion) =================================================================== --- community-testing-x86_64/bash_completion (rev 0) +++ community-testing-x86_64/bash_completion 2015-09-27 11:03:44 UTC (rev 141686) @@ -0,0 +1,203 @@ +## Bash completion for the Android SDK tools. +## +## Copyright (c) 2009 Matt Brubeck +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included in +## all copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +## THE SOFTWARE. + + +function _adb() +{ + local cur prev opts cmds c subcommand device_selected + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="-d -e -s -p" + cmds="devices push pull sync shell emu logcat forward jdwp install sideload \ + uninstall bugreport help version wait-for-device start-server \ + reboot reboot-bootloader \ + connect disconnect \ + kill-server get-state get-serialno status-window remount root ppp backup restore" + cmds_not_need_device="devices help version start-server kill-server connect disconnect" + subcommand="" + device_selected="" + + # Look for the subcommand. + c=1 + while [ $c -lt $COMP_CWORD ]; do + word="${COMP_WORDS[c]}" + if [ "$word" = "-d" -o "$word" = "-e" -o "$word" = "-s" ]; then + device_selected=true + opts="-p" + fi + for cmd in $cmds; do + if [ "$cmd" = "$word" ]; then + subcommand="$word" + fi + done + c=$((++c)) + done + + case "${subcommand}" in + '') + case "${prev}" in + -p) + return 0; + ;; + -s) + # Use 'adb devices' to list serial numbers. + COMPREPLY=( $(compgen -W "$(adb devices | + awk '/(device|recovery|sideload)$/{print $1}')" -- ${cur} ) ) + return 0 + ;; + esac + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) + return 0 + ;; + esac + if [ -z "$device_selected" ]; then + local num_devices=$(( $(adb devices 2>/dev/null|wc -l) - 2 )) + if [ "$num_devices" -gt "1" ]; then + # With multiple devices, you must choose a device first. + COMPREPLY=( $(compgen -W "${opts} ${cmds_not_need_device}" -- ${cur}) ) + return 0 + fi + fi + COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) ) + return 0 + ;; + install) + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "-l -r -s" -- ${cur}) ) + return 0 + ;; + esac + ;; + forward) + # Filename or installation option. + COMPREPLY=( $(compgen -W "tcp: localabstract: localreserved: localfilesystem: dev: jdwp:" -- ${cur}) ) + return 0 + ;; + uninstall) + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "-k" -- ${cur}) ) + return 0 + ;; + esac + ;; + logcat) + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "-v -b -c -d -f -g -n -r -s" -- ${cur}) ) + return 0 + ;; + esac + case "${prev}" in + -v) + COMPREPLY=( $(compgen -W "brief process tag thread raw time long" -- ${cur}) ) + return 0 + ;; + -b) + COMPREPLY=( $(compgen -W "radio events main" -- ${cur}) ) + return 0 + ;; + esac + ;; + backup) + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "-f -apk -noapk -obb -noobb -shared -noshared -all -system -nosystem" -- ${cur}) ) + return 0 + ;; + esac + ;; + esac +} +complete -o default -F _adb adb + +function _fastboot() +{ + local cur prev opts cmds c subcommand device_selected + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="-w -s -p -c -i -b -n" + cmds="update flashall flash erase getvar boot devices \ + reboot reboot-bootloader oem continue" + subcommand="" + partition_list="boot recovery system userdata bootloader radio" + device_selected="" + + # Look for the subcommand. + c=1 + while [ $c -lt $COMP_CWORD ]; do + word="${COMP_WORDS[c]}" + if [ "$word" = "-s" ]; then + device_selected=true + fi + for cmd in $cmds; do + if [ "$cmd" = "$word" ]; then + subcommand="$word" + fi + done + c=$((++c)) + done + + case "${subcommand}" in + '') + case "${prev}" in + -s) + # Use 'fastboot devices' to list serial numbers. + COMPREPLY=( $(compgen -W "$(fastboot devices|cut -f1)" -- ${cur} ) ) + return 0 + ;; + esac + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) + return 0 + ;; + esac + if [ -z "$device_selected" ]; then + local num_devices=$(( $(fastboot devices 2>/dev/null|wc -l) )) + if [ "$num_devices" -gt "1" ]; then + # With multiple devices, you must choose a device first. + COMPREPLY=( $(compgen -W "-s" -- ${cur}) ) + return 0 + fi + fi + COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) ) + return 0 + ;; + flash) + # partition name + COMPREPLY=( $(compgen -W "${partition_list}" -- ${cur}) ) + return 0 + ;; + erase) + # partition name + COMPREPLY=( $(compgen -W "${partition_list}" -- ${cur}) ) + return 0 + ;; + esac +} +complete -o default -F _fastboot fastboot