new package: entr

This commit is contained in:
Steven Hollett 2020-07-31 07:39:03 -04:00 committed by Leonid Pliushch
parent 9c1635f1c3
commit 7161a0a459
3 changed files with 120 additions and 0 deletions

15
packages/entr/build.sh Normal file
View File

@ -0,0 +1,15 @@
TERMUX_PKG_HOMEPAGE=http://eradman.com/entrproject/
TERMUX_PKG_DESCRIPTION="Event Notify Test Runner - run arbitrary commands when files change"
TERMUX_PKG_LICENSE="ISC"
TERMUX_PKG_VERSION=4.6
TERMUX_PKG_SRCURL=http://ftp.debian.org/debian/pool/main/e/entr/entr_$TERMUX_PKG_VERSION.orig.tar.gz
TERMUX_PKG_SHA256=16de20820df4a38162354754487b1248c8711822c7342d2f6d4f28fbd4a38e6d
TERMUX_PKG_BUILD_IN_SRC=true
termux_step_configure() {
./configure
}
termux_step_make() {
make install
}

View File

@ -0,0 +1,79 @@
diff --git a/NEWS b/NEWS
index a97dcaa..355e10b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+= Next Release: 4.7
+
+ - Use system file descriptor limits when max_user_watches is not accessible
+
= Release History
== 4.6: July 1, 2020
diff --git a/entr.c b/entr.c
index 3316f47..ec3d569 100644
--- a/entr.c
+++ b/entr.c
@@ -105,6 +105,7 @@ static void watch_loop(int, char *[]);
int
main(int argc, char *argv[]) {
struct rlimit rl;
+ rlim_t max_watches;
int kq;
struct sigaction act;
int ttyfd;
@@ -155,14 +156,20 @@ main(int argc, char *argv[]) {
err(1, "Failed to set SIGCHLD handler");
getrlimit(RLIMIT_NOFILE, &rl);
+
#if defined(_LINUX_PORT)
- rl.rlim_cur = (rlim_t)fs_sysctl(INOTIFY_MAX_USER_WATCHES);
-#else
+ max_watches = (rlim_t)fs_sysctl(INOTIFY_MAX_USER_WATCHES);
+ if(max_watches > 0) {
+ rl.rlim_cur = max_watches;
+ goto rlim_set;
+ }
+#endif
/* raise soft limit */
rl.rlim_cur = min((rlim_t)sysconf(_SC_OPEN_MAX), rl.rlim_max);
if (setrlimit(RLIMIT_NOFILE, &rl) != 0)
err(1, "setrlimit cannot set rlim_cur to %d", (int)rl.rlim_cur);
-#endif
+
+rlim_set:
/* prevent interactive utilities from paging output */
setenv("PAGER", "/bin/cat", 0);
diff --git a/missing/kqueue_inotify.c b/missing/kqueue_inotify.c
index 3ddd064..9465d94 100644
--- a/missing/kqueue_inotify.c
+++ b/missing/kqueue_inotify.c
@@ -57,16 +57,21 @@ int
fs_sysctl(const int name) {
FILE *file;
char line[8];
- int value = 0;
+ int value;
switch(name) {
case INOTIFY_MAX_USER_WATCHES:
file = fopen("/proc/sys/fs/inotify/max_user_watches", "r");
- if (file == NULL || fgets(line, sizeof(line), file) == NULL)
- err(1, "max_user_watches");
- value = atoi(line);
- fclose(file);
+ if (file == NULL || fgets(line, sizeof(line), file) == NULL) {
+ /* failed to read max_user_watches; sometimes inaccessible on Android */
+ value = 0;
+ }
+ else
+ value = atoi(line);
+
+ if (file)
+ fclose(file);
break;
}
return value;

26
packages/entr/path.patch Normal file
View File

@ -0,0 +1,26 @@
diff --git a/entr.c b/entr.c
index 3316f47..10c590a 100644
--- a/entr.c
+++ b/entr.c
@@ -165,10 +165,10 @@ main(int argc, char *argv[]) {
#endif
/* prevent interactive utilities from paging output */
- setenv("PAGER", "/bin/cat", 0);
+ setenv("PAGER", "@TERMUX_PREFIX@/bin/cat", 0);
/* ensure a shell is available to use */
- setenv("SHELL", "/bin/sh", 0);
+ setenv("SHELL", "@TERMUX_PREFIX@/bin/sh", 0);
/* sequential scan may depend on a 0 at the end */
files = calloc(rl.rlim_cur+1, sizeof(WatchFile *));
@@ -446,7 +446,7 @@ run_utility(char *argv[]) {
if (pid == 0) {
if (clear_opt == 1)
- system("/usr/bin/clear");
+ system("@TERMUX_PREFIX@/bin/clear");
/* Set process group so subprocess can be signaled */
if (restart_opt == 1) {
setpgid(0, getpid());