-
-
Save PedroHLC/606da5b1bc3a141fee30 to your computer and use it in GitHub Desktop.
Added ARChon as an external extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# archon.sh: Wrapper script for launching APK files with ARChon and chromeos-apk | |
# | |
# Author: Kevin MacMartin | |
# Released under the MIT license | |
# Version: 1.0 | |
# | |
# The directory to install APKs | |
[[ -z "$ARCHON_APKROOT" ]] && ARCHON_APKROOT='/tmp/archon' | |
# Don't allow variables set in the environment from here on out | |
set -o nounset | |
function create_apk_dir() { | |
# Create and enter the folder to contain the extracted APK | |
install -d "$ARCHON_APKROOT/$SUM" | |
pushd "$ARCHON_APKROOT/$SUM" >/dev/null | |
# Generate the APK folder using chromeos-apk | |
chromeos-apk -a --tablet "$1" >chromeos-apk.log | |
# Fix the "There is no message element for key extName" error | |
[[ $(grep -r 'appNotSupported') ]] && { | |
APPDIR=$(ls -1 --group-directories-first | head -n 1) | |
EXTNAME=$(cat "$APPDIR/manifest.json" \ | |
| grep '"name":' \ | |
| head -n 1 \ | |
| sed 's|[^"]*"name"[^"]*"||;s|".*||') | |
for msgfile in $(find "$APPDIR/_locales" -type f -name 'messages.json'); do | |
echo -e '{\n "extName": {\n "description": "'"$EXTNAME"'",\n "message": ""\n }\n}' > "$msgfile" | |
done | |
} | |
# Return to the original folder | |
popd >/dev/null | |
} | |
# Show usage information if the user attempts to run without an Android APK as input | |
[[ ! -f "$1" ]] && { | |
echo "Usage: $(grep -o -e "[^\/]*$" <<< "$0") [APK]" | |
exit 1 | |
} | |
# Store the md5sum of the APK so different versions won't overwrite eachother | |
SUM=$(md5sum "$1" | sed 's|\ .*||') | |
# Delete the existing apk directory if it doesn't contain exactly one folder | |
[[ -d "$ARCHON_APKROOT/$SUM" ]] \ | |
&& [[ ! $(find "$ARCHON_APKROOT/$SUM" -maxdepth 1 -mindepth 1 -type d | wc -l) = 1 ]] \ | |
&& rm -rf "$ARCHON_APKROOT/$SUM" | |
# If an app directory doesn't exist, create one and extract the APK using chromeos-apk | |
[[ ! -d "$ARCHON_APKROOT/$SUM" ]] && create_apk_dir "$(readlink -f "$1")" | |
# Evaluate the name of the directory containing the app | |
APPDIR=$(find "$ARCHON_APKROOT/$SUM" -maxdepth 1 -mindepth 1 -type d | sed 's|^.*/||') | |
# Remove the apk folder and exit with an error if an app directory doesn't exist | |
[[ -z "$APPDIR" ]] && { | |
echo 'Error: chromeos-apk failed to extract an app folder in "'"$ARCHON_APKROOT/$SUM"'"' | |
[[ -d "$ARCHON_APKROOT/$SUM" ]] && rm -rf "$ARCHON_APKROOT/$SUM" | |
exit 1 | |
} | |
# The common part of the Chromium launch command to launch the extracted APK using ARChon | |
EXE='chromium --user-data-dir='"$HOME"'/.config/archon --profile-directory='"$APPDIR"' --silent-launch' | |
# Launch the Android app | |
$EXE --load-and-launch-app="$ARCHON_APKROOT/$SUM/$APPDIR" > "$ARCHON_APKROOT/$SUM/run.log" & | |
sleep 1 | |
# Cleanup the non-functional XDG desktop file created by Chromium | |
XDGDESKTOP=$(ls "$HOME/.local/share/applications" | egrep 'chrome-.*-'"$APPDIR"'\.desktop') | |
[[ -n "$XDGDESKTOP" ]] && rm "$HOME/.local/share/applications/$XDGDESKTOP" | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maintainer: Kevin MacMartin <prurigro at gmail dot com> | |
pkgname=archon | |
pkgver=1.2 | |
pkgrel=6 | |
pkgdesc="Execute Android APKs" | |
arch=('i686' 'x86_64' 'armv7h') | |
url="https://bitbucket.org/vladikoff/archon" | |
license=('Apache' 'custom') | |
depends=('chromium' 'chromeos-apk-git') | |
makedepends=('git' 'openssl' 'coreutils') | |
options=('!strip') | |
install=${pkgname}.install | |
_pluginpath="usr/share/chromium/extensions" | |
_pluginver=38.4410.120.43 | |
# x86_64 has a newer version than armv7h or i686 | |
[[ "$CARCH" == "x86_64" ]] && pkgver=2.0.0 && _pluginver=41.4410.227.0 | |
# Determine the tag based on $CARCH | |
case $CARCH in | |
i686) _tag="x86_32" ;; | |
armv7h) _tag="ARM" ;; | |
*) _tag="$CARCH" ;; | |
esac | |
source=( | |
"git+${url}.git#tag=v${pkgver}-${_tag}" | |
"http://tools.android.com/recent/miscellaneousimprovements-1/android_icon_128.png" | |
"${pkgname}.desktop" | |
"${pkgname}.sh" | |
) | |
sha512sums=( | |
'SKIP' | |
'16c8aa6c9b27d3727f70d6326c736eccefe630bc3bf7a95ba11ea60acd5078d20fc9fe0991db50a4c4c97225d05cbc1c63267a1ba552aebe66b6f04f9ec70012' | |
'7b47e1f0253a375c510205572e1de17fe2de23f214b5a6dfa7467cda3e85be0bcf33bfea86c7b00f7096dddebe6e4bc49db31c04d0aaad474931d8623a9e1b9f' | |
'b772a42bbb362149ed7882564bde6bed77a3f703f627fa3aeadf3f53354459205a8faeccc4fd8626c1b76a5b6532bc45f4d6407306694306fc7a481de3cb8d28') | |
prepare() { | |
# Increase the application font size by 1.2 times (the default is a bit too small) | |
sed -i 's|window\.devicePixelRatio|1\.2\*window\.devicePixelRatio|' $pkgname/gen_{index,main}.min.js | |
} | |
build() { | |
cd "$srcdir" | |
chromium --pack-extension="$srcdir/$pkgname" | |
} | |
package() { | |
# Install the .desktop file, icon and launch script | |
install -Dm644 $pkgname.desktop "$pkgdir"/usr/share/applications/$pkgname.desktop | |
install -Dm644 android_icon_128.png "$pkgdir"/usr/share/pixmaps/$pkgname.png | |
install -Dm755 $pkgname.sh "$pkgdir"/usr/bin/$pkgname | |
# Install ARChon extension | |
install -d "$pkgdir/$_pluginpath" | |
install -m 755 "${srcdir}/$pkgname.crx" "$pkgdir/$_pluginpath/$pkgname.crx" | |
_pluginid=`openssl rsa -pubout -outform DER < "$srcdir/$pkgname.pem" | sha256sum | head -c32 | tr 0-9a-f a-p` | |
echo "{\"external_crx\": \"/$_pluginpath/$pkgname.crx\", \"external_version\": \"$_pluginver\"}" >> "$pkgdir/$_pluginpath/$_pluginid.json" | |
# Install links to the license files | |
install -d "$pkgdir"/usr/share/licenses/$pkgname | |
ln -s /opt/$pkgname/NOTICE.{html,txt} "$pkgdir"/usr/share/licenses/$pkgname/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment