view android/my-android-symlink @ 610:92f77b6d0d99

Utilities for enabling access to Android SDK.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Mon, 18 Jan 2016 01:06:17 +0200
parents
children
line wrap: on
line source

#!/bin/bash

LANG=C
LC_ALL=C

prefix=~/usr
bindir=$prefix/bin

sdk=
# Find first available.
for f in /opt/*/platform-tools/adb; do
  if [[ -f $f ]]; then
    sdk=${f%/platform-tools/adb}
    break
  fi
done

if [[ -z "$sdk" ]]; then
  echo "Can't find Androidf SDK dir. I try search in /opt/*"
  exit 1
fi
if [[ ! -d "$bindir" ]]; then
  echo "$bindir does not exist*"
  exit 1
fi

create_link() {
  if [[ -f "$1" ]]; then
    ln -s -f "$1" "$2"
  else
    echo "Can't find $1"
    exit 1
  fi
}

create_link $sdk/platform-tools/adb $bindir/adb
create_link $sdk/platform-tools/fastboot $bindir/fastboot
create_link $sdk/tools/android $bindir/android
create_link $sdk/tools/ddms $bindir/ddms

maxver=$(for d in $sdk/build-tools/*[0-9].[0-9]*; do
  [[ -d $d ]] && echo ${d##*/}
done | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr | head -n 1)
if [[ -z "$maxver" ]]; then
  echo "You have no platform-tools in $sdk/platform-tools/"
  exit 0
fi
btools=$sdk/build-tools/$maxver
if [[ ! -d "$btools" ]]; then
  echo "$btools isn't a directory"
  exit 1
fi

create_link $btools/aapt $bindir/aapt
create_link $btools/aapt $bindir/dexdump
create_link $btools/aapt $bindir/dx