summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans-Nikolai Viessmann2023-12-07 13:40:13 +0100
committerHans-Nikolai Viessmann2023-12-07 13:40:13 +0100
commit8264a11ab7bab01215c1b593fd964716d8e903c3 (patch)
tree1e4d6adf32b0f15deffa1df1505bbe8a788c1996
downloadaur-bsdsed.tar.gz
inital commit
-rw-r--r--.SRCINFO18
-rw-r--r--Makefile26
-rw-r--r--PKGBUILD30
-rw-r--r--errc.c12
-rw-r--r--linux_compat.h29
5 files changed, 115 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..ba0afaf826c7
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,18 @@
+pkgbase = bsdsed
+ pkgdesc = BSD variant of sed
+ pkgver = 1.0.0
+ pkgrel = 1
+ url = https://github.com/freebsd/freebsd-src/tree/main/usr.bin/sed
+ arch = x86_64
+ license = BSD
+ depends = glibc
+ source = https://github.com/freebsd/freebsd-src/archive/refs/tags/release/14.0.0.tar.gz
+ source = Makefile
+ source = errc.c
+ source = linux_compat.h
+ sha256sums = ebdb7af04060d0a52e713bab4eba274ab2c9c6b94e657e67b32c80086ccbeabc
+ sha256sums = 394e15e993e651f98f5d0a7c69714f1a1b9870d500a9ead7616f0dfb1a34fddd
+ sha256sums = ffa4df0805e86b6298758b0abd4857b189d2d8b4df0de510376efd064a3d5e64
+ sha256sums = 64c848535ea2af835c1cf3b24a0843408bc4ecd542ff660f023fe9413d6888c2
+
+pkgname = bsdsed
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000000..4cb8dfa3041f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+FREEBSDVER?=14.0.0
+
+INSTALL?=/usr/bin/install
+INSTALL_PROGRAM=$(INSTALL) -Dm755
+INSTALL_DATA=$(INSTALL) -Dm644
+bindir=/usr/bin/
+man1dir=/usr/share/man/man1/
+CFLAGS+= -include linux_compat.h
+
+all: bsdsed
+
+bsdsed: freebsd-src-release-$(FREEBSDVER)/usr.bin/sed/compile.o \
+ freebsd-src-release-$(FREEBSDVER)/usr.bin/sed/main.o \
+ freebsd-src-release-$(FREEBSDVER)/usr.bin/sed/misc.o \
+ freebsd-src-release-$(FREEBSDVER)/usr.bin/sed/process.o \
+ freebsd-src-release-$(FREEBSDVER)/lib/libc/string/strlcat.o \
+ freebsd-src-release-$(FREEBSDVER)/lib/libc/string/strlcpy.o \
+ errc.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o bsdsed $^
+
+bsdsed.1:
+ @sed 's/sed/bsdsed/;s/GNU bsd/GNU /' freebsd-src-release-$(FREEBSDVER)/usr.bin/sed/sed.1 > bsdsed.1
+
+install: bsdsed bsdsed.1
+ $(INSTALL_PROGRAM) -t $(DESTDIR)$(bindir) bsdsed
+ $(INSTALL_DATA) -t $(DESTDIR)$(man1dir) bsdsed.1
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..361ce4a78b71
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,30 @@
+# Maintainer: Hans-Nikolai Viessmann <hans@viess.mn>
+pkgname="bsdsed"
+_freebsd_ver="14.0.0"
+pkgver="1.0.0"
+pkgrel=1
+pkgdesc="BSD variant of sed"
+arch=('x86_64')
+url="https://github.com/freebsd/freebsd-src/tree/main/usr.bin/sed"
+license=('BSD')
+depends=('glibc')
+source=("https://github.com/freebsd/freebsd-src/archive/refs/tags/release/$_freebsd_ver.tar.gz"
+ "Makefile"
+ "errc.c"
+ "linux_compat.h")
+sha256sums=('ebdb7af04060d0a52e713bab4eba274ab2c9c6b94e657e67b32c80086ccbeabc'
+ '394e15e993e651f98f5d0a7c69714f1a1b9870d500a9ead7616f0dfb1a34fddd'
+ 'ffa4df0805e86b6298758b0abd4857b189d2d8b4df0de510376efd064a3d5e64'
+ '64c848535ea2af835c1cf3b24a0843408bc4ecd542ff660f023fe9413d6888c2')
+
+build() {
+ cd "$srcdir"
+ make FREEBSDVER=$_freebsd_ver
+}
+
+package() {
+ cd "$srcdir"
+ make FREEBSDVER=$_freebsd_ver DESTDIR="$pkgdir/" install
+
+ install -Dm644 -t $pkgdir/usr/share/licenses/$pkgname/ freebsd-src-release-$_freebsd_ver/COPYRIGHT
+}
diff --git a/errc.c b/errc.c
new file mode 100644
index 000000000000..7dd7aa46d67a
--- /dev/null
+++ b/errc.c
@@ -0,0 +1,12 @@
+#include <stdlib.h>
+#include <stdarg.h>
+#include <err.h>
+
+_Noreturn void errc(int eval, int status, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vwarnx(fmt, ap);
+ va_end(ap);
+ exit(eval);
+}
diff --git a/linux_compat.h b/linux_compat.h
new file mode 100644
index 000000000000..9ad6ce5b333d
--- /dev/null
+++ b/linux_compat.h
@@ -0,0 +1,29 @@
+#ifndef LINUX_COMPAT_H
+#define LINUX_COMPAT_H
+
+#ifdef __linux__
+
+#define _GNU_SOURCE
+
+#include <stdlib.h>
+#include <errno.h>
+
+extern char *program_invocation_short_name;
+
+#define getprogname() program_invocation_short_name
+
+#define __unreachable() __builtin_unreachable()
+#define __dead2 __attribute__((__noreturn__))
+
+size_t
+strlcat(char *dst, const char *src, size_t siz);
+
+size_t
+strlcpy(char *dst, const char *src, size_t siz);
+
+void errc(int eval, int status, const char *fmt, ...) __dead2;
+
+#define __FBSDID(x)
+
+#endif /* __linux__ */
+#endif /* LINUX_COMPAT_H */