%global debug_package %{nil} %global _find_debuginfo_dwz_opts %{nil} %global _build_id_links none Name: systemd-lock-handler Version: 8 Release: %autorelease Summary: Systemd user service for lock/unlock events License: ISC URL: https://github.com/Infiniti151/systemd-lock-handler Source0: systemd-lock-handler.tar.gz Source1: go-amd64.tar.gz Source2: go-arm64.tar.gz BuildRequires: systemd-rpm-macros BuildRequires: go-rpm-macros BuildRequires: compiler(go-compiler) %description A systemd user service to handle lock/unlock events. %prep %setup -q -c -T echo "=*=*=*> Running Prep Phase <*=*=*=" tar -xf %{SOURCE0} --strip-components=1 echo "=== Extracted Source Tarball ===" mkdir -p ./go-home %ifarch x86_64 tar -C ./go-home -xf %{SOURCE1} echo "=== Extracted Go (amd64) Tarball ===" %endif %ifarch aarch64 tar -C ./go-home -xf %{SOURCE2} echo "=== Extracted Go (arm64) Tarball ===" %endif %build echo "=*=*=*> Running Build Phase <*=*=*=" GO_BIN=$(pwd)/go-home/go/bin/go if [ ! -x "$GO_BIN" ]; then echo "ERROR: Custom Go compiler not found at $GO_BIN" exit 1 fi echo "=== Go version: $($GO_BIN version) ===" export GOTOOLCHAIN=local export CGO_ENABLED=0 echo "=== Go environment ===" $GO_BIN env echo "=== Building systemd-lock-handler ===" $GO_BIN build -ldflags '-s -w' -o systemd-lock-handler main.go %check echo "=*=*=*> Running Check Phase <*=*=*=" GO_BIN=$(pwd)/go-home/go/bin/go export GOTOOLCHAIN=local echo "=== Package List ===" $GO_BIN list . echo "=== Running Tests ===" $GO_BIN test -v . %install echo "=*=*=*> Running Install Phase <*=*=*=" echo "Working directory: $(pwd)" echo "Buildroot: %{buildroot}" if [ ! -f systemd-lock-handler ]; then echo "ERROR: Binary 'systemd-lock-handler' not found in $(pwd)!" ls -lh exit 1 fi mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_userunitdir} echo "=== Installing binary to %{buildroot}%{_bindir}/ ===" install -m 755 systemd-lock-handler %{buildroot}%{_bindir}/ echo "=== Installing systemd units to %{buildroot}%{_userunitdir}/ ===" install -m 644 dist/systemd-lock-handler.service.ready %{buildroot}%{_userunitdir}/systemd-lock-handler.service install -m 644 dist/*.target %{buildroot}%{_userunitdir}/ echo "=== Final Buildroot Contents ===" find %{buildroot} -maxdepth 4 -not -path '*/.*' echo "=*=*=*> Finished Install Phase - Moving to File Manifest <*=*=*=" %files %license LICENCE %{_bindir}/systemd-lock-handler %{_userunitdir}/*.service %{_userunitdir}/*.target %post %systemd_user_post systemd-lock-handler.service %preun %systemd_user_preun systemd-lock-handler.service %postun %systemd_user_postun_with_restart systemd-lock-handler.service %changelog %autochangelog