From 7330ea61610238006f36ec520d177a4bb27971ab Mon Sep 17 00:00:00 2001
From: Caleb Connolly <caleb@postmarketos.org>
Date: Wed, 6 Mar 2024 23:31:11 +0000
Subject: [PATCH] systemd/postmarketos-base-systemd: new aport

postmarketOS base package with systemd stuff.
---
 systemd/postmarketos-base-systemd/APKBUILD    | 58 +++++++++++++++++++
 .../rootfs-etc-motd.ansi                      | 13 +++++
 .../rootfs-etc-profile.d-99motd.sh            |  6 ++
 .../rootfs-etc-ssh-sshd_config.d-usepam.conf  |  2 +
 .../rootfs-etc-systemd-logind.conf            | 35 +++++++++++
 .../rootfs-usr-bin-setup-timezone             | 19 ++++++
 6 files changed, 133 insertions(+)
 create mode 100644 systemd/postmarketos-base-systemd/APKBUILD
 create mode 100644 systemd/postmarketos-base-systemd/rootfs-etc-motd.ansi
 create mode 100644 systemd/postmarketos-base-systemd/rootfs-etc-profile.d-99motd.sh
 create mode 100644 systemd/postmarketos-base-systemd/rootfs-etc-ssh-sshd_config.d-usepam.conf
 create mode 100644 systemd/postmarketos-base-systemd/rootfs-etc-systemd-logind.conf
 create mode 100644 systemd/postmarketos-base-systemd/rootfs-usr-bin-setup-timezone

