From f41a5bd1e0cc01a7fa0ff26011b1ff060cc8e5f4 Mon Sep 17 00:00:00 2001 From: Stephen Smoogen Date: Thu, 18 Jan 2024 10:02:08 -0500 Subject: [PATCH] Fix makefile to add sha512sum instead of md5sum as some sites no longer allow md5 Make sure PREFIX/bin exists Copy binary with preserve so permissions and timestamp remain. Signed-off-by: Stephen Smoogen --- Makefile | 7 ++++--- phytool.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2472ad0..cdd5431 100644 --- a/Makefile +++ b/Makefile @@ -31,12 +31,13 @@ clean: @rm -f $(TARGET) dist: - @echo "Creating $(ARCHIVE), with $(ARCHIVE).md5 in parent dir ..." + @echo "Creating $(ARCHIVE), with $(ARCHIVE).sha512 in parent dir ..." @git archive --format=tar --prefix=$(PKG)/ v$(VERSION) | xz >../$(ARCHIVE) - @(cd .. && md5sum $(ARCHIVE) > $(ARCHIVE).md5) + @(cd .. && sha5125sum $(ARCHIVE) > $(ARCHIVE).sha512) install: phytool - @cp phytool $(DESTDIR)/$(PREFIX)/bin/ + @mkdir -p $(DESTDIR)/$(PREFIX)/bin/ + @cp -p phytool $(DESTDIR)/$(PREFIX)/bin/ @for app in $(APPLETS); do \ ln -sf phytool $(DESTDIR)/$(PREFIX)/bin/$$app; \ done diff --git a/phytool.c b/phytool.c index 1255068..121e6a8 100644 --- a/phytool.c +++ b/phytool.c @@ -275,13 +275,19 @@ static int mv6tool_parse_loc_if(char *dev, char *addr, char *reg, strncpy(loc->ifnam, dev, IFNAMSIZ - 1); - asprintf(&path, "/sys/class/net/%s/phys_switch_id", dev); + err = asprintf(&path, "/sys/class/net/%s/phys_switch_id", dev); + if (err == -1) + return -ENOMEM; + err = sysfs_readu(path, &phy_port); free(path); if (err) return -ENOSYS; - asprintf(&path, "/sys/class/net/%s/phys_port_id", dev); + err = asprintf(&path, "/sys/class/net/%s/phys_port_id", dev); + if (err == -1) + return -ENOMEM; + err = sysfs_readu(path, &phy_dev); free(path); if (err)