@@ -6,12 +6,14 @@ APPDIR="$APP".AppDir
66SITE=" https://dl.google.com/android/repository/platform-tools-latest-linux.zip"
77ICON=" https://developer.android.com/static/images/brand/Android_Robot.png"
88APPIMAGETOOL=" https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
9+ SHARUN=" https://bin.ajam.dev/$( uname -m) /sharun"
10+ LIB4BIN=" https://raw.githubusercontent.com/VHSgunzo/sharun/refs/heads/main/lib4bin"
911
1012# CREATE DIRECTORIES AND DOWNLOAD THE ARCHIVE
1113[ -n " $APP " ] || exit 1
12- mkdir -p ./" $APP " /" $APPDIR " /usr && cd ./" $APP " /" $APPDIR " /usr || exit 1
14+ mkdir -p ./" $APP " /" $APPDIR " /shared && cd ./" $APP " /" $APPDIR " || exit 1
1315wget " $SITE " && unzip -q * .zip && rm -f ./* .zip || exit 1
14- mv ./platform-* ./bin && cd .. || exit 1
16+ mv ./platform-tools ./shared/ bin || exit 1
1517
1618# DESKTOP & ICON
1719cat >> ./Android-$APP .desktop << 'EOF '
@@ -25,20 +27,28 @@ Terminal=true
2527EOF
2628wget " $ICON " -O ./Android.png && ln -s ./Android.png ./.DirIcon
2729
30+ # BUNDLE ALL DEPENDENCIES
31+ wget " $SHARUN " -O ./sharun || exit 1
32+ wget " $LIB4BIN " -O ./lib4bin || exit 1
33+ chmod +x ./sharun ./lib4bin
34+
35+ HARD_LINKS=1 ./lib4bin ./shared/bin/* && rm -f ./lib4bin || exit 1
36+
2837# AppRun
2938cat >> ./AppRun << 'EOF '
3039#!/bin/sh
31- CURRENTDIR="$(dirname "$(readlink -f "$0")")"/usr/bin
40+ CURRENTDIR="$(dirname "$(readlink -f "$0")")"
3241UDEVNOTICE='No android udev rules detected, use "--getudev" to install'
3342UDEVREPO="https://github.com/M0Rf30/android-udev-rules.git"
3443cat /etc/udev/rules.d/*droid.rules >/dev/null 2>&1 && UDEVNOTICE=""
35- ARGV0="${ARGV0#./}"
36- export PATH="$CURRENTDIR:$PATH"
44+ BIN="${ARGV0#./}"
45+ unset ARGV0
46+ export PATH="$CURRENTDIR/bin:$PATH"
3747
3848_get_udev_rules() {
3949 if cat /etc/udev/rules.d/*droid.rules >/dev/null 2>&1; then
4050 echo "ERROR: udev rules are already installed!"
41- echo "Errors persisting with installed udev rules may be due to missing"
51+ echo "Errors persisting with installed udev rules may be due to missing"
4252 echo "udev rules for device or lack of permissions from device"
4353 exit 1
4454 fi
@@ -71,14 +81,15 @@ _get_udev_rules() {
7181
7282_get_symlinks() {
7383 BINDIR="${XDG_BIN_HOME:-$HOME/.local/bin}"
74- links="adb etc1tool fastboot hprof-conv make_f2fs make_f2fs_casefold mke2fs sqlite3"
84+ links="$(find "$CURRENTDIR"/shared/bin -maxdepth 1 -exec file {} \; \
85+ | awk -F":" '/ELF/ {print $1}' | xargs -I {} basename {} 2>/dev/null)"
7586 echo ""
7687 echo "This function will make wrapper symlinks in $BINDIR"
7788 echo "that will point to $APPIMAGE with the names:"
7889 echo "$links" | tr ' ' '\n'
7990 echo ""
8091 echo "Make sure there are not existing files $BINDIR with those names"
81- printf '\n%s' "Proceed with the symlink creation? (Y/n): "
92+ printf '\n%s' "Proceed with the symlink creation? (Y/n): "
8293 read -r yn
8394 if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then
8495 echo "Aborting..."
@@ -92,46 +103,41 @@ _get_symlinks() {
92103}
93104
94105# logic
95- case "$ARGV0" in
96- 'adb'|'etc1tool'|'fastboot'|'hprof-conv'|\
97- 'make_f2fs'|'make_f2fs_casefold'|'mke2fs'|'sqlite3')
98- "$CURRENTDIR/$ARGV0" "$@" || echo "$UDEVNOTICE"
106+ if [ -n "$BIN" ] && [ -e "$CURRENTDIR/bin/$BIN" ]; then
107+ "$CURRENTDIR/bin/$BIN" "$@" || echo "$UDEVNOTICE"
108+ elif [ -n "$1" ] && [ -e "$CURRENTDIR/bin/$1" ]; then
109+ option="$1"
110+ shift
111+ "$CURRENTDIR/bin/$option" "$@" || echo "$UDEVNOTICE"
112+ else
113+ case "$1" in
114+ '--getudev')
115+ _get_udev_rules
116+ ;;
117+ '--getlinks')
118+ _get_symlinks
99119 ;;
100120 *)
101- case $1 in
102- 'adb'|'etc1tool'|'fastboot'|'hprof-conv'|\
103- 'make_f2fs'|'make_f2fs_casefold'|'mke2fs'|'sqlite3')
104- option="$1"
105- shift
106- "$CURRENTDIR/$option" "$@" || echo "$UDEVNOTICE"
107- ;;
108- '--getudev')
109- _get_udev_rules
110- ;;
111- '--getlinks')
112- _get_symlinks
113- ;;
114- *)
115- echo ""
116- echo "USAGE: \"${APPIMAGE##*/} [ARGUMENT]\""
117- echo "EXAMPLE: \"${APPIMAGE##*/} adb shell\" to enter adb shell"
118- echo ""
119- echo "You can also make a symlink to $APPIMAGE named adb"
120- echo "and run the symlink to enter adb without typing ${APPIMAGE##*/}"
121- echo ""
122- echo 'use "--getlinks" if you want to make the symlinks automatically'
123- echo ""
124- exit 1
125- ;;
126- esac
127- ;;
128- esac
121+ echo ""
122+ echo "USAGE: \"${APPIMAGE##*/} [ARGUMENT]\""
123+ echo "EXAMPLE: \"${APPIMAGE##*/} adb shell\" to enter adb shell"
124+ echo ""
125+ echo "You can also make a symlink to $APPIMAGE named adb"
126+ echo "and run the symlink to enter adb without typing ${APPIMAGE##*/}"
127+ echo ""
128+ echo 'use "--getlinks" if you want to make the symlinks automatically'
129+ echo ""
130+ exit 1
131+ ;;
132+ esac
133+ fi
129134EOF
130135chmod a+x ./AppRun
131- export VERSION=" $( awk -F" =" ' /vision/ {print $2}' ./usr /bin/source.properties) "
136+ export VERSION=" $( awk -F" =" ' /vision/ {print $2}' ./shared /bin/source.properties) "
132137
133138# Do the thing!
134139cd .. && wget -q " $APPIMAGETOOL " -O appimagetool && chmod +x ./appimagetool
135- ./appimagetool --comp zstd --mksquashfs-opt -Xcompression-level --mksquashfs-opt 22 ./" $APPDIR " || exit 1
140+ ./appimagetool --comp zstd \
141+ --mksquashfs-opt -Xcompression-level --mksquashfs-opt 22 ./" $APPDIR " || exit 1
136142[ -n " $APP " ] && mv ./* .AppImage .. && cd .. && rm -rf " $APP " || exit 1
137143echo " All Done!"
0 commit comments