1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-31 05:41:08 +00:00

misc/hxtools: update the port to the latest version 20230411

- COMPAT_PROC is now respected when accessing linprocfs(5) on
  FreeBSD which allows us to drop all corresponding patches;
  while /compat/linux is sensible default, follow ${LINUXBASE}
- checkbrack program had been rewritten from Perl to C++, but
  still listed on the `dist_bin_SCRIPTS' (notified upstream)
- Unfortunately, one of the useful utilities, cctypeinfo, had
  been removed as the author believes that all those strange
  exotic architectures are practically irrelevant now due to
  architecture consolidation in the market :(

Reported by:	portscout
This commit is contained in:
Alexey Dokuchaev 2023-09-15 10:22:16 +00:00
parent 2cf1aff496
commit 89f83f2095
14 changed files with 12 additions and 406 deletions

View File

@ -1,5 +1,5 @@
PORTNAME= hxtools
PORTVERSION= 20221120
PORTVERSION= 20230411
CATEGORIES= misc
MASTER_SITES= http://inai.de/files/hxtools/
@ -17,7 +17,7 @@ SHEBANG_FILES= data/hxtools_bashrc.bash data/hxtools_profile.bash \
examples/git-deconstruct examples/rc4 sadmin/hxnetload \
sadmin/ldif-duplicate-attrs sadmin/ldif-leading-spaces \
sadmin/logontime sadmin/pmap_dirty sadmin/recursive_lower \
sadmin/vcsaview sdevel/checkbrack sdevel/cwdiff \
sadmin/vcsaview sdevel/cwdiff \
sdevel/diff2php sdevel/doxygen-kerneldoc-filter \
sdevel/git-author-stat sdevel/git-blame-stats \
sdevel/git-forest sdevel/git-revert-stats \
@ -37,8 +37,15 @@ CONFLICTS_INSTALL= grx psptoolchain-pspsdk-stage2 # bin/bin2c
OPTIONS_DEFINE= DOCS EXAMPLES
post-patch:
@${REINPLACE_CMD} -e '/COMPAT_PROC/s,/compat/linux,${LINUXBASE},' \
${WRKSRC}/${CONFIGURE_SCRIPT}
@${REINPLACE_CMD} -E '/COMPAT_PROC ?=/s,"","${LINUXBASE}",' \
${WRKSRC}/sadmin/hxnetload \
${WRKSRC}/sadmin/pmap_dirty \
${WRKSRC}/sdevel/paddrspacesize
@${REINPLACE_CMD} -E 's,(/usr)?/bin,${LOCALBASE}/bin,g' \
${WRKSRC}/sadmin/su1
@${REINPLACE_CMD} -e '/checkbrack \\/d' ${WRKSRC}/sdevel/Makefile.in
post-install-DOCS-on:
@${MKDIR} ${STAGEDIR}${DOCSDIR}

View File

@ -1,3 +1,3 @@
TIMESTAMP = 1668943703
SHA256 (hxtools-20221120.tar.zst) = 8ab7337130cc55063a33964231bc5c7f253613da068b43555043ed06eef6d6d0
SIZE (hxtools-20221120.tar.zst) = 202850
TIMESTAMP = 1681210008
SHA256 (hxtools-20230411.tar.zst) = 15266562661b339e054ab1e4f1830bd1ae43faf151401075e3b7d1fc788a10f7
SIZE (hxtools-20230411.tar.zst) = 203185

View File

@ -1,23 +0,0 @@
--- sadmin/hxnetload.orig 2020-07-12 09:44:16 UTC
+++ sadmin/hxnetload
@@ -28,11 +28,11 @@ else
fi;
while :; do
- cat /proc/net/dev | grep " $1" | cut -f 2 -d:;
+ cat /compat/linux/proc/net/dev | grep " $1" | cut -f 2 -d:;
"$sleeper" $wait;
done | perl -pe '$|=1;s/.*://' | while read rxcnt rxpkt c d e f g h txcnt txpkt; do
if [ "$all" != "" ]; then
- now="`cat /proc/uptime | cut -f 1 -d " " | sed s/"\."//g`";
+ now="`cat /compat/linux/proc/uptime | cut -f 1 -d " " | sed s/"\."//g`";
[ $[$now-$oldtm] -eq 0 ] && continue;
rxbytes=$[($rxcnt-$oldrx)*100/($now-$oldtm)];
rxint=$[$rxbytes/1024];
@@ -48,5 +48,5 @@ done | perl -pe '$|=1;s/.*://' | while read rxcnt rxpk
all=$[$rxcnt+$txcnt];
oldrx=$rxcnt;
oldtx=$txcnt;
- oldtm="`cat /proc/uptime | cut -f 1 -d " " | sed s/"\."//g`";
+ oldtm="`cat /compat/linux/proc/uptime | cut -f 1 -d " " | sed s/"\."//g`";
done;