diff --git a/systemd/postmarketos-base-systemd/APKBUILD b/systemd/postmarketos-base-systemd/APKBUILD
new file mode 100644
index 00000000000..3797f37fee4
--- /dev/null
+++ b/systemd/postmarketos-base-systemd/APKBUILD
@@ -0,0 +1,58 @@
+# Maintainer: Oliver Smith <ollipearanoid@postmarketos.org>
+# pmbootstrap installs this, if systemd is selected in "pmbootstrap init".
+pkgname=postmarketos-base-systemd
+pkgver=1
+pkgrel=0
+pkgdesc="Meta package for running postmarketOS with systemd"
+url="https://postmarketos.org"
+arch="noarch"
+license="GPL-3.0-or-later"
+options="!check"
+depends="
+	openssh-server-pam
+	polkit
+	systemd
+	tzdata
+	linux-pam=1.5.3-r8
+	"
+replaces="alpine-baselayout postmarketos-base systemd"
+
+_source644="
+	etc/motd.ansi
+	etc/profile.d/99motd.sh
+	etc/systemd/logind.conf
+	etc/ssh/sshd_config.d/usepam.conf
+"
+
+_source755="
+	usr/bin/setup-timezone
+"
+
+flatpath() {
+	local i
+	for i in $@; do
+		echo "rootfs-$i" | sed s./.-.g
+	done
+}
+source="$(flatpath $_source644 $_source755)"
+
+package() {
+	local i
+	for i in $_source644; do
+		install -Dm644 "$srcdir/$(flatpath "$i")" "$pkgdir/$i"
+	done
+	for i in $_source755; do
+		install -Dm755 "$srcdir/$(flatpath "$i")" "$pkgdir/$i"
+	done
+
+	# This gets printed still so overwrite it with an empty file.
+	touch $pkgdir/etc/motd
+}
+
+sha512sums="
+a6c27ab5d365807a40b16328918b6ca3d7f97a4128381674001cf46133928d8bb073ff4691b78c82f7965bcc2649d7ca4bf3e7453dd61be9b9341bbe6b448fd6  rootfs-etc-motd.ansi
+fbaa33425e507062a454f11bda48508f261c2144e5c23a20f567dc1cef14ce1dec57f8d934f418f5b6095509757f8503481aba9790a04c8f9f6995e65833d8c9  rootfs-etc-profile.d-99motd.sh
+2faac294bb632762e247b850f09ff4b544ccff6c462efd8d4faca71ba30bdfa9c460377a0dc88e92c5dbbe251017d164064a56ac0e0410f224b45d4f5f81866c  rootfs-etc-systemd-logind.conf
+208f53c1d142151277cfcf0a95df839919ce8cb15ec888d50890dc6b3631a994335bfa12194cec856b649f97cfd7c80019c595cc0ea2c5ee96498a3e76a9950b  rootfs-etc-ssh-sshd_config.d-usepam.conf
+605df1f004783d2e0ec5dd99a688bca27502c8c24bc05fb4dc26589b2070b0fbd1cf9bd56e6861d7cda2f8ac8147e7eb040acfd886185c01c8cf9de8b1ce2dcd  rootfs-usr-bin-setup-timezone
+"
diff --git a/systemd/postmarketos-base-systemd/rootfs-etc-motd.ansi b/systemd/postmarketos-base-systemd/rootfs-etc-motd.ansi
new file mode 100644
index 00000000000..d08a886a3f5
--- /dev/null
+++ b/systemd/postmarketos-base-systemd/rootfs-etc-motd.ansi
@@ -0,0 +1,13 @@
+\033[1;33mNOTICE:\033[22m This build is for showcasing systemd support, it is buggy,
+unreliable, and NOT suitable for use on devices you rely on.
+
+As there is no binary repository for systemd packages yet, please
+do not run \033[38;5;252mapk upgrade -a\033[33m as it *will* break your system.
+
+For up to date info on the state of systemd support in postmarketOS,
+please see \033[38;5;75mhttps://postmarketos.org/systemd\033[0m
+
+This distribution is based on Alpine Linux.
+First time using postmarketOS? Make sure to read the cheatsheet in the wiki:
+
+-> \033[38;5;75mhttps://postmarketos.org/cheatsheet\033[0m
diff --git a/systemd/postmarketos-base-systemd/rootfs-etc-profile.d-99motd.sh b/systemd/postmarketos-base-systemd/rootfs-etc-profile.d-99motd.sh
new file mode 100644
index 00000000000..adc34ee06cd
--- /dev/null
+++ b/systemd/postmarketos-base-systemd/rootfs-etc-profile.d-99motd.sh
@@ -0,0 +1,6 @@
+# Very minimal ANSI motd
+. /etc/os-release
+
+echo
+echo -e "  Welcome to \033[32mpostmarketOS $VERSION\033[0m/\033[97msystemd\033[0m! ^^\n"
+echo -e "$(cat /etc/motd.ansi | sed 's/^/  /')"
diff --git a/systemd/postmarketos-base-systemd/rootfs-etc-ssh-sshd_config.d-usepam.conf b/systemd/postmarketos-base-systemd/rootfs-etc-ssh-sshd_config.d-usepam.conf
new file mode 100644
index 00000000000..2770cb3d6d6
--- /dev/null
+++ b/systemd/postmarketos-base-systemd/rootfs-etc-ssh-sshd_config.d-usepam.conf
@@ -0,0 +1,2 @@
+# postmarketOS: enable PAM auth for environment configuration
+UsePAM yes
diff --git a/systemd/postmarketos-base-systemd/rootfs-etc-systemd-logind.conf b/systemd/postmarketos-base-systemd/rootfs-etc-systemd-logind.conf
new file mode 100644
index 00000000000..7bd2a1b5907
--- /dev/null
+++ b/systemd/postmarketos-base-systemd/rootfs-etc-systemd-logind.conf
@@ -0,0 +1,35 @@
+# This file is provided by postmarketos-base. See logind.conf(5) for details.
+
+[Login]
+#NAutoVTs=6
+#ReserveVT=6
+#KillUserProcesses=no
+#KillOnlyUsers=
+#KillExcludeUsers=root
+#InhibitDelayMaxSec=5
+#UserStopDelaySec=10
+HandlePowerKey=ignore
+#HandlePowerKeyLongPress=ignore
+#HandleRebootKey=reboot
+#HandleRebootKeyLongPress=poweroff
+#HandleSuspendKey=suspend
+#HandleSuspendKeyLongPress=hibernate
+#HandleHibernateKey=hibernate
+#HandleHibernateKeyLongPress=ignore
+#HandleLidSwitch=suspend
+#HandleLidSwitchExternalPower=suspend
+#HandleLidSwitchDocked=ignore
+#PowerKeyIgnoreInhibited=no
+#SuspendKeyIgnoreInhibited=no
+#HibernateKeyIgnoreInhibited=no
+#LidSwitchIgnoreInhibited=yes
+#RebootKeyIgnoreInhibited=no
+#HoldoffTimeoutSec=30s
+#IdleAction=ignore
+#IdleActionSec=30min
+#RuntimeDirectorySize=10%
+#RuntimeDirectoryInodesMax=
+#RemoveIPC=yes
+#InhibitorsMax=8192
+#SessionsMax=8192
+#StopIdleSessionSec=infinity
diff --git a/systemd/postmarketos-base-systemd/rootfs-usr-bin-setup-timezone b/systemd/postmarketos-base-systemd/rootfs-usr-bin-setup-timezone
new file mode 100644
index 00000000000..9a84325b915
--- /dev/null
+++ b/systemd/postmarketos-base-systemd/rootfs-usr-bin-setup-timezone
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+# Stub that implements a simplified version of Alpine's setup-timezone, so
+# pmbootstrap can call it during "pmbootstrap install" without having a
+# dependency on alpine-conf, which in turn depends on openrc.
+
+if [ "$#" != "2" ] || [ "$1" != "-i" ]; then
+	echo "setup-timezone stub from postmarketos-base-systemd"
+	echo "usage: setup-timezone -i TIMEZONE"
+	exit 1
+fi
+
+TZ_FILE="/usr/share/zoneinfo/$2"
+
+if ! [ -e "$TZ_FILE" ]; then
+	echo "ERROR: not found: $TZ_FILE"
+	exit 1
+fi
+
+ln -sf "$TZ_FILE" /etc/localtime
-- 
GitLab