On Wed, Mar 27, 2024 at 01:41:49PM +0800, ericwq057 wrote:
> I search fedora39/centos 7, there is no available rpm package for
> utmps or skalibs. Asked google, there is only a very old (1.6) skalibs
> rpm spec available: https://github.com/imeyer/skalibs-rpm. Is there
> any plan to support rpm package? Recently I prepared to build rpm
> package for my project. Maybe I can help to build rpm package for
> skalibs and utmps. But I definitely need your help for rpm package.

Attached is spec code that builds a monolithic RPM package for skalibs,
execline and s6, tested under CentOS 7 and Rocky Linux 8; it needs to be
used with <https://github.com/CasperVector/ihep-pkg-ose>.  It uses ugly
tricks, most importantly invoking sudo to move files from/to root-owned
directories, and is therefore mostly intended for reference purpose
(apart from where it is actually used -- part of some EPICS-related
work which I plan to publish later this year).

-- 
My current OpenPGP key:
RSA4096/0x227E8CAAB7AA186C (expires: 2024.09.30)
7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C

%define skaver 2.13.1.1
%define execver 2.9.3.0

Name:           s6
Version:        2.11.3.2
Release:        2.el%{rhel}
Summary:        skarnet's small and secure supervision software suite

License:        ISC
URL:            https://skarnet.org/software/s6/
Source0:        https://skarnet.org/software/skalibs/skalibs-%{skaver}.tar.gz
Source1:        https://skarnet.org/software/execline/execline-%{execver}.tar.gz
Source2:        https://skarnet.org/software/s6/s6-%{version}.tar.gz
Patch0:         %{name}-files.patch

BuildRequires:  gcc, make

%description

%prep
%setup -T -c -n %{name}
. %{_specdir}/fn-build.sh
tar xpf %{S:0}; _mv_commit skalibs %{skaver}
tar xpf %{S:1}; _mv_commit execline %{execver}
tar xpf %{S:2}; _mv_commit s6 %{version}
patch -p1 < %{P:0}

%build
stat -c '%a' /bin > bin.mod; stat -c '%a' %{_libdir} > libdir.mod
sudo chmod 0755 %{_bindir} %{_libdir}
%_chown_me %{_bindir} %{_libexecdir} %{_libdir} %{_includedir}
confargs='--bindir=%{_bindir} --libexecdir=%{_libexecdir} --disable-shared'
confargs="$confargs --with-sysdep-devurandom=yes --with-sysdep-posixspawn=no"
for pkg in skalibs execline s6; do cd "$pkg"
        sed -i 's@/usr/lib\>@%{_libdir}@' configure
        ./configure $confargs; make %{?_smp_mflags}
        mkdir image; make install; make DESTDIR="$PWD"/image install
cd -; done

%install
. %{_specdir}/fn-build.sh; mkdir rm
_mv_me "$PWD"/rm %{_bindir} %{_libexecdir} %{_libdir} %{_includedir}
sudo chmod "$(cat bin.mod)" %{_bindir}
sudo chmod "$(cat libdir.mod)" %{_libdir}
for pkg in skalibs execline s6; do
        cp -a "$pkg"/image/* %{buildroot}
done
cd %{buildroot}%{_bindir}; rm cd umask; mv wait execline-wait; cd -
mkdir -p %{buildroot}%{_prefix}/lib/systemd/system \
        %{buildroot}/var/service/.s6-svscan
install -m 0644 *.service %{buildroot}%{_prefix}/lib/systemd/system
install -m 0755 crash SIGTERM %{buildroot}/var/service/.s6-svscan
%_file_list %{_bindir} %{_libexecdir} > files.lst

%files -f %{_builddir}/%{name}/files.lst
%{_includedir}/skalibs
%{_includedir}/execline
%{_includedir}/s6
%{_libdir}/skalibs
%{_libdir}/execline
%{_libdir}/s6
%{_prefix}/lib/systemd/system/*.service
/var/service/.s6-svscan/*

diff -Nur 0/crash 1/crash
--- 0/crash	1970-01-01 08:00:00.000000000 +0800
+++ 1/crash	2023-12-20 23:21:29.956693399 +0800
@@ -0,0 +1,2 @@
+#!/bin/sh -
+
diff -Nur 0/s6.service 1/s6.service
--- 0/s6.service	1970-01-01 08:00:00.000000000 +0800
+++ 1/s6.service	2023-12-20 23:22:47.352897253 +0800
@@ -0,0 +1,14 @@
+[Unit]
+Description=s6
+Wants=rc-local.service
+After=rc-local.service
+
+[Service]
+ExecStart=/bin/execline-cd /var/service emptyenv -p s6-svscan
+ExecReload=/usr/bin/s6-svscanctl -h /var/service
+KillMode=mixed
+Restart=always
+
+[Install]
+WantedBy=multi-user.target
+
diff -Nur 0/SIGTERM 1/SIGTERM
--- 0/SIGTERM	1970-01-01 08:00:00.000000000 +0800
+++ 1/SIGTERM	2023-12-20 23:21:29.956693399 +0800
@@ -0,0 +1,3 @@
+#!/bin/sh -
+exec s6-svscanctl -t .
+

Reply via email to