View File

@ -1,57 +0,0 @@
--- sadmin/ofl.c.orig 2020-07-12 09:44:16 UTC
+++ sadmin/ofl.c
@@ -42,7 +42,7 @@ static const char *ofl_comm(pid_t pid, char *buf, size
const char *p;
ssize_t ret;
- snprintf(src, sizeof(src), "/proc/%u/exe", (unsigned int)pid);
+ snprintf(src, sizeof(src), "/compat/linux/proc/%u/exe", (unsigned int)pid);
ret = readlink(src, dst, sizeof(dst) - 1);
if (ret < 0) {
*buf = '\0';
@@ -227,7 +227,7 @@ static bool ofl(const char *mnt, unsigned int signum)
char tmp[256];
struct HXdir *dir;
- dir = HXdir_open("/proc");
+ dir = HXdir_open("/compat/linux/proc");
if (dir == NULL)
return false;
while ((de = HXdir_read(dir)) != NULL) {
@@ -236,30 +236,30 @@ static bool ofl(const char *mnt, unsigned int signum)
data.pid = strtoul(de, NULL, 0);
if (data.pid == 0)
continue;
- snprintf(tmp, sizeof(tmp), "/proc/%s", de);
+ snprintf(tmp, sizeof(tmp), "/compat/linux/proc/%s", de);
if (lstat(tmp, &data.sb) < 0 || !S_ISDIR(data.sb.st_mode))
continue;
/* Program map */
- snprintf(tmp, sizeof(tmp), "/proc/%s/maps", de);
+ snprintf(tmp, sizeof(tmp), "/compat/linux/proc/%s/maps", de);
if (ofl_pmap(mnt, tmp, &data))
continue;
/* Basic links */
data.check = true;
- snprintf(tmp, sizeof(tmp), "/proc/%s/root", de);
+ snprintf(tmp, sizeof(tmp), "/compat/linux/proc/%s/root", de);
if (ofl_one(mnt, tmp, &data))
continue;
- snprintf(tmp, sizeof(tmp), "/proc/%s/cwd", de);
+ snprintf(tmp, sizeof(tmp), "/compat/linux/proc/%s/cwd", de);
if (ofl_one(mnt, tmp, &data))
continue;
- snprintf(tmp, sizeof(tmp), "/proc/%s/exe", de);
+ snprintf(tmp, sizeof(tmp), "/compat/linux/proc/%s/exe", de);
if (ofl_one(mnt, tmp, &data))
continue;
/* All file descriptors */
data.check = false;
- snprintf(tmp, sizeof(tmp), "/proc/%s/task", de);
+ snprintf(tmp, sizeof(tmp), "/compat/linux/proc/%s/task", de);
ofl_task(mnt, tmp, &data);
}

View File

@ -1,32 +0,0 @@
--- sadmin/pmap_dirty.orig 2020-07-12 09:44:16 UTC
+++ sadmin/pmap_dirty
@@ -25,9 +25,9 @@ my %total_counter;
if (scalar(@ARGV) == 0) {
@ARGV = sort { $a <=> $b } map {
- $_ = ($_ =~ m{^/proc/(\d+)$})[0];
+ $_ = ($_ =~ m{^/compat/linux/proc/(\d+)$})[0];
(!defined($_) || $_ eq "") ? () : $_
- } glob("/proc/*");
+ } glob("/compat/linux/proc/*");
}
&print_one();
@@ -35,7 +35,7 @@ if (scalar(@ARGV) == 0) {
foreach my $pid (@ARGV) {
my $proc_name;
my $fh;
- open($fh, "< /proc/$pid/smaps");
+ open($fh, "< /compat/linux/proc/$pid/smaps");
my %counter = (
Private_Dirty => 0,
@@ -50,7 +50,7 @@ foreach my $pid (@ARGV) {
}
close $fh;
- if (open($fh, "</proc/$pid/stat")) {
+ if (open($fh, "</compat/linux/proc/$pid/stat")) {
($proc_name) = (<$fh> =~ /^.*?\((.*)\)/);
close $fh;
}

View File

@ -1,20 +0,0 @@
--- sadmin/proc_iomem_count.c.orig 2020-07-12 09:44:16 UTC
+++ sadmin/proc_iomem_count.c
@@ -17,7 +17,7 @@
static int main2(int argc, const char **argv)
{
- const char *file = "/proc/iomem";
+ const char *file = "/compat/linux/proc/iomem";
uint64_t start, end;
hxmc_t *ln = NULL;
char *e;
@@ -28,7 +28,7 @@ static int main2(int argc, const char **argv)
fp = fopen(file, "r");
if (fp == NULL) {
- fprintf(stderr, "fopen: /proc/iomem: %s\n", strerror(errno));
+ fprintf(stderr, "fopen: /compat/linux/proc/iomem: %s\n", strerror(errno));
return EXIT_FAILURE;
}

View File

@ -1,41 +0,0 @@
--- sadmin/psthreads.c.orig 2020-07-12 09:44:16 UTC
+++ sadmin/psthreads.c
@@ -141,15 +141,15 @@ static struct kps_proc_data *kps_proc_read_one(unsigne
HXlist_init(&task->process_children);
task->cmdlen = 0;
- snprintf(buf, sizeof(buf), "/proc/%u/cmdline", pid);
+ snprintf(buf, sizeof(buf), "/compat/linux/proc/%u/cmdline", pid);
if ((fd = open(buf, O_RDONLY)) >= 0)
kps_read_cmdline(task, fd);
- snprintf(buf, sizeof(buf), "/proc/%u/status", pid);
+ snprintf(buf, sizeof(buf), "/compat/linux/proc/%u/status", pid);
if ((fp = fopen(buf, "r")) != NULL)
kps_read_status(task, fp);
- snprintf(buf, sizeof(buf), "/proc/%u/stat", pid);
+ snprintf(buf, sizeof(buf), "/compat/linux/proc/%u/stat", pid);
if ((fp = fopen(buf, "r")) != NULL)
kps_read_stat(task, fp);
@@ -162,8 +162,8 @@ static void kps_proc_read(struct HXmap *tree)
char buf[64];
struct HXdir *dproc, *dthr;
- if ((dproc = HXdir_open("/proc")) == NULL) {
- fprintf(stderr, "Could not open /proc: %s\n", strerror(errno));
+ if ((dproc = HXdir_open("/compat/linux/proc")) == NULL) {
+ fprintf(stderr, "Could not open /compat/linux/proc: %s\n", strerror(errno));
return;
}
@@ -175,7 +175,7 @@ static void kps_proc_read(struct HXmap *tree)
if (end == dentry || *end != '\0')
continue;
- snprintf(buf, sizeof(buf), "/proc/%u/task", tgid);
+ snprintf(buf, sizeof(buf), "/compat/linux/proc/%u/task", tgid);
if ((dthr = HXdir_open(buf)) == NULL) {
fprintf(stderr, "Could not open %s: %s\n", buf, strerror(errno));
continue;

View File

@ -22,29 +22,3 @@
HXOPT_AUTOHELP,
HXOPT_TABLEEND,
};
@@ -181,8 +185,10 @@ static int main2(int argc, const char **argv)
setutxent();
pututxline(&entry);
}
+#if 0
if (Opt.op_wtmp)
updwtmpx(Opt.fwtmp, &entry);
+#endif
if (Opt.op_lastlog)
update_lastlog(Opt.flastlog, &entry);
}
@@ -193,11 +199,13 @@ static int main2(int argc, const char **argv)
setutxent();
pututxline(&entry);
}
+#if 0
if (Opt.op_wtmp)
updwtmpx(Opt.fwtmp, &entry);
+#endif
}
- endutent();
+ endutxent();
return EXIT_SUCCESS;
}

View File

@ -1,11 +0,0 @@
--- sadmin/xfs_irecover.c.orig 2020-07-12 09:44:16 UTC
+++ sadmin/xfs_irecover.c
@@ -42,7 +42,7 @@
#include <libHX/proc.h>
#include <libHX/string.h>
#include <arpa/inet.h>
-#include <linux/types.h>
+#include <infiniband/types.h>
struct work_info {
char *device;

View File

@ -1,30 +0,0 @@
--- sdevel/cctypeinfo.c.orig 2020-07-12 09:44:16 UTC
+++ sdevel/cctypeinfo.c
@@ -6,6 +6,7 @@
* modify it under the terms of the WTF Public License version 2 or
* (at your option) any later version.
*/
+#include <sys/socket.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -61,9 +62,6 @@ p(intptr_t);
p(wchar_t);
p(size_t);
p(off_t);
-#ifdef HAVE_LOFF_T
-p(loff_t)
-#endif
p(uint8_t);
p(uint16_t);
p(uint32_t);
@@ -98,9 +96,6 @@ int main(void)
t(size_t);
t(wchar_t);
t(off_t);
-#ifdef HAVE_LOFF_T
- t(loff_t);
-#endif
t(uint8_t);
t(uint16_t);
t(uint32_t);

View File

@ -1,11 +0,0 @@
--- sdevel/paddrspacesize.orig 2020-07-12 09:44:16 UTC
+++ sdevel/paddrspacesize
@@ -18,7 +18,7 @@ foreach my $line (@list) {
my($pid, $reset) = ($line =~ /^\s*(\d+)\s+(.*)/);
my $bitness = 0;
- if (!open(FH, "</proc/$pid/maps")) {
+ if (!open(FH, "</compat/linux/proc/$pid/maps")) {
next;
}

View File

@ -1,115 +0,0 @@
--- smm/hcdplay.c.orig 2020-07-12 09:44:16 UTC
+++ smm/hcdplay.c
@@ -15,16 +15,18 @@
#include <unistd.h>
#include <libHX/option.h>
#include <sys/ioctl.h>
-#include <linux/cdrom.h>
-#define DEFAULT_ROM "/dev/sr0"
+#include <sys/cdio.h>
+#define DEFAULT_ROM "/dev/cd0"
static char *cdev;
static unsigned int dump_toc, do_start, do_pause, do_resume;
-static unsigned int do_play, do_stop, do_eject;
+static unsigned int do_play, do_stop, do_eject, do_close;
static bool cdp_get_options(int *argc, const char ***argv)
{
static const struct HXoption option_table[] = {
+ {.sh = 'C', .ln = "close", .type = HXTYPE_NONE, .ptr = &do_close,
+ .help = "Close the CD-ROM"},
{.sh = 'D', .ln = "device", .type = HXTYPE_STRING, .ptr = &cdev,
.help = "CD-ROM device path", .htyp = "FILE"},
{.sh = 'E', .ln = "eject", .type = HXTYPE_NONE, .ptr = &do_eject,
@@ -56,7 +58,7 @@ static bool cdp_get_options(int *argc, const char ***a
int main(int argc, const char **argv)
{
- struct cdrom_tochdr toc;
+ struct ioc_toc_header toc;
int fd;
if (!cdp_get_options(&argc, &argv))
@@ -69,38 +71,57 @@ int main(int argc, const char **argv)
return EXIT_FAILURE;
}
- if (ioctl(fd, CDROMREADTOCHDR, &toc) < 0) {
- perror("ioctl CDROMREADTOCHDR");
+ /*
+ * Ejecting and closing the CD-ROM tray does not require reading
+ * of the TOC header first (at least on FreeBSD).
+ */
+ if (do_eject) {
+ (void)ioctl(fd, CDIOCALLOW);
+ if (ioctl(fd, CDIOCEJECT) < 0)
+ perror("ioctl CDIOCEJECT");
+ /*
+ * It is pointless to do anything after CD-ROM had been
+ * ejected, so exit early.
+ */
+ goto done;
+ }
+ if (do_close) {
+ (void)ioctl(fd, CDIOCALLOW);
+ if (ioctl(fd, CDIOCCLOSE) < 0)
+ perror("ioctl CDIOCCLOSE");
+ }
+ if (ioctl(fd, CDIOREADTOCHEADER, &toc) < 0) {
+ perror("ioctl CDIOREADTOCHEADER");
return EXIT_FAILURE;
}
if (dump_toc)
- printf("Tracks: %u-%u\n", toc.cdth_trk0, toc.cdth_trk1);
+ printf("Tracks: %u-%u\n", toc.starting_track, toc.ending_track);
if (do_start)
- if (ioctl(fd, CDROMSTART) < 0)
- perror("ioctl CDROMSTART");
+ if (ioctl(fd, CDIOCSTART) < 0)
+ perror("ioctl CDIOCSTART");
if (do_pause)
- if (ioctl(fd, CDROMPAUSE) < 0)
- perror("ioctl CDROMPAUSE");
+ if (ioctl(fd, CDIOCPAUSE) < 0)
+ perror("ioctl CDIOCPAUSE");
if (do_resume)
- if (ioctl(fd, CDROMRESUME) < 0)
- perror("ioctl CDROMRESUME");
+ if (ioctl(fd, CDIOCRESUME) < 0)
+ perror("ioctl CDIOCRESUME");
if (do_play) {
- struct cdrom_ti t;
- t.cdti_trk0 = (argc >= 2) ? strtoul(argv[1], NULL, 0) :
- toc.cdth_trk0;
- t.cdti_trk1 = (argc >= 3) ? strtoul(argv[2], NULL, 0) :
- toc.cdth_trk1;
- t.cdti_ind0 = 0;
- t.cdti_ind1 = 0;
- if (ioctl(fd, CDROMPLAYTRKIND, &t) < 0)
- perror("ioctl CDROMPLAYTRKIND");
+ struct ioc_play_track t;
+ t.start_track = (argc >= 2) ? strtoul(argv[1], NULL, 0) :
+ toc.starting_track;
+ t.end_track = (argc >= 3) ? strtoul(argv[2], NULL, 0) :
+ toc.ending_track;
+ t.start_index = 1;
+ t.end_index = 1;
+ if (ioctl(fd, CDIOCPLAYTRACKS, &t) < 0)
+ perror("ioctl CDIOCPLAYTRACKS");
}
- if (do_stop)
- if (ioctl(fd, CDROMSTOP) < 0)
- perror("ioctl CDROMSTOP");
- if (do_eject)
- if (ioctl(fd, CDROMEJECT) < 0)
- perror("ioctl CDROMEJECT");
+ if (do_stop) {
+ if (ioctl(fd, CDIOCSTOP) < 0)
+ perror("ioctl CDIOCSTOP");
+ (void)ioctl(fd, CDIOCALLOW);
+ }
+ done:
close(fd);
return EXIT_SUCCESS;
}

View File

@ -1,33 +0,0 @@
--- suser/sysinfo.c.orig 2020-07-12 09:44:16 UTC
+++ suser/sysinfo.c
@@ -48,9 +48,9 @@ struct sy_block {
unsigned int display_width, display_height;
};
-static const char *sy_osrelease_file = "/etc/os-release";
-static const char *sy_cpuinfo_file = "/proc/cpuinfo";
-static const char sysfs_cpu_dir[] = "/sys/devices/system/cpu";
+static const char *sy_osrelease_file = "/var/run/os-release";
+static const char *sy_cpuinfo_file = "/compat/linux/proc/cpuinfo";
+static const char sysfs_cpu_dir[] = "/compat/linux/sys/devices/system/cpu";
static unsigned int sy_verbose;
static void sy_num_cpu_threads(struct sy_block *sib)
@@ -190,7 +190,7 @@ static void sy_loadavg(struct sy_block *sib)
{
double avg5, avg15;
unsigned int run;
- FILE *fp = fopen("/proc/loadavg", "r");
+ FILE *fp = fopen("/compat/linux/proc/loadavg", "r");
if (fp == NULL)
return;
@@ -202,7 +202,7 @@ static void sy_loadavg(struct sy_block *sib)
static void sy_memory(struct sy_block *sib)
{
unsigned long long mem_free = 0, mem_buf = 0, mem_cac = 0, mem_shm = 0;
- FILE *fp = fopen("/proc/meminfo", "r");
+ FILE *fp = fopen("/compat/linux/proc/meminfo", "r");
hxmc_t *line = NULL;
char *key, *value;

View File

@ -41,7 +41,6 @@ bin/tailhex
bin/wktimer
bin/xcp
etc/hxloginpref.conf
libexec/hxtools/cctypeinfo
libexec/hxtools/clock_info
libexec/hxtools/diff2php
libexec/hxtools/doxygen-kerneldoc-filter
@ -63,7 +62,6 @@ libexec/hxtools/vcsaview
man/man1/aumeta.1.gz
man/man1/bin2c.1.gz
man/man1/bsvplay.1.gz
man/man1/cctypeinfo.1.gz
man/man1/checkbrack.1.gz
man/man1/clock_info.1.gz
man/man1/cwdiff.1.gz