git: f6d34ea28841 - main - x11/hyprlock: add new port

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Sat, 24 Feb 2024 00:50:38 UTC
The branch main has been updated by jbeich:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f6d34ea28841e750ee5321787838ee1e21e95bba

commit f6d34ea28841e750ee5321787838ee1e21e95bba
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2024-02-23 17:12:52 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2024-02-24 00:49:59 +0000

    x11/hyprlock: add new port
    
    Hyprland's simple, yet multi-threaded and GPU-accelerated screen
    locking utility.
    
    Features:
     - uses the secure ext-session-lock protocol
     - full support for fractional-scale
     - fully GPU accelerated
     - multi-threaded resource acquisition for no hitches
    
    https://github.com/hyprwm/hyprlock
---
 x11/Makefile                 |  1 +
 x11/hyprlock/Makefile        | 67 ++++++++++++++++++++++++++++++++++++++++++++
 x11/hyprlock/distinfo        |  5 ++++
 x11/hyprlock/files/patch-pam | 21 ++++++++++++++
 x11/hyprlock/pkg-descr       |  8 ++++++
 5 files changed, 102 insertions(+)

diff --git a/x11/Makefile b/x11/Makefile
index 2318ff802b6f..33ed03c7d1d5 100644
--- a/x11/Makefile
+++ b/x11/Makefile
@@ -123,6 +123,7 @@
     SUBDIR += hsetroot
     SUBDIR += hybrid-bar
     SUBDIR += hypridle
+    SUBDIR += hyprlock
     SUBDIR += hyprpaper
     SUBDIR += hyprpicker
     SUBDIR += i3bar-river
diff --git a/x11/hyprlock/Makefile b/x11/hyprlock/Makefile
new file mode 100644
index 000000000000..4e76c8614dd0
--- /dev/null
+++ b/x11/hyprlock/Makefile
@@ -0,0 +1,67 @@
+PORTNAME=	hyprlock
+PORTVERSION=	s20240223
+CATEGORIES=	x11 wayland
+
+MAINTAINER=	jbeich@FreeBSD.org
+COMMENT=	Hyprland's GPU-accelerated screen locking utility #'
+WWW=		https://github.com/hyprwm/hyprlock
+
+LICENSE=	BSD3CLAUSE
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+BUILD_DEPENDS=	wayland-protocols>0:graphics/wayland-protocols
+LIB_DEPENDS=	libhyprlang.so:devel/hyprlang \
+		libdrm.so:graphics/libdrm \
+		libwayland-client.so:graphics/wayland \
+		libxkbcommon.so:x11/libxkbcommon
+RUN_DEPENDS=	unix-selfauth-helper>0:security/unix-selfauth-helper
+
+USES=		compiler:c++11-lib cmake gl gnome pkgconfig
+USE_GITHUB=	yes
+USE_GL=		egl gbm
+USE_GNOME=	cairo pango
+GH_ACCOUNT=	hyprwm
+GH_TAGNAME=	8969351
+LDFLAGS+=	-Wl,--as-needed # pango deps
+PLIST_FILES=	bin/${PORTNAME} \
+		etc/pam.d/${PORTNAME}
+
+# XXX Drop after FreeBSD 14.0 EOL around 2025-03-01
+.if exists(/usr/lib/libc++.so) && !exists(/usr/include/c++/v1/__format/write_escaped.h)
+CXXFLAGS+=	-fexperimental-library
+.endif
+
+# XXX Drop after FreeBSD 13.3 EOL around 2025-07-01
+.if exists(/usr/lib/libc++.so) && !exists(/usr/include/c++/v1/__chrono/time_zone.h)
+LIB_DEPENDS+=	libdate-tz.so:devel/date
+USES+=		localbase:ldflags
+.endif
+
+post-install:
+	${INSTALL_DATA} ${WRKSRC}/pam/${PORTNAME} \
+		${STAGEDIR}${PREFIX}/etc/pam.d/${PORTNAME}
+
+# XXX Drop after FreeBSD 13.2 EOL around 2024-05-01 (don't forget distinfo)
+.if ${CXX} == c++ && exists(/usr/lib/libc++.so)
+.if !exists(/usr/include/c++/v1/expected) || make(makesum) || make(fetch)
+USES+=		llvm:min=16,build,export
+PATH:=		${LLVM_PREFIX}/bin:${PATH} # XXX _CMAKE_TOOLCHAIN_SUFFIX vs. devel/llvm*
+CONFIGURE_ENV+=	CC="${CC}" CXX="${CXX}" CPP="${CPP}"
+
+# XXX Move into separate port and standardize via USES
+GH_TUPLE+=	llvm:llvm-project:llvmorg-16.0.1:libcxx
+CXXFLAGS+=	-nostdinc++ -isystem${WRKDIR}/libcxx_prefix/include/c++/v1
+# Don't link against new libc++ as it's not necessary
+#LDFLAGS+=	-nostdlib++ -L${WRKDIR}/libcxx_prefix/lib -l:libc++.a -lcxxrt
+
+pre-configure:	bundled-libcxx
+bundled-libcxx:
+	@${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} \
+		-DLIBCXX_INCLUDE_BENCHMARKS:BOOL=OFF \
+		-DCMAKE_INSTALL_PREFIX:PATH=${WRKDIR}/libcxx_prefix \
+		-B ${WRKDIR}/libcxx_build -S ${WRKSRC_libcxx}/libcxx
+	@${DO_MAKE_BUILD:NDESTDIR*} install -C ${WRKDIR}/libcxx_build
+.endif
+.endif # exists(/usr/lib/libc++.so)
+
+.include <bsd.port.mk>
diff --git a/x11/hyprlock/distinfo b/x11/hyprlock/distinfo
new file mode 100644
index 000000000000..4a6e36a1b566
--- /dev/null
+++ b/x11/hyprlock/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1708723748
+SHA256 (hyprwm-hyprlock-s20240223-8969351_GH0.tar.gz) = c30cefee520fa06f6f955b5f65fb8ba117a7d32faf8ecf860176b1654a6afabe
+SIZE (hyprwm-hyprlock-s20240223-8969351_GH0.tar.gz) = 49265
+SHA256 (llvm-llvm-project-llvmorg-16.0.1_GH0.tar.gz) = b5a9ff1793b1e2d388a3819bf35797002b1d2e40bb35a10c65605e0ea1435271
+SIZE (llvm-llvm-project-llvmorg-16.0.1_GH0.tar.gz) = 179289803
diff --git a/x11/hyprlock/files/patch-pam b/x11/hyprlock/files/patch-pam
new file mode 100644
index 000000000000..044b0af3a847
--- /dev/null
+++ b/x11/hyprlock/files/patch-pam
@@ -0,0 +1,21 @@
+"su" has "auth sufficient pam_self.so" but a screen locker is
+supposed to ask for password regardless.
+
+pam_unix(8) requires root priveleges to access master.passwd(5),
+so try authenticating via setuid helper first.
+
+--- pam/hyprlock.orig	1970-01-01 00:00:00 UTC
++++ pam/hyprlock
+@@ -0,0 +1 @@
++auth include unix-selfauth
+--- src/core/Password.cpp.orig	2024-02-23 21:29:08 UTC
++++ src/core/Password.cpp
+@@ -30,7 +30,7 @@ std::shared_ptr<CPassword::SVerificationResult> CPassw
+         const pam_conv localConv = {conv, NULL};
+         pam_handle_t*  handle    = NULL;
+ 
+-        int            ret = pam_start("su", getlogin(), &localConv, &handle);
++        int            ret = pam_start("hyprlock", getlogin(), &localConv, &handle);
+ 
+         if (ret != PAM_SUCCESS) {
+             result->success    = false;
diff --git a/x11/hyprlock/pkg-descr b/x11/hyprlock/pkg-descr
new file mode 100644
index 000000000000..c84e12082d3d
--- /dev/null
+++ b/x11/hyprlock/pkg-descr
@@ -0,0 +1,8 @@
+Hyprland's simple, yet multi-threaded and GPU-accelerated screen
+locking utility.
+
+Features:
+ - uses the secure ext-session-lock protocol
+ - full support for fractional-scale
+ - fully GPU accelerated
+ - multi-threaded resource acquisition for no hitches