Add termux-info tool (#422)

* Add termux-info tool

* Add more information to termux-info

* Resolve conflicts. Add comment and fix Typo.

* remove empty lines in output
This commit is contained in:
Oliver Schmidhauser 2017-04-09 00:07:06 +02:00 committed by Fredrik Fornwall
parent 9093c6b69e
commit 833973d1be
2 changed files with 55 additions and 2 deletions

View File

@ -1,6 +1,6 @@
TERMUX_PKG_HOMEPAGE=https://termux.com/
TERMUX_PKG_DESCRIPTION="Basic system tools for Termux"
TERMUX_PKG_VERSION=0.41
TERMUX_PKG_VERSION=0.42
TERMUX_PKG_PLATFORM_INDEPENDENT=yes
TERMUX_PKG_CONFFILES="etc/motd"
@ -18,7 +18,7 @@ termux_step_make_install () {
chmod +x $TERMUX_PREFIX/bin/$tool
done
cp -p $TERMUX_PKG_BUILDER_DIR/{dalvikvm,su,termux-fix-shebang,termux-reload-settings,termux-setup-storage,chsh,termux-open-url,termux-wake-lock,termux-wake-unlock,login,packages,termux-open} $TERMUX_PREFIX/bin/
cp -p $TERMUX_PKG_BUILDER_DIR/{dalvikvm,su,termux-fix-shebang,termux-reload-settings,termux-setup-storage,chsh,termux-open-url,termux-wake-lock,termux-wake-unlock,login,packages,termux-open,termux-info} $TERMUX_PREFIX/bin/
perl -p -i -e "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" $TERMUX_PREFIX/bin/dalvikvm
cp $TERMUX_PKG_BUILDER_DIR/motd $TERMUX_PREFIX/etc/motd

View File

@ -0,0 +1,53 @@
#!/data/data/com.termux/files/usr/bin/sh
if [ "$#" != "0" ]; then
echo 'usage: termux-info'
echo 'Provides information about Termux, and the current system. Helpful for debugging.'
exit
fi
version() {
if [ -e "$PREFIX/version" ]; then
cat "$PREFIX/version"
else
#Last version that didn't have a way to detect Termux version
echo '<=0.48'
fi
}
apps() {
pm list packages -i | grep com.termux
}
updates() {
apt update >/dev/null 2>&1
updatable=$(apt list --upgradable 2>/dev/null | tail -n +2)
if [ -z "$updatable" ];then
echo "All packages up to date"
else
echo "$updatable"
fi
}
output="Termux version:
$(version)
Installed Termux apps:
$(apps)
Updatable packages:
$(updates)
System information:
$(uname -a)
Termux-packages arch:
$(dpkg --print-architecture)
Android version:
$(getprop ro.build.version.release)
Device manufacturer:
$(getprop ro.product.manufacturer)
Device model:
$(getprop ro.product.model)"
echo "$output"
# Copy to clipboard (requires termux-api)
# use timeout in case termux-api is installed but the termux:api app is missing
echo "$output" | busybox timeout -t 3 termux-clipboard-set 2>/dev/null
busybox timeout -t 3 termux-toast "Information has been copied to the clipboard" 2>/dev/null
exit 0