Skip to content

Commit 691b000

Browse files
authored
Add files via upload
1 parent 787a2d1 commit 691b000

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

android-tools-appimage.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/sh
2+
3+
APP=platform-tools
4+
SITE="https://dl.google.com/android/repository"
5+
6+
# CREATE DIRECTORIES
7+
if [ -z "$APP" ]; then exit 1; fi
8+
mkdir -p "./$APP/tmp" && cd "./$APP/tmp" || exit
9+
10+
# DOWNLOAD THE ARCHIVE
11+
mkdir ./tmp && cd ./tmp || exit
12+
wget "$SITE/$APP-latest-linux.zip" && unzip -qq ./*.zip
13+
cd ..
14+
mkdir "./$APP.AppDir" && mv --backup=t ./tmp/*/* ./$APP.AppDir
15+
cd ./$APP.AppDir || exit
16+
17+
# DESKTOP ENTRY
18+
echo "[Desktop Entry]
19+
Name=Android-platform-tools
20+
Type=Application
21+
Icon=Android
22+
TryExec=adb
23+
Exec=adb shell %f
24+
Categories=Utility;
25+
Terminal=true" >> "./Android-$APP.desktop"
26+
27+
# GET ICON
28+
wget https://developer.android.com/static/images/brand/Android_Robot.png -O ./Android.png 2> /dev/null
29+
ln -s ./Android.png ./.DirIcon
30+
31+
# AppRun
32+
cat >> ./AppRun << 'EOF'
33+
#!/bin/bash
34+
CURRENTDIR="$(readlink -f "$(dirname "$0")")"
35+
UDEVNOTICE=$(echo "If you get errors it might be because you don't have the android udev rules for your device" )
36+
if [ "$1" = "adb" ]; then
37+
"$CURRENTDIR"/adb "${@:2}"
38+
elif [ "$1" = "etc1tool" ]; then
39+
"$CURRENTDIR"/etc1tool "${@:2}" || echo "$UDEVNOTICE"
40+
elif [ "$1" = "fastboot" ]; then
41+
"$CURRENTDIR"/fastboot "${@:2}" || echo "$UDEVNOTICE"
42+
elif [ "$1" = "make_f2fs" ]; then
43+
"$CURRENTDIR"/make_f2fs "${@:2}" || echo "$UDEVNOTICE"
44+
elif [ "$1" = "make_f2fs_casefold" ]; then
45+
"$CURRENTDIR"/make_f2fs_casefold "${@:2}" || echo "$UDEVNOTICE"
46+
elif [ "$1" = "mke2fs" ]; then
47+
"$CURRENTDIR"/mke2fs "${@:2}" || echo "$UDEVNOTICE"
48+
elif [ "$1" = "sqlite3" ]; then
49+
"$CURRENTDIR"/sqlite3 "${@:2}" || echo "$UDEVNOTICE"
50+
else
51+
echo "Error: No command specified, try \"./*tools.AppImage adb shell\" for example"
52+
echo "You can also use aliases or wrapper scripts to not write ./*tools.AppImage every time"
53+
echo "$UDEVNOTICE"
54+
fi
55+
EOF
56+
chmod a+x ./AppRun
57+
58+
# MAKE APPIMAGE
59+
VERSION=$(cat source.properties | grep vision | awk -F = '{print $NF; exit}')
60+
cd ..
61+
wget -q $(wget -q https://api.github.com/repos/probonopd/go-appimage/releases -O - | grep -v zsync | grep -i continuous | grep -i appimagetool | grep -i x86_64 | grep browser_download_url | cut -d '"' -f 4 | head -1) -O appimagetool
62+
chmod a+x ./appimagetool
63+
64+
# Do the thing!
65+
ARCH=x86_64 VERSION=$(./appimagetool -v | grep -o '[[:digit:]]*') ./appimagetool -s ./$APP.AppDir &&
66+
ls ./*.AppImage || { echo "appimagetool failed to make the appimage"; exit 1; }
67+
mv ./*AppImage ./"$VERSION"-"platform-tools.AppImage"
68+
if [ -z "$APP" ]; then exit 1; fi # Being extra safe lol
69+
rm -rf "./$APP.AppDir" && rm ./appimagetool
70+
mv ./*.AppImage .. && cd .. && rm -rf "./tmp"
71+
echo "All Done!"

0 commit comments

Comments
 (0)