diff --git a/packages/net-snmp/agent-mibgroup-host-data_access-swinst_apt.c.patch b/packages/net-snmp/agent-mibgroup-host-data_access-swinst_apt.c.patch new file mode 100644 index 000000000..bca01d46c --- /dev/null +++ b/packages/net-snmp/agent-mibgroup-host-data_access-swinst_apt.c.patch @@ -0,0 +1,11 @@ +--- a/agent/mibgroup/host/data_access/swinst_apt.c ++++ b/agent/mibgroup/host/data_access/swinst_apt.c +@@ -42,7 +42,7 @@ + void + netsnmp_swinst_arch_init(void) + { +- strlcpy(pkg_directory, "/var/lib/dpkg/info", sizeof(pkg_directory)); ++ strlcpy(pkg_directory, "@TERMUX_PREFIX@/var/lib/dpkg/info", sizeof(pkg_directory)); + snprintf(apt_fmt, SNMP_MAXBUF, "%%%d[^#]#%%%d[^#]#%%%d[^#]#%%%d[^#]#%%%d[^#]#%%%d[^#]#%%%ds", + SNMP_MAXBUF-1, SNMP_MAXBUF-1, SNMP_MAXBUF-1, SNMP_MAXBUF-1, + SNMP_MAXBUF-1, SNMP_MAXBUF-1, SNMP_MAXBUF-1); diff --git a/packages/net-snmp/agent-mibgroup-host-data_access-swinst_pkginfo.c.patch b/packages/net-snmp/agent-mibgroup-host-data_access-swinst_pkginfo.c.patch new file mode 100644 index 000000000..6d5a46924 --- /dev/null +++ b/packages/net-snmp/agent-mibgroup-host-data_access-swinst_pkginfo.c.patch @@ -0,0 +1,11 @@ +--- a/agent/mibgroup/host/data_access/swinst_pkginfo.c ++++ b/agent/mibgroup/host/data_access/swinst_pkginfo.c +@@ -68,7 +68,7 @@ + #elif defined(freebsd2) || defined(openbsd) + snprintf( pkg_directory, SNMP_MAXPATH, "/var/db/pkg" ); + #elif defined(linux) +- snprintf( pkg_directory, SNMP_MAXPATH, "/var/cache/hrmib" ); ++ snprintf( pkg_directory, SNMP_MAXPATH, "@TERMUX_PREFIX@/var/cache/hrmib" ); + #else + pkg_directory[0] = '\0'; + snmp_log( LOG_ERR, "SWInst: No package directory\n" ); diff --git a/packages/net-snmp/agent-mibgroup-host-hr_filesys.c.patch b/packages/net-snmp/agent-mibgroup-host-hr_filesys.c.patch new file mode 100644 index 000000000..0dc9d7fc2 --- /dev/null +++ b/packages/net-snmp/agent-mibgroup-host-hr_filesys.c.patch @@ -0,0 +1,11 @@ +--- a/agent/mibgroup/host/hr_filesys.c ++++ b/agent/mibgroup/host/hr_filesys.c +@@ -892,7 +892,7 @@ + if (cp1 == NULL) + cp1 = filesys; + +- if ((dump_fp = fopen("/etc/dumpdates", "r")) == NULL) ++ if ((dump_fp = fopen("@TERMUX_PREFIX@/etc/dumpdates", "r")) == NULL) + return date_n_time(NULL, length); + + while (fgets(line, sizeof(line), dump_fp) != NULL) { diff --git a/packages/net-snmp/agent-mibgroup-host-hr_swinst.c.patch b/packages/net-snmp/agent-mibgroup-host-hr_swinst.c.patch new file mode 100644 index 000000000..85a614413 --- /dev/null +++ b/packages/net-snmp/agent-mibgroup-host-hr_swinst.c.patch @@ -0,0 +1,11 @@ +--- a/agent/mibgroup/host/hr_swinst.c ++++ b/agent/mibgroup/host/hr_swinst.c +@@ -193,7 +193,7 @@ + #define _PATH_HRSW_directory "/var/db/pkg" + #endif + #if defined(linux) && !defined(HAVE_LIBRPM) +-#define _PATH_HRSW_directory "/var/cache/hrmib" ++#define _PATH_HRSW_directory "@TERMUX_PREFIX@/var/cache/hrmib" + #endif + + void diff --git a/packages/net-snmp/agent-mibgroup-host-hrh_filesys.c.patch b/packages/net-snmp/agent-mibgroup-host-hrh_filesys.c.patch new file mode 100644 index 000000000..e016841d6 --- /dev/null +++ b/packages/net-snmp/agent-mibgroup-host-hrh_filesys.c.patch @@ -0,0 +1,11 @@ +--- a/agent/mibgroup/host/hrh_filesys.c ++++ b/agent/mibgroup/host/hrh_filesys.c +@@ -338,7 +338,7 @@ + if (cp1 == NULL) + cp1 = filesys; + +- if ((dump_fp = fopen("/etc/dumpdates", "r")) == NULL) ++ if ((dump_fp = fopen("@TERMUX_PREFIX@/etc/dumpdates", "r")) == NULL) + return date_n_time(NULL, length); + + while (fgets(line, sizeof(line), dump_fp) != NULL) { diff --git a/packages/net-snmp/agent-mibgroup-if-mib-data_access-interface_linux.c.patch b/packages/net-snmp/agent-mibgroup-if-mib-data_access-interface_linux.c.patch new file mode 100644 index 000000000..7d1b52c7b --- /dev/null +++ b/packages/net-snmp/agent-mibgroup-if-mib-data_access-interface_linux.c.patch @@ -0,0 +1,13 @@ +--- a/agent/mibgroup/if-mib/data_access/interface_linux.c ++++ b/agent/mibgroup/if-mib/data_access/interface_linux.c +@@ -10,6 +10,10 @@ + #include + #include "interface_private.h" + ++#ifdef __ANDROID__ ++typedef unsigned short ushort; ++#endif ++ + netsnmp_feature_require(fd_event_manager); + netsnmp_feature_require(delete_prefix_info); + netsnmp_feature_require(create_prefix_info); diff --git a/packages/net-snmp/agent-mibgroup-ip-mib-data_access-ipaddress_linux.c.patch b/packages/net-snmp/agent-mibgroup-ip-mib-data_access-ipaddress_linux.c.patch new file mode 100644 index 000000000..9a0c06aae --- /dev/null +++ b/packages/net-snmp/agent-mibgroup-ip-mib-data_access-ipaddress_linux.c.patch @@ -0,0 +1,13 @@ +--- a/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c ++++ b/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c +@@ -21,6 +21,10 @@ + #include + #include + ++#ifdef __ANDROID__ ++typedef unsigned long ulong; ++#endif ++ + netsnmp_feature_require(prefix_info); + netsnmp_feature_require(find_prefix_info); + diff --git a/packages/net-snmp/apps-encode_keychange.c.patch b/packages/net-snmp/apps-encode_keychange.c.patch new file mode 100644 index 000000000..5bc315b51 --- /dev/null +++ b/packages/net-snmp/apps-encode_keychange.c.patch @@ -0,0 +1,10 @@ +--- a/apps/encode_keychange.c ++++ b/apps/encode_keychange.c +@@ -95,6 +95,7 @@ + int snmp_ttyecho(const int fd, const int echo); + char *snmp_getpassphrase(const char *prompt, int fvisible); + ++#undef HAVE_GETPASS + #if defined(HAVE__CPUTS) && defined(HAVE__GETCH) + #include + #include diff --git a/packages/net-snmp/apps-snmpnetstat-main.c.patch b/packages/net-snmp/apps-snmpnetstat-main.c.patch new file mode 100644 index 000000000..040547e9f --- /dev/null +++ b/packages/net-snmp/apps-snmpnetstat-main.c.patch @@ -0,0 +1,17 @@ +--- a/apps/snmpnetstat/main.c ++++ b/apps/snmpnetstat/main.c +@@ -57,6 +57,14 @@ + #include "winstub.h" + #endif + ++#if defined __ANDROID__ && __ANDROID_API__ < 28 ++#define getprotoent() (NULL) ++#define sethostent(s) ((void)0) ++#define setnetent(s) ((void)0) ++#define setprotoent(s) ((void)0) ++#define endprotoent() ((void)0) ++#endif ++ + int aflag; /* show all sockets (including servers) */ + int bflag; /* show bytes instead of packets */ + int dflag; /* show i/f dropped packets */ diff --git a/packages/net-snmp/build.sh b/packages/net-snmp/build.sh new file mode 100644 index 000000000..da8d1232c --- /dev/null +++ b/packages/net-snmp/build.sh @@ -0,0 +1,26 @@ +TERMUX_PKG_HOMEPAGE=http://www.net-snmp.org/ +TERMUX_PKG_DESCRIPTION="Various tools relating to the Simple Network Management Protocol" +# Licenses: HPND, BSD 3-Clause, MIT +TERMUX_PKG_LICENSE="custom" +TERMUX_PKG_LICENSE_FILE="COPYING" +TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_VERSION=5.9.1 +TERMUX_PKG_SRCURL=https://github.com/net-snmp/net-snmp/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz +TERMUX_PKG_SHA256=bdff5fe0915369971e4c7f8e43283fa5fdd08785c7d3b61431465562112d86e7 +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" +--with-agentx-socket=$TERMUX_PREFIX/var/agentx/master +--with-default-snmp-version=3 +--with-logfile=$TERMUX_PREFIX/var/log/net-snmpd.log +--with-mnttab=$TERMUX_PREFIX/etc/mtab +--with-persistent-directory=$TERMUX_PREFIX/var/lib/net-snmp +--with-sys-contact=root@localhost +--with-sys-location=Unknown +--with-temp-file-pattern=$TERMUX_PREFIX/tmp/snmpdXXXXXX +ac_cv_path_LPSTAT_PATH=$TERMUX_PREFIX/bin/lpstat +" + +termux_step_pre_configure() { + if [ $TERMUX_ARCH = "x86_64" ]; then + CPPFLAGS+=" -DOPENSSL_NO_INLINE_ASM" + fi +} diff --git a/packages/net-snmp/config.sub.patch b/packages/net-snmp/config.sub.patch new file mode 100644 index 000000000..6300b6c24 --- /dev/null +++ b/packages/net-snmp/config.sub.patch @@ -0,0 +1,41 @@ +--- a/config.sub ++++ b/config.sub +@@ -247,10 +247,11 @@ + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ ++ | aarch64 \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ +- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ ++ | arc | arm | arm[bl]e | arme[lb] | armv* | avr | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ +@@ -301,7 +302,7 @@ + | ubicom32 \ + | v850 | v850e \ + | we32k \ +- | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ ++ | x86 | x86_64 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; +@@ -339,6 +340,7 @@ + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ ++ | aarch64-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ +@@ -1300,7 +1302,7 @@ + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. +- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ ++ -gnu* | -android* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ diff --git a/packages/net-snmp/include-net-snmp-library-types.h.patch b/packages/net-snmp/include-net-snmp-library-types.h.patch new file mode 100644 index 000000000..9af08157c --- /dev/null +++ b/packages/net-snmp/include-net-snmp-library-types.h.patch @@ -0,0 +1,13 @@ +--- a/include/net-snmp/library/types.h ++++ b/include/net-snmp/library/types.h +@@ -6,6 +6,10 @@ + #endif + + ++#ifdef __ANDROID__ ++#include ++#endif ++ + #include + + diff --git a/packages/net-snmp/include-net-snmp-session_api.h.patch b/packages/net-snmp/include-net-snmp-session_api.h.patch new file mode 100644 index 000000000..205533535 --- /dev/null +++ b/packages/net-snmp/include-net-snmp-session_api.h.patch @@ -0,0 +1,13 @@ +--- a/include/net-snmp/session_api.h ++++ b/include/net-snmp/session_api.h +@@ -17,6 +17,10 @@ + * including sending and receiving requests. + */ + ++#ifdef __ANDROID__ ++#include ++#endif ++ + #include + + #ifdef __cplusplus