diff --git a/devel/efivar/Makefile b/devel/efivar/Makefile --- a/devel/efivar/Makefile +++ b/devel/efivar/Makefile @@ -1,53 +1,28 @@ PORTNAME= efivar -PORTVERSION= 0.15 -PORTREVISION= 9 +PORTVERSION= 39 CATEGORIES= devel -MAINTAINER= ports@FreeBSD.org -COMMENT= Tools and library to manipulate EFI variables +MAINTAINER= decke@FreeBSD.org +COMMENT= Tools and libraries to work with EFI variables WWW= https://github.com/rhboot/efivar LICENSE= LGPL21 NOT_FOR_ARCHS= powerpc powerpc64 powerpcspe NOT_FOR_ARCHS_REASON= specification only supports little-endian processors +BROKEN_FreeBSD_13= requires at least FreeBSD 14 +BUILD_DEPENDS= gsed:textproc/gsed LIB_DEPENDS= libpopt.so:devel/popt -CFLAGS+= -fpermissive +USES= gmake pkgconfig python -USES= gmake localbase pkgconfig USE_GCC= yes USE_GITHUB= yes GH_ACCOUNT= rhboot USE_LDCONFIG= yes +BINARY_ALIAS= sed=${LOCALBASE}/bin/gsed -.include - -post-patch: - @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/src/efivar.pc.in - -do-install: - ${INSTALL_PROGRAM} ${WRKSRC}/src/efivar ${STAGEDIR}${PREFIX}/bin - ${INSTALL_LIB} ${WRKSRC}/src/libefivar.so ${STAGEDIR}${PREFIX}/lib - ${INSTALL_LIB} ${WRKSRC}/src/libefivar.so.0 ${STAGEDIR}${PREFIX}/lib - ${INSTALL_DATA} ${WRKSRC}/src/efivar.h ${STAGEDIR}${PREFIX}/include - ${INSTALL_DATA} ${WRKSRC}/src/efivar-guids.h ${STAGEDIR}${PREFIX}/include - ${INSTALL_DATA} ${WRKSRC}/src/efivar.pc ${STAGEDIR}${PREFIX}/libdata/pkgconfig - ${INSTALL_MAN} ${WRKSRC}/docs/efivar.1 ${STAGEDIR}${PREFIX}/share/man/man1 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_append_variable.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_del_variable.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_get_next_variable_name.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_get_variable.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_get_variable_attributes.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_get_variable_size.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_guid_to_name.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_guid_to_str.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_guid_to_symbol.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_name_to_guid.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_set_variable.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_str_to_guid.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_symbol_to_guid.3 ${STAGEDIR}${PREFIX}/share/man/man3 - ${INSTALL_MAN} ${WRKSRC}/docs/efi_variables_supported.3 ${STAGEDIR}${PREFIX}/share/man/man3 - -.include +MAKE_ARGS+= CC="${CC}" LIBDIR="${PREFIX}/lib" + +.include diff --git a/devel/efivar/distinfo b/devel/efivar/distinfo --- a/devel/efivar/distinfo +++ b/devel/efivar/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1544125008 -SHA256 (rhboot-efivar-0.15_GH0.tar.gz) = 8e5a45ebbd116a96a43176e96b211c73f3ec8452da3bd0ce75a5716f86d4343f -SIZE (rhboot-efivar-0.15_GH0.tar.gz) = 30064 +TIMESTAMP = 1730568659 +SHA256 (rhboot-efivar-39_GH0.tar.gz) = c9edd15f2eeeea63232f3e669a48e992c7be9aff57ee22672ac31f5eca1609a6 +SIZE (rhboot-efivar-39_GH0.tar.gz) = 463349 diff --git a/devel/efivar/files/patch-src_compiler.h b/devel/efivar/files/patch-src_compiler.h new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_compiler.h @@ -0,0 +1,13 @@ +--- src/compiler.h.orig 2024-01-31 20:08:46 UTC ++++ src/compiler.h +@@ -74,7 +74,9 @@ + + #define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) + #define __ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1) +-#define ALIGN(x, a) __ALIGN((x), (a)) ++#if !defined(ALIGN) ++# define ALIGN(x, a) __ALIGN((x), (a)) ++#endif + #define ALIGN_DOWN(x, a) __ALIGN((x) - ((a) - 1), (a)) + + #define ALIGNMENT_PADDING(value, align) ((align - (value % align)) % align) diff --git a/devel/efivar/files/patch-src_creator.c b/devel/efivar/files/patch-src_creator.c new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_creator.c @@ -0,0 +1,26 @@ +--- src/creator.c.orig 2024-01-31 20:08:46 UTC ++++ src/creator.c +@@ -9,16 +9,22 @@ + #include + #include + #include ++#if defined(__linux__) + #include ++#endif ++#include + #include + #include + #include + #include +-#include + #include + #include + + #include "efiboot.h" ++ ++#if defined(__FreeBSD__) ++# include "mntent.h" ++#endif + + static int NONNULL(1, 2, 3) + find_file(const char * const filepath, char **devicep, char **relpathp) diff --git a/devel/efivar/files/patch-src_disk.c b/devel/efivar/files/patch-src_disk.c new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_disk.c @@ -0,0 +1,32 @@ +--- src/disk.c.orig 2024-01-31 20:08:46 UTC ++++ src/disk.c +@@ -14,6 +14,10 @@ + #include + #include + #include ++#ifdef __FreeBSD__ ++# include ++# undef LIST_HEAD ++#endif + #include + #include + #include +@@ -158,8 +162,18 @@ msdos_disk_get_partition_info (int fd, int write_signa + } else if (num == 0) { + /* Whole disk */ + *start = 0; ++#if defined(__linux__) + ioctl(fd, BLKGETSIZE, &disk_size); + *size = disk_size; ++#elif defined(__FreeBSD__) ++ long sector_size=0; ++ ioctl(fd, DIOCGMEDIASIZE, &disk_size); ++ ioctl(fd, DIOCGSECTORSIZE, §or_size); ++ *size = disk_size / sector_size; ++#else ++ efi_error("could not get disk size (not implemented on your OS)"); ++ return -1; ++#endif + } else if (num >= 1 && num <= 4) { + /* Primary partition */ + *start = mbr->partition[num-1].starting_lba; diff --git a/devel/efivar/files/patch-src_dp.h b/devel/efivar/files/patch-src_dp.h new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_dp.h @@ -0,0 +1,13 @@ +--- src/dp.h.orig 2024-01-31 20:08:46 UTC ++++ src/dp.h +@@ -6,7 +6,9 @@ + #ifndef _EFIVAR_INTERNAL_DP_H + #define _EFIVAR_INTERNAL_DP_H + +-#include ++#if defined(__linux__) ++# include ++#endif + #include + #include + #include diff --git a/devel/efivar/files/patch-src_efisecdb.c b/devel/efivar/files/patch-src_efisecdb.c new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_efisecdb.c @@ -0,0 +1,38 @@ +--- src/efisecdb.c.orig 2024-01-31 20:08:46 UTC ++++ src/efisecdb.c +@@ -93,7 +93,7 @@ secdb_warnx(const char * const fmt, ...) + int errnum = errno; + + fflush(stdout); +- fprintf(stderr, "%s: ", program_invocation_short_name); ++ fprintf(stderr, "%s: ", getprogname()); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); +@@ -109,7 +109,7 @@ secdb_err(int status, const char * const fmt, ...) + int errnum = errno; + + fflush(stdout); +- fprintf(stderr, "%s: ", program_invocation_short_name); ++ fprintf(stderr, "%s: ", getprogname()); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); +@@ -126,7 +126,7 @@ secdb_errx(int status, const char * const fmt, ...) + int errnum = errno; + + fflush(stdout); +- fprintf(stderr, "%s: ", program_invocation_short_name); ++ fprintf(stderr, "%s: ", getprogname()); + va_start(ap, fmt); + errno = errnum; + vfprintf(stderr, fmt, ap); +@@ -149,7 +149,7 @@ usage(int status) + " -t, --type= hash type to add (\"help\" lists options)\n" + " -c, --certificate= certificate file to add\n" + " -L, --list-guids list well known guids\n", +- program_invocation_short_name); ++ getprogname()); + exit(status); + } + diff --git a/devel/efivar/files/patch-src_efivar.c b/devel/efivar/files/patch-src_efivar.c new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_efivar.c @@ -0,0 +1,31 @@ +--- src/efivar.c.orig 2024-01-31 20:08:46 UTC ++++ src/efivar.c +@@ -20,6 +20,10 @@ + #include + #include + ++#if defined(__FreeBSD__) ++# undef LIST_HEAD ++#endif ++ + extern char *optarg; + extern int optind, opterr, optopt; + +@@ -408,7 +412,7 @@ prepare_data(const char *filename, uint8_t **data, siz + goto err; + + buflen = statbuf.st_size; +- buf = mmap(NULL, buflen, PROT_READ, MAP_PRIVATE|MAP_POPULATE, fd, 0); ++ buf = mmap(NULL, buflen, PROT_READ, MAP_PRIVATE, fd, 0); + if (buf == MAP_FAILED) + goto err; + +@@ -447,7 +451,7 @@ usage(int ret) + "Help options:\n" + " -?, --help Show this help message\n" + " --usage Display brief usage message\n", +- program_invocation_short_name); ++ getprogname()); + exit(ret); + } + diff --git a/devel/efivar/files/patch-src_efivarfs.c b/devel/efivar/files/patch-src_efivarfs.c new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_efivarfs.c @@ -0,0 +1,162 @@ +--- src/efivarfs.c.orig 2024-01-31 20:08:46 UTC ++++ src/efivarfs.c +@@ -9,20 +9,32 @@ + #include + #include + #include +-#include ++#if defined(__linux__) ++# include ++#endif + #include + #include + #include + #include + #include ++#include ++#include + #include + #include +-#include ++#if defined(__linux__) ++# include ++#endif + #include + ++#if defined(__FreeBSD__) ++# undef LIST_HEAD ++#endif ++ + #include "efivar.h" + +-#include ++#if defined(__linux__) ++# include ++#endif + + #ifndef EFIVARFS_MAGIC + # define EFIVARFS_MAGIC 0xde5e81e4 +@@ -102,6 +114,7 @@ efivarfs_set_fd_immutable(int fd, int immutable) + static int + efivarfs_set_fd_immutable(int fd, int immutable) + { ++#if defined(__linux__) + unsigned int flags; + int rc = 0; + +@@ -124,11 +137,42 @@ efivarfs_set_fd_immutable(int fd, int immutable) + } + + return rc; ++#elif defined(__FreeBSD__) ++ struct stat sb; ++ int rc = 0; ++ unsigned long flags; ++ ++ if (fstat(fd, &sb) == -1) { ++ if (errno == EBADF) ++ rc = 0; ++ else ++ efi_error("fstat(%d) failed", fd); ++ return rc; ++ } ++ ++ flags = sb.st_flags; ++ ++ if ((immutable && !(flags & UF_IMMUTABLE)) || ++ (!immutable && (flags & UF_IMMUTABLE))) { ++ if (immutable) ++ flags |= UF_IMMUTABLE; ++ else ++ flags &= ~UF_IMMUTABLE; ++ ++ if (chflagsat(fd, "", flags, AT_EMPTY_PATH) == -1) { ++ efi_error("chflagsat(%d) failed\n", fd); ++ rc = -1; ++ } ++ } ++ ++ return rc; ++#endif + } + + static int + efivarfs_make_fd_mutable(int fd, unsigned long *orig_attrs) + { ++#if defined(__linux__) + unsigned long mutable_attrs = 0; + + *orig_attrs = 0; +@@ -145,6 +189,26 @@ efivarfs_make_fd_mutable(int fd, unsigned long *orig_a + return -1; + + return 0; ++#elif defined(__FreeBSD__) ++ struct stat sb; ++ ++ *orig_attrs = 0; ++ ++ if (fstat(fd, &sb) == -1) ++ return -1; ++ ++ *orig_attrs = sb.st_flags; ++ ++ // if the file is not immutable, nothing to do ++ if ((sb.st_flags & UF_IMMUTABLE) == 0) ++ return 0; ++ ++ // remove user immutable flag ++ if (chflagsat(fd, "", sb.st_flags & ~UF_IMMUTABLE, AT_EMPTY_PATH) == -1) ++ return -1; ++ ++ return 0; ++#endif + } + + static int +@@ -375,10 +439,17 @@ efivarfs_set_variable(efi_guid_t guid, const char *nam + goto err; + } + ++#if defined(__linux__) + /* if the file is indeed immutable, clear and remember it */ + if (efivarfs_make_fd_mutable(rfd, &orig_attrs) == 0 && + (orig_attrs & FS_IMMUTABLE_FL)) + restore_immutable_fd = rfd; ++#elif defined(__FreeBSD__) ++ /* if the file is indeed immutable, clear and remember it */ ++ if (efivarfs_make_fd_mutable(rfd, &orig_attrs) == 0 && ++ (orig_attrs & UF_IMMUTABLE)) ++ restore_immutable_fd = rfd; ++#endif + } + + /* +@@ -414,9 +485,15 @@ efivarfs_set_variable(efi_guid_t guid, const char *nam + * immediately, and the write() below would fail otherwise. + */ + if (rfd == -1) { ++#if defined(__linux__) + if (efivarfs_make_fd_mutable(wfd, &orig_attrs) == 0 && + (orig_attrs & FS_IMMUTABLE_FL)) + restore_immutable_fd = wfd; ++#elif defined(__FreeBSD__) ++ if (efivarfs_make_fd_mutable(wfd, &orig_attrs) == 0 && ++ (orig_attrs & UF_IMMUTABLE)) ++ restore_immutable_fd = wfd; ++#endif + } else { + /* make sure rfd and wfd refer to the same file */ + struct stat wfd_stat; +@@ -452,7 +529,11 @@ err: + if (ret == -1 && rfd == -1 && wfd != -1 && unlink(path) == -1) + efi_error("failed to unlink %s", path); + ++#if defined(__linux__) + ioctl(restore_immutable_fd, FS_IOC_SETFLAGS, &orig_attrs); ++#elif defined(__FreeBSD__) ++ chflagsat(restore_immutable_fd, "", orig_attrs, AT_EMPTY_PATH); ++#endif + + if (wfd >= 0) + close(wfd); diff --git a/devel/efivar/files/patch-src_gpt.c b/devel/efivar/files/patch-src_gpt.c new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_gpt.c @@ -0,0 +1,59 @@ +--- src/gpt.c.orig 2024-01-31 20:08:46 UTC ++++ src/gpt.c +@@ -16,6 +16,11 @@ + #include + #include + #include ++#if defined(__FreeBSD__) ++# include ++# undef LIST_HEAD ++#endif ++#include + #include + #include + #include +@@ -60,6 +65,7 @@ is_pmbr_valid(legacy_mbr *mbr) + return (magic && found); + } + ++#if defined(__linux__) + /** + * kernel_has_blkgetsize64() + * +@@ -92,6 +98,7 @@ kernel_has_blkgetsize64(void) + return 0; + return 1; + } ++#endif + + /************************************************************ + * _get_num_sectors +@@ -114,6 +121,8 @@ _get_num_sectors(int filedes) + unsigned long sectors=0; + uint64_t bytes=0; + int rc; ++ ++#if defined(__linux__) + if (kernel_has_blkgetsize64()) { + rc = ioctl(filedes, BLKGETSIZE64, &bytes); + if (!rc) +@@ -125,6 +134,19 @@ _get_num_sectors(int filedes) + return 0; + + return sectors; ++#elif defined(__FreeBSD__) ++ rc = ioctl(filedes, DIOCGMEDIASIZE, &bytes); ++ if (rc == -1) ++ return 0; ++ ++ rc = ioctl(filedes, DIOCGSECTORSIZE, §ors); ++ if (rc == -1) ++ return 0; ++ ++ return bytes / sectors; ++#else ++ return 0; ++#endif + } + + /************************************************************ diff --git a/devel/efivar/files/patch-src_include_defaults.mk b/devel/efivar/files/patch-src_include_defaults.mk new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_include_defaults.mk @@ -0,0 +1,26 @@ +--- src/include/defaults.mk.orig 2024-01-31 20:08:46 UTC ++++ src/include/defaults.mk +@@ -43,7 +43,6 @@ override CFLAGS = $(_CFLAGS) \ + override CFLAGS = $(_CFLAGS) \ + -std=gnu11 \ + -funsigned-char \ +- -fvisibility=hidden \ + $(call family,CFLAGS) \ + $(call pkg-config-cflags) + LDFLAGS_CLANG ?= -rtlib=compiler-rt +@@ -53,7 +52,6 @@ override LDFLAGS = $(CFLAGS) -L. $(_LDFLAGS) $(_CCLDFL + override _LDFLAGS := $(LDFLAGS) + override LDFLAGS = $(CFLAGS) -L. $(_LDFLAGS) $(_CCLDFLAGS) \ + -Wl,--build-id \ +- -Wl,--no-allow-shlib-undefined \ + -Wl,--no-undefined-version \ + -Wl,-z,now \ + -Wl,-z,muldefs \ +@@ -99,7 +97,6 @@ override HOST_LDFLAGS = $(HOST_CFLAGS) -L. \ + override HOST_LDFLAGS = $(HOST_CFLAGS) -L. \ + $(_HOST_LDFLAGS) $(_HOST_CCLDFLAGS) \ + -Wl,--build-id \ +- -Wl,--no-allow-shlib-undefined \ + -Wl,-z,now \ + -Wl,-z,muldefs \ + $(call family,HOST_LDFLAGS) \ diff --git a/devel/efivar/files/patch-src_include_gcc.specs b/devel/efivar/files/patch-src_include_gcc.specs new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_include_gcc.specs @@ -0,0 +1,8 @@ +--- src/include/gcc.specs.orig 2024-01-31 20:08:46 UTC ++++ src/include/gcc.specs +@@ -5,4 +5,4 @@ + %{!shared:%{!static:%{!r:-pie}}} %{static:-Wl,-no-fa + + %{!shared:%{!static:%{!r:-pie}}} %{static:-Wl,-no-fatal-warnings -Wl,-static -static -Wl,-z,relro,-z,now} -grecord-gcc-switches + + *link: +-+ %{!static:--fatal-warnings} --no-undefined-version --no-allow-shlib-undefined -z now --build-id %{!static:%{!shared:-pie}} %{shared:-z relro} %{static:% + #include + #include +-#include +-#include +-#include ++#if defined(__linux__) ++# include ++# include ++# include ++#elif defined(__FreeBSD__) ++# include ++# include ++#endif + #include +-#include ++#if defined(__linux__) ++# include ++#endif + #include + #include ++#if defined(__FreeBSD__) ++# include ++# undef LIST_HEAD ++#endif + #include + #include + #include +-#include ++#if defined(__linux__) ++# include ++#endif + #include + #include + #include +@@ -630,6 +643,7 @@ make_blockdev_path(uint8_t *buf, ssize_t size, struct + return off; + } + ++#if defined(__linux__) + ssize_t HIDDEN + make_mac_path(uint8_t *buf, ssize_t size, const char * const ifname) + { +@@ -693,7 +707,48 @@ err: + close(fd); + return ret; + } ++#elif defined(__FreeBSD__) ++ssize_t HIDDEN ++make_mac_path(uint8_t *buf, ssize_t size, const char * const ifname) ++{ ++ int fd; ++ struct ifreq ifr; ++ struct sockaddr_dl *sdl; ++ ssize_t ret = -1; + ++ if (!buf || !ifname) ++ return -1; ++ ++ fd = socket(AF_INET, SOCK_DGRAM, 0); ++ if (fd < 0) ++ return -1; ++ ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1); ++ ifr.ifr_name[IFNAMSIZ-1] = '\0'; ++ ++ if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) { ++ close(fd); ++ return -1; ++ } ++ ++ // For MAC, use AF_LINK (sockaddr_dl) ++ if (ioctl(fd, SIOCGIFCONF, &ifr) < 0) { ++ close(fd); ++ return -1; ++ } ++ ++ sdl = (struct sockaddr_dl *)&ifr.ifr_addr; ++ if (sdl->sdl_alen > 0 && sdl->sdl_alen <= size) { ++ memcpy(buf, LLADDR(sdl), sdl->sdl_alen); ++ ret = sdl->sdl_alen; ++ } ++ ++ close(fd); ++ return ret; ++} ++#endif ++ + /************************************************************ + * get_sector_size + * Requires: +@@ -707,7 +762,12 @@ get_sector_size(int filedes) + { + int rc, sector_size = 512; + ++ (void)filedes; ++#if defined(__linux__) + rc = ioctl(filedes, BLKSSZGET, §or_size); ++#elif defined(__FreeBSD__) ++ rc = ioctl(filedes, DIOCGSECTORSIZE, §or_size); ++#endif + if (rc) + sector_size = 512; + return sector_size; diff --git a/devel/efivar/files/patch-src_mntent.h b/devel/efivar/files/patch-src_mntent.h new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_mntent.h @@ -0,0 +1,192 @@ +--- src/mntent.h.orig 2025-10-12 11:00:40 UTC ++++ src/mntent.h +@@ -0,0 +1,189 @@ ++/* ++ * mntent ++ * mntent.h - compatibility header for FreeBSD ++ * ++ * Copyright (c) 2001 David Rufino ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#ifndef VIFM__UTILS__MNTENT_H__ ++#define VIFM__UTILS__MNTENT_H__ ++ ++#include ++#include ++ ++#define MOUNTED "dummy" ++ ++#define MNTTYPE_NFS "nfs" ++ ++struct mntent ++{ ++ char *mnt_fsname; ++ char *mnt_dir; ++ char *mnt_type; ++ char *mnt_opts; ++ int mnt_freq; ++ int mnt_passno; ++}; ++ ++#define setmntent(x,y) ((FILE *)0x1) ++struct mntent * getmntent(FILE *fp); ++char * hasmntopt(const struct mntent *mnt, const char option[]); ++#define endmntent(x) ((int)1) ++ ++#endif /* VIFM__UTILS__MNTENT_H__ */ ++ ++#include ++#include ++#include ++ ++#include ++#include ++ ++#ifdef __NetBSD__ ++#define statfs statvfs ++#define f_flags f_flag ++#endif ++ ++static struct mntent * statfs_to_mntent(struct statfs *mntbuf); ++static char * flags2opts(int flags); ++static char * catopt(char s0[], const char s1[]); ++ ++char * ++hasmntopt(const struct mntent *mnt, const char option[]) ++{ ++ char *opt, *optbuf; ++ ++ optbuf = strdup(mnt->mnt_opts); ++ for(opt = optbuf; (opt = strtok(opt, " ")) != NULL; opt = NULL) ++ { ++ if(!strcasecmp(opt, option)) ++ { ++ opt = opt - optbuf + mnt->mnt_opts; ++ free(optbuf); ++ return (opt); ++ } ++ } ++ free(optbuf); ++ return NULL; ++} ++ ++struct mntent * ++getmntent(FILE *fp) ++{ ++ static int pos = -1; ++ static int mntsize = -1; ++ ++ static struct statfs *mntbuf; ++ ++ (void)fp; ++ ++ if(pos == -1 || mntsize == -1) ++ { ++ mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); ++ } ++ ++ pos++; ++ if(pos == mntsize) ++ { ++ pos = mntsize = -1; ++ return NULL; ++ } ++ ++ return statfs_to_mntent(&mntbuf[pos]); ++} ++ ++static struct mntent * ++statfs_to_mntent(struct statfs *mntbuf) ++{ ++ static struct mntent _mntent; ++ static char opts_buf[40], *tmp; ++ ++ _mntent.mnt_fsname = mntbuf->f_mntfromname; ++ _mntent.mnt_dir = mntbuf->f_mntonname; ++ _mntent.mnt_type = mntbuf->f_fstypename; ++ tmp = flags2opts (mntbuf->f_flags); ++ if(tmp != NULL) ++ { ++ opts_buf[sizeof(opts_buf) - 1] = '\0'; ++ strncpy(opts_buf, tmp, sizeof(opts_buf) - 1); ++ free(tmp); ++ } ++ else ++ { ++ *opts_buf = '\0'; ++ } ++ _mntent.mnt_opts = opts_buf; ++ _mntent.mnt_freq = _mntent.mnt_passno = 0; ++ return &_mntent; ++} ++ ++static char * ++flags2opts(int flags) ++{ ++ char *res = catopt(NULL, (flags & MNT_RDONLY) ? "ro" : "rw"); ++ if(flags & MNT_SYNCHRONOUS) res = catopt(res, "sync"); ++ if(flags & MNT_NOEXEC) res = catopt(res, "noexec"); ++ if(flags & MNT_NOSUID) res = catopt(res, "nosuid"); ++#ifndef __OpenBSD__ ++ if(flags & MNT_UNION) res = catopt(res, "union"); ++#endif ++ if(flags & MNT_ASYNC) res = catopt(res, "async"); ++ if(flags & MNT_NOATIME) res = catopt(res, "noatime"); ++#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__NetBSD__) ++ if(flags & MNT_NOCLUSTERR) res = catopt(res, "noclusterr"); ++ if(flags & MNT_NOCLUSTERW) res = catopt(res, "noclusterw"); ++ if(flags & MNT_NOSYMFOLLOW) res = catopt(res, "nosymfollow"); ++ if(flags & MNT_SUIDDIR) res = catopt(res, "suiddir"); ++#endif ++ ++ return res; ++} ++ ++static char * ++catopt(char s0[], const char s1[]) ++{ ++ char *cp; ++ ++ if(s1 == NULL || *s1 == '\0') ++ { ++ return s0; ++ } ++ if(s0 && *s0) ++ { ++ const size_t i = strlen(s0) + strlen(s1) + 1 + 1; ++ if((cp = malloc(i)) == NULL) ++ { ++ return NULL; ++ } ++ (void)snprintf(cp, i, "%s %s", s0, s1); ++ } ++ else ++ { ++ cp = strdup(s1); ++ } ++ ++ free(s0); ++ return cp; ++} diff --git a/devel/efivar/files/patch-src_test_tester.c b/devel/efivar/files/patch-src_test_tester.c new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_test_tester.c @@ -0,0 +1,13 @@ +--- src/test/tester.c.orig 2024-01-31 20:08:46 UTC ++++ src/test/tester.c +@@ -5,7 +5,9 @@ + * Copyright 2012-2018 Peter M. Jones + */ + +-#include ++#if defined(__linux__) ++# include ++#endif + #include + #include + #include diff --git a/devel/efivar/files/patch-src_thread-test.c b/devel/efivar/files/patch-src_thread-test.c new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_thread-test.c @@ -0,0 +1,22 @@ +--- src/thread-test.c.orig 2024-01-31 20:08:46 UTC ++++ src/thread-test.c +@@ -6,7 +6,9 @@ + + #include "fix_coverity.h" + +-#include ++#if defined(__linux__) ++# include ++#endif + #include + #include + #include +@@ -125,7 +127,7 @@ usage(int ret) + "Help options:\n" + " -?, --help Show this help message\n" + " --usage Display brief usage message\n", +- program_invocation_short_name); ++ getprogname()); + exit(ret); + } + diff --git a/devel/efivar/files/patch-src_time.c b/devel/efivar/files/patch-src_time.c new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_time.c @@ -0,0 +1,20 @@ +--- src/time.c.orig 2024-01-31 20:08:46 UTC ++++ src/time.c +@@ -52,7 +52,17 @@ tm_to_efi_time(const struct tm * const s, efi_time_t * + + if (tzadj) { + tzset(); ++ ++#if defined(__FreeBSD__) ++ time_t t = time(NULL); ++ struct tm lt = {0}; ++ ++ localtime_r(&t, <); ++ ++ d->timezone = lt.tm_gmtoff / 60; ++#else + d->timezone = timezone / 60; ++#endif + } + + return 0; diff --git a/devel/efivar/files/patch-src_util.h b/devel/efivar/files/patch-src_util.h new file mode 100644 --- /dev/null +++ b/devel/efivar/files/patch-src_util.h @@ -0,0 +1,13 @@ +--- src/util.h.orig 2024-01-31 20:08:46 UTC ++++ src/util.h +@@ -8,7 +8,9 @@ + #ifndef EFIVAR_UTIL_H + #define EFIVAR_UTIL_H 1 + +-#include ++#if defined(__linux__) ++# include ++#endif + #include + #include + #include diff --git a/devel/efivar/pkg-descr b/devel/efivar/pkg-descr --- a/devel/efivar/pkg-descr +++ b/devel/efivar/pkg-descr @@ -1 +1 @@ -Tools and library to manipulate EFI variables. +Tools and libraries to work with EFI variables. diff --git a/devel/efivar/pkg-plist b/devel/efivar/pkg-plist --- a/devel/efivar/pkg-plist +++ b/devel/efivar/pkg-plist @@ -1,9 +1,29 @@ +bin/efisecdb bin/efivar -include/efivar-guids.h -include/efivar.h +include/efivar/efiboot-creator.h +include/efivar/efiboot-loadopt.h +include/efivar/efiboot.h +include/efivar/efisec-secdb.h +include/efivar/efisec-types.h +include/efivar/efisec.h +include/efivar/efivar-dp.h +include/efivar/efivar-guids.h +include/efivar/efivar-time.h +include/efivar/efivar-types.h +include/efivar/efivar.h +lib/libefiboot.so +lib/libefiboot.so.1 +lib/libefiboot.so.1.39 +lib/libefisec.so +lib/libefisec.so.1 +lib/libefisec.so.1.39 lib/libefivar.so -lib/libefivar.so.0 +lib/libefivar.so.1 +lib/libefivar.so.1.39 +libdata/pkgconfig/efiboot.pc +libdata/pkgconfig/efisec.pc libdata/pkgconfig/efivar.pc +share/man/man1/efisecdb.1.gz share/man/man1/efivar.1.gz share/man/man3/efi_append_variable.3.gz share/man/man3/efi_del_variable.3.gz @@ -11,6 +31,7 @@ share/man/man3/efi_get_variable.3.gz share/man/man3/efi_get_variable_attributes.3.gz share/man/man3/efi_get_variable_size.3.gz +share/man/man3/efi_guid_to_id_guid.3.gz share/man/man3/efi_guid_to_name.3.gz share/man/man3/efi_guid_to_str.3.gz share/man/man3/efi_guid_to_symbol.3.gz @@ -18,4 +39,18 @@ share/man/man3/efi_set_variable.3.gz share/man/man3/efi_str_to_guid.3.gz share/man/man3/efi_symbol_to_guid.3.gz +share/man/man3/efi_variable_alloc.3.gz +share/man/man3/efi_variable_export.3.gz +share/man/man3/efi_variable_free.3.gz +share/man/man3/efi_variable_get_attributes.3.gz +share/man/man3/efi_variable_get_data.3.gz +share/man/man3/efi_variable_get_guid.3.gz +share/man/man3/efi_variable_get_name.3.gz +share/man/man3/efi_variable_import.3.gz +share/man/man3/efi_variable_realize.3.gz +share/man/man3/efi_variable_set_attributes.3.gz +share/man/man3/efi_variable_set_data.3.gz +share/man/man3/efi_variable_set_guid.3.gz +share/man/man3/efi_variable_set_name.3.gz +share/man/man3/efi_variable_t.3.gz share/man/man3/efi_variables_supported.3.gz