move from main repo: htop

htop v3.x requires root, SELinux permissive or Lineage OS ENG build in order
to work because access to /proc/stat is restricted.
This commit is contained in:
Leonid Pliushch 2020-09-02 15:37:16 +03:00 committed by Yaksh Bariya
parent 3a637ce71d
commit 478138f042
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
4 changed files with 109 additions and 0 deletions

View File

@ -0,0 +1,32 @@
From b992d52bcf8ff8c51c847cd4bbf33a7db441dbe9 Mon Sep 17 00:00:00 2001
From: Nathan Scott <nathans@redhat.com>
Date: Fri, 28 Aug 2020 16:57:21 +1000
Subject: [PATCH] Increae the size of sysfs power supply path buffers
Resolves https://github.com/htop-dev/htop/issues/15
---
linux/Battery.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/linux/Battery.c b/linux/Battery.c
index 4014a50..a8784da 100644
--- a/linux/Battery.c
+++ b/linux/Battery.c
@@ -107,7 +107,7 @@ static ACPresence procAcpiCheck() {
if (entryName[0] != 'A')
continue;
- char statePath[50];
+ char statePath[256];
xSnprintf((char *) statePath, sizeof statePath, "%s/%s/state", power_supplyPath, entryName);
FILE* file = fopen(statePath, "r");
if (!file) {
@@ -191,7 +191,7 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
if (!dirEntry)
break;
char* entryName = (char *) dirEntry->d_name;
- const char filePath[50];
+ const char filePath[256];
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName);
int fd1 = open(filePath, O_RDONLY);

View File

@ -0,0 +1,20 @@
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=3
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.
TERMUX_PKG_DEPENDS="libandroid-support, ncurses"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_RM_AFTER_INSTALL="share/applications share/pixmaps"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
ac_cv_lib_ncursesw6_addnwstr=yes
LIBS=-landroid-support
"
termux_step_pre_configure() {
./autogen.sh
}

View File

@ -0,0 +1,36 @@
diff -uNr htop-2.1.0/linux/LinuxProcessList.c htop-2.1.0.mod/linux/LinuxProcessList.c
--- htop-2.1.0/linux/LinuxProcessList.c 2018-02-04 20:57:13.000000000 +0200
+++ htop-2.1.0.mod/linux/LinuxProcessList.c 2018-03-05 17:57:46.901891199 +0200
@@ -37,6 +37,14 @@
#include <linux/taskstats.h>
#endif
+#ifndef major
+#define major(rdev) ((rdev)>>8)
+#endif
+
+#ifndef minor
+#define minor(rdev) ((rdev) & 0xff)
+#endif
+
/*{
#include "ProcessList.h"
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
@@ -29,6 +29,14 @@
#include <assert.h>
#include <math.h>
+#ifndef major
+#define major(rdev) ((rdev)>>8)
+#endif
+
+#ifndef minor
+#define minor(rdev) ((rdev) & 0xff)
+#endif
+
#ifdef __ANDROID__
#define SYS_ioprio_get __NR_ioprio_get
#define SYS_ioprio_set __NR_ioprio_set

View File

@ -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 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 in order to get 'htop' working properly.\n");
}
int cpus = this->super.cpuCount;
assert(cpus > 0);