From 819f92fefd204acf4e984ed4c8250ae94a5cd745 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Sat, 29 Aug 2020 11:58:04 +0300 Subject: [PATCH] htop: since v3.0.0 it can't work without /proc/stat, add a proper error description why and what to do --- packages/htop/build.sh | 1 + packages/htop/fix-missing-macros.patch | 18 ------------------ packages/htop/no-proc-stat.patch | 21 +++++++++++++++++++++ 3 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 packages/htop/no-proc-stat.patch diff --git a/packages/htop/build.sh b/packages/htop/build.sh index a66d62da7..2e6f7e14e 100644 --- a/packages/htop/build.sh +++ b/packages/htop/build.sh @@ -2,6 +2,7 @@ TERMUX_PKG_HOMEPAGE=https://htop.dev/ TERMUX_PKG_DESCRIPTION="Interactive process viewer for Linux" TERMUX_PKG_LICENSE="GPL-2.0" TERMUX_PKG_VERSION=3.0.0 +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://github.com/htop-dev/htop/archive/${TERMUX_PKG_VERSION}/htop-${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=1c0661f0ae5f4e2874da250b60cd515e4ac4c041583221adfe95f10e18d1a4e6 # htop checks setlocale() return value for UTF-8 support, so use libandroid-support. diff --git a/packages/htop/fix-missing-macros.patch b/packages/htop/fix-missing-macros.patch index 37b0e325f..20f5b353e 100644 --- a/packages/htop/fix-missing-macros.patch +++ b/packages/htop/fix-missing-macros.patch @@ -16,24 +16,6 @@ diff -uNr htop-2.1.0/linux/LinuxProcessList.c htop-2.1.0.mod/linux/LinuxProcessL /*{ #include "ProcessList.h" -@@ -241,7 +249,7 @@ - // Update CPU count: - FILE* file = fopen(PROCSTATFILE, "r"); - if (file == NULL) { -- CRT_fatalError("Cannot open " PROCSTATFILE); -+ return pl; - } - char buffer[PROC_LINE_LENGTH + 1]; - int cpus = -1; -@@ -966,7 +974,7 @@ - - FILE* file = fopen(PROCSTATFILE, "r"); - if (file == NULL) { -- CRT_fatalError("Cannot open " PROCSTATFILE); -+ return 0; - } - int cpus = this->super.cpuCount; - assert(cpus > 0); diff -uNr htop-2.1.0/Process.c htop-2.1.0.mod/Process.c --- htop-2.1.0/Process.c 2018-02-04 20:57:13.000000000 +0200 +++ htop-2.1.0.mod/Process.c 2018-03-05 17:59:16.522983619 +0200 diff --git a/packages/htop/no-proc-stat.patch b/packages/htop/no-proc-stat.patch new file mode 100644 index 000000000..6eb10be23 --- /dev/null +++ b/packages/htop/no-proc-stat.patch @@ -0,0 +1,21 @@ +diff -uNr htop-3.0.0/linux/LinuxProcessList.c htop-3.0.0.mod/linux/LinuxProcessList.c +--- htop-3.0.0/linux/LinuxProcessList.c 2020-08-27 02:36:56.000000000 +0300 ++++ htop-3.0.0.mod/linux/LinuxProcessList.c 2020-08-29 11:55:19.994514529 +0300 +@@ -265,7 +265,7 @@ + // Update CPU count: + file = fopen(PROCSTATFILE, "r"); + if (file == NULL) { +- CRT_fatalError("Cannot open " PROCSTATFILE); ++ CRT_fatalError("Cannot open '/proc/stat'.\nOn Android 8 and higher access to this file is restricted by SELinux.\nRoot your device and/or install Lineage OS in order to get 'htop' working properly.\n"); + } + int cpus = 0; + do { +@@ -1127,7 +1127,7 @@ + + FILE* file = fopen(PROCSTATFILE, "r"); + if (file == NULL) { +- CRT_fatalError("Cannot open " PROCSTATFILE); ++ CRT_fatalError("Cannot open '/proc/stat'.\nOn Android 8 and higher access to this file is restricted by SELinux.\nRoot your device and/or install Lineage OS in order to get 'htop' working properly.\n"); + } + int cpus = this->super.cpuCount; + assert(cpus > 0);