systemd/dsme: fork from Alpine to add systemd support (MR 6160)

This commit is contained in:
Bart Ribbers 2025-02-05 19:02:35 +01:00 committed by Pablo Correa Gómez
parent dcf72bea5c
commit b7ac3683ad
No known key found for this signature in database
GPG key ID: 7A342565FF635F79
5 changed files with 193 additions and 0 deletions

View file

@ -0,0 +1,77 @@
This scripts assumes locations that are not valid on our system.
Also, we do not have a shutdown command available
This patch modifies the paths to our locations, and removes the shutdown command
diff --git a/reboot-via-dsme.sh b/reboot-via-dsme.sh
index cc97de0..40aee0f 100644
--- a/reboot-via-dsme.sh
+++ b/reboot-via-dsme.sh
@@ -11,9 +11,9 @@
# commands from interactive shell, but do the shutdown/reboot
# via dsme.
#
-# If needed, the real systemd binaries (e.g. reboot) can still
+# If needed, the real binaries (e.g. reboot) can still
# be invoked by using the full path:
-# # /usr/sbin/reboot
+# # /sbin/reboot
#
# Or by ignoring the shell functions via command:
# # command reboot
@@ -21,51 +21,18 @@
# Define shell functions for interactive shells only
case "$-" in *i*) ;; *) return ;; esac
-# Replace simple poweroff/halt/reboot/shutdown invocations
+# Replace simple poweroff/halt/reboot invocations
# with equivalent dsmetool operations
poweroff()
{
- [ "$#" -eq 0 ] && /usr/sbin/dsmetool --shutdown || /usr/sbin/poweroff "$@"
+ [ "$#" -eq 0 ] && /usr/sbin/dsmetool --shutdown || /sbin/poweroff "$@"
}
halt()
{
- [ "$#" -eq 0 ] && /usr/sbin/dsmetool --shutdown || /usr/sbin/halt "$@"
+ [ "$#" -eq 0 ] && /usr/sbin/dsmetool --shutdown || /sbin/halt "$@"
}
reboot()
{
- [ "$#" -eq 0 ] && /usr/sbin/dsmetool --reboot || /usr/sbin/reboot "$@"
-}
-shutdown()
-{
- DSME_SHUTDOWN_MODE="--shutdown"
- DSME_SHUTDOWN_TIME=""
- DSME_SHUTDOWN_MESG=""
- DSME_SHUTDOWN_UNKN=""
- for f in "$@"; do
- case "$f" in
- -H|--halt|-P|--poweroff|-h)
- DSME_SHUTDOWN_MODE="--shutdown"
- ;;
- -r|--reboot)
- DSME_SHUTDOWN_MODE="--reboot"
- ;;
- -*)
- DSME_SHUTDOWN_UNKN="y"
- ;;
- *)
- if [ -z "$DSME_SHUTDOWN_TIME" ]; then
- DSME_SHUTDOWN_TIME="$f"
- else
- DSME_SHUTDOWN_MESG="$f"
- fi
- ;;
- esac
- done
- [ "${DSME_SHUTDOWN_TIME:-now}" = "now" ] && \
- [ "$DSME_SHUTDOWN_MESG" = "" ] && \
- [ "$DSME_SHUTDOWN_UNKN" = "" ] && \
- /usr/sbin/dsmetool "$DSME_SHUTDOWN_MODE" || /usr/sbin/shutdown "$@"
- unset DSME_SHUTDOWN_MODE DSME_SHUTDOWN_TIME
- unset DSME_SHUTDOWN_MESG DSME_SHUTDOWN_UNKN
+ [ "$#" -eq 0 ] && /usr/sbin/dsmetool --reboot || /sbin/reboot "$@"
}

View file

@ -0,0 +1,16 @@
We don't care about warnings, we just want it to compile and work
Needed to compile on 32-bit arches
diff --git a/configure.ac b/configure.ac
index ff15596..d502682 100644
--- a/configure.ac
+++ b/configure.ac
@@ -185,7 +185,7 @@ fi
AC_SUBST(CPP_GENFLAGS, ["-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"])
-AC_SUBST(C_GENFLAGS, ["-pthread -g -std=c99 -Wall -Wwrite-strings -Wmissing-prototypes -Werror -Wshadow"])
+AC_SUBST(C_GENFLAGS, ["-pthread -g -std=c99 -Wall -Wwrite-strings -Wmissing-prototypes -Wshadow"])
AC_SUBST(C_OPTFLAGS, ["-O2"])
AC_SUBST(C_DBGFLAGS, ["-g -DDEBUG"])

View file

@ -0,0 +1,88 @@
# Forked from Alpine to enable systemd support
maintainer="Bart Ribbers <bribbers@disroot.org>"
pkgname=dsme
pkgver=99990.84.4
_pkgver=0.84.4
pkgrel=0
_commit_dbusglib="d42176ae4763e5288ef37ea314fe58387faf2005"
pkgdesc="Device State Management Entity"
url="https://github.com/sailfishos/dsme"
arch="all"
license="LGPL-2.1-only"
depends_dev="
cryptsetup-dev
libiphb-dev
libngf-dev
"
makedepends="$depends_dev
autoconf
automake
libtool
systemd-dev
"
subpackages="$pkgname-dev $pkgname-openrc $pkgname-systemd"
source="https://github.com/sailfishos/dsme/archive/$_pkgver/dsme-$_pkgver.tar.gz
https://github.com/sailfishos-mirror/dbus-glib/archive/$_commit_dbusglib/dbus-glib-$_commit_dbusglib.tar.gz
0001-correct-paths.patch
0002-disable-werror.patch
dsme.initd
dsme.confd
"
options="!check" # Only test comes from dbus-glib and fails
builddir="$srcdir/$pkgname-$_pkgver"
prepare() {
default_prepare
rmdir dbus-gmain
mv "$srcdir/dbus-glib-$_commit_dbusglib" dbus-gmain
}
build() {
./autogen.sh
./configure \
--build=$CBUILD \
--host=$CHOST \
--prefix=/usr \
--exec_prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--localstatedir=/var \
--disable-static \
--disable-poweron-timer \
--disable-upstart \
--disable-validatorlistener \
--enable-pwrkeymonitor \
--enable-abootsettings \
--enable-usewheel \
--enable-systemd
make
}
package() {
make DESTDIR="$pkgdir" install
install -Dm644 reboot-via-dsme.sh -t "$pkgdir"/etc/profile.d/
install -Dm755 "$srcdir"/dsme.initd "$pkgdir"/etc/init.d/dsme
install -Dm644 "$srcdir"/dsme.confd "$pkgdir"/etc/conf.d/dsme
# Remove installed tests
rm -r "$pkgdir"/opt
mkdir -p "$pkgdir"/usr/share/dbus-1/system.d/
mv "$pkgdir"/etc/dbus-1/system.d/* "$pkgdir"/usr/share/dbus-1/system.d/
mkdir -p "$pkgdir"/usr/lib/systemd/system
sed -e "s|@LIBDIR@|/usr/lib|g" rpm/dsme.service.in > "$pkgdir"/usr/lib/systemd/system/dsme.service
}
sha512sums="
abda54469edb9470f4dd876758c9160d92bb4668083c9295f9e311f526797ffffc483a102f1d11fd55d6138f19cb05dc2bf29b20ebca9d7af6019ddac8ad1fb4 dsme-0.84.4.tar.gz
665cd6395ee0ea14086ba30188c62a72697b3f63484681e18fc7f54109c9aca162f2e33aa2fa4d45287c6c0b590e81ca310c143dac0232cd5887692cdaf51256 dbus-glib-d42176ae4763e5288ef37ea314fe58387faf2005.tar.gz
063ce9f2bd13fb2bd05ab9cd11544265eb5378562ee1fbed1cfa65d2345d092cfcff69f57589d3914005c31a00a58f3993cc13b59615ebe0f48458ba478d8772 0001-correct-paths.patch
2b18c6affaefa786358c07480968fd744370c48452c05e969cc8b26cba5307279ce51f782f42778fbd597bf29ec3d90b7b1ee4d182e8ab41675d1070be2f1954 0002-disable-werror.patch
786971b4a8f9cff0b66db658d9b8a2c4ceaaf1c5baa4b62346b9e0a2ab6f46ff3225a60678cb7ddd78e4e9e70fbe41432581e32ebccfa4174375dc79fea49a84 dsme.initd
b841282b96110ec59a7aa539db0737327b09549d55c78dc4b2c3b28b4a6ad1facf015b3175cb6d3a38f13e47aa6314ef3dc1514a4e60dd653a97409ec54ba706 dsme.confd
"

View file

@ -0,0 +1 @@
supervisor=supervise-daemon

View file

@ -0,0 +1,11 @@
#!/sbin/openrc-run
name="DSME"
description="Device State Management Entity"
command=/usr/sbin/dsme
command_args="-- -p /usr/lib/dsme/startup.so"
depend() {
need dbus
}