2019-11-13 15:38:40 +01:00
|
|
|
#!/bin/bash
|
2017-04-09 00:07:06 +02:00
|
|
|
|
2021-12-15 19:16:31 +01:00
|
|
|
TERMUX_PACKAGE_FORMAT="@TERMUX_PACKAGE_FORMAT@"
|
|
|
|
|
2017-04-09 00:07:06 +02:00
|
|
|
if [ "$#" != "0" ]; then
|
2017-11-21 05:59:47 +01:00
|
|
|
echo 'usage: termux-info'
|
|
|
|
echo 'Provides information about Termux, and the current system. Helpful for debugging.'
|
|
|
|
exit
|
2017-04-09 00:07:06 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
updates() {
|
2019-11-13 15:38:40 +01:00
|
|
|
local updatable
|
|
|
|
|
|
|
|
if [ "$(id -u)" = "0" ]; then
|
|
|
|
echo "Running as root. Cannot check package updates."
|
2017-04-09 00:07:06 +02:00
|
|
|
else
|
2021-12-15 19:16:31 +01:00
|
|
|
if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ]; then
|
|
|
|
pacman -Sy >/dev/null 2>&1
|
|
|
|
updatable=$(pacman -Qeu)
|
|
|
|
else
|
|
|
|
apt update >/dev/null 2>&1
|
|
|
|
updatable=$(apt list --upgradable 2>/dev/null | tail -n +2)
|
|
|
|
fi
|
2019-11-13 15:38:40 +01:00
|
|
|
|
|
|
|
if [ -z "$updatable" ];then
|
|
|
|
echo "All packages up to date"
|
|
|
|
else
|
|
|
|
echo "$updatable"
|
|
|
|
fi
|
2017-04-09 00:07:06 +02:00
|
|
|
fi
|
|
|
|
}
|
2017-11-21 05:59:47 +01:00
|
|
|
|
2021-12-15 19:16:31 +01:00
|
|
|
repo_subscriptions_apt() {
|
2019-11-13 15:38:40 +01:00
|
|
|
local main_sources
|
|
|
|
main_sources=$(grep -P '^\s*deb\s' "@TERMUX_PREFIX@/etc/apt/sources.list")
|
|
|
|
|
|
|
|
if [ -n "$main_sources" ]; then
|
|
|
|
echo "# sources.list"
|
|
|
|
echo "$main_sources"
|
|
|
|
fi
|
|
|
|
|
2021-10-13 13:14:32 +02:00
|
|
|
if [ -d "@TERMUX_PREFIX@/etc/apt/sources.list.d" ]; then
|
|
|
|
local filename repo_package supl_sources
|
|
|
|
while read -r filename; do
|
|
|
|
repo_package=$(dpkg -S "$filename" 2>/dev/null | cut -d : -f 1)
|
|
|
|
supl_sources=$(grep -P '^\s*deb\s' "$filename")
|
2019-11-13 15:38:40 +01:00
|
|
|
|
2021-10-13 13:14:32 +02:00
|
|
|
if [ -n "$supl_sources" ]; then
|
|
|
|
if [ -n "$repo_package" ]; then
|
|
|
|
echo "# $repo_package (sources.list.d/$(basename "$filename"))"
|
|
|
|
else
|
|
|
|
echo "# sources.list.d/$(basename "$filename")"
|
|
|
|
fi
|
|
|
|
echo "$supl_sources"
|
2019-11-13 15:38:40 +01:00
|
|
|
fi
|
2021-10-13 13:14:32 +02:00
|
|
|
done < <(find "@TERMUX_PREFIX@/etc/apt/sources.list.d" -maxdepth 1 ! -type d)
|
|
|
|
fi
|
2019-11-13 15:38:40 +01:00
|
|
|
}
|
|
|
|
|
2021-12-15 19:16:31 +01:00
|
|
|
repo_subscriptions_pacman() {
|
|
|
|
local conf
|
|
|
|
conf="@TERMUX_PREFIX@/etc/pacman.conf"
|
|
|
|
|
|
|
|
if [[ -f $conf ]]; then
|
|
|
|
echo "# $conf"
|
|
|
|
for i in $(pacman-conf -l); do
|
|
|
|
pacman-conf | grep "$i"
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "$conf file not found"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-03-20 14:46:44 +01:00
|
|
|
output=""
|
|
|
|
|
|
|
|
if [ -n "$TERMUX_VERSION" ]; then
|
|
|
|
# Application version is exported in Termux v0.107 or higher only.
|
|
|
|
output+="Application version:
|
|
|
|
$TERMUX_VERSION
|
|
|
|
"
|
2021-09-17 15:17:53 +02:00
|
|
|
else
|
|
|
|
output+="Application version:
|
|
|
|
unsupported
|
|
|
|
"
|
2021-03-20 14:46:44 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
output+="Packages CPU architecture:
|
2021-12-15 19:16:31 +01:00
|
|
|
$(
|
|
|
|
if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ]; then
|
|
|
|
pacman-conf | grep Architecture | sed 's/Architecture = //g'
|
|
|
|
else
|
|
|
|
dpkg --print-architecture
|
|
|
|
fi
|
|
|
|
)
|
2019-11-13 15:38:40 +01:00
|
|
|
Subscribed repositories:
|
2021-12-15 19:16:31 +01:00
|
|
|
$(
|
|
|
|
if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ]; then
|
|
|
|
repo_subscriptions_pacman
|
|
|
|
else
|
|
|
|
repo_subscriptions_apt
|
|
|
|
fi
|
|
|
|
)
|
2019-11-13 15:38:40 +01:00
|
|
|
Updatable packages:
|
|
|
|
$(updates)
|
2017-04-09 00:07:06 +02:00
|
|
|
Android version:
|
|
|
|
$(getprop ro.build.version.release)
|
2019-11-13 15:38:40 +01:00
|
|
|
Kernel build information:
|
|
|
|
$(uname -a)
|
2017-04-09 00:07:06 +02:00
|
|
|
Device manufacturer:
|
|
|
|
$(getprop ro.product.manufacturer)
|
|
|
|
Device model:
|
|
|
|
$(getprop ro.product.model)"
|
|
|
|
echo "$output"
|
2019-11-13 15:38:40 +01:00
|
|
|
|
|
|
|
if [ -n "$(command -v termux-clipboard-set)" ]; then
|
|
|
|
# Copy to clipboard (requires termux-api)
|
|
|
|
# use timeout in case termux-api is installed but the termux:api app is missing
|
|
|
|
echo "$output" | timeout 3 termux-clipboard-set 2>/dev/null
|
|
|
|
timeout 3 termux-toast "Information has been copied to the clipboard" 2>/dev/null
|
|
|
|
fi
|
|
|
|
|
2017-04-09 00:07:06 +02:00
|
|
|
exit 0
|