commit:     489930e0c504439316323b1e20abe3244c9ad9b7
Author:     Marco Scardovi <marco <AT> scardovi <DOT> com>
AuthorDate: Fri Jun 25 19:04:36 2021 +0000
Commit:     Marco Scardovi <marco <AT> scardovi <DOT> com>
CommitDate: Fri Jun 25 19:04:36 2021 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=489930e0

sys-boot/osk-sdl: add new package

Package-Manager: Portage-3.0.20, Repoman-3.0.3
Signed-off-by: Marco Scardovi <marco <AT> scardovi.com>

 sys-boot/osk-sdl/Manifest                 |  1 +
 sys-boot/osk-sdl/files/module-setup.sh    | 29 +++++++++++++++
 sys-boot/osk-sdl/files/osk-sdl-pp.conf    |  2 +
 sys-boot/osk-sdl/files/osk-sdl-pp.path    | 21 +++++++++++
 sys-boot/osk-sdl/files/osk-sdl-pp.service | 21 +++++++++++
 sys-boot/osk-sdl/files/osk-sdl.sh         | 49 ++++++++++++++++++++++++
 sys-boot/osk-sdl/metadata.xml             |  8 ++++
 sys-boot/osk-sdl/osk-sdl-0.64.ebuild      | 62 +++++++++++++++++++++++++++++++
 8 files changed, 193 insertions(+)

diff --git a/sys-boot/osk-sdl/Manifest b/sys-boot/osk-sdl/Manifest
new file mode 100644
index 000000000..907091802
--- /dev/null
+++ b/sys-boot/osk-sdl/Manifest
@@ -0,0 +1 @@
+DIST osk-sdl-0.64.tar.gz 37851 BLAKE2B 
dc297a0b1879f7b64bceb3032275b30f10072c50a2e2ddd985e94136ebf2308819fe71ca831fcc05d413c5e74f8ab955d920cc63bd90529e0c45fd3b6aae44db
 SHA512 
0da985e1e8d0352f53f661dd4f7f6243a8f9b48279297f4ea3b120aa239c733411a83d324b58d152cafd9c2e7a791a36506afec6449e141c6445f0420bb9fd6b

diff --git a/sys-boot/osk-sdl/files/module-setup.sh 
b/sys-boot/osk-sdl/files/module-setup.sh
new file mode 100644
index 000000000..f27d34582
--- /dev/null
+++ b/sys-boot/osk-sdl/files/module-setup.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# called by dracut
+check() {
+    return 0
+}
+
+# called by dracut
+depends() {
+    echo drm crypt
+    return 0
+}
+
+# called by dracut
+install() {
+    inst_multiple "/etc/osk.conf" \
+        "/usr/share/glvnd/egl_vendor.d/50_mesa.json" \
+        "/usr/share/fonts/dejavu/DejaVuSans.ttf" \
+        osk-sdl
+    inst_simple $moddir/osk-sdl.sh /usr/bin/osk-sdl.sh
+    inst_simple $moddir/osk-sdl-pp.service 
${systemdsystemunitdir}/osk-sdl-pp.service
+    inst_simple $moddir/osk-sdl-pp.path ${systemdsystemunitdir}/osk-sdl-pp.path
+    systemctl -q --root "$initdir" add-wants sysinit.target osk-sdl-pp.path
+    # mesa cogl libglvnd
+    equery f mesa cogl libglvnd | grep ".so$" | while read -r so; do
+      inst ${so}
+    done
+
+}

diff --git a/sys-boot/osk-sdl/files/osk-sdl-pp.conf 
b/sys-boot/osk-sdl/files/osk-sdl-pp.conf
new file mode 100644
index 000000000..bc5ec8bf0
--- /dev/null
+++ b/sys-boot/osk-sdl/files/osk-sdl-pp.conf
@@ -0,0 +1,2 @@
+# dracut config, need osk-sdl for encrypted root, uncomment the following line 
to enable it in initramfs
+#add_dracutmodules+=" osk-sdl "

diff --git a/sys-boot/osk-sdl/files/osk-sdl-pp.path 
b/sys-boot/osk-sdl/files/osk-sdl-pp.path
new file mode 100644
index 000000000..5a386bdaf
--- /dev/null
+++ b/sys-boot/osk-sdl/files/osk-sdl-pp.path
@@ -0,0 +1,21 @@
+#  SPDX-License-Identifier: LGPL-2.1-or-later
+#
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Run on screen keyboard to unlock root dev path watch
+DefaultDependencies=no
+Conflicts=shutdown.target emergency.service
+Before=systemd-ask-password-console.service 
systemd-ask-password-plymouth.service systemd-fsck-root.service paths.target 
shutdown.target
+
+[Path]
+PathExists=/dev/null
+# touch screen
+#PathExists=/dev/input/by-path/platform-1c2ac00.i2c-event
+# video
+PathExists=/dev/dri/renderD128/

diff --git a/sys-boot/osk-sdl/files/osk-sdl-pp.service 
b/sys-boot/osk-sdl/files/osk-sdl-pp.service
new file mode 100644
index 000000000..e5445b7cc
--- /dev/null
+++ b/sys-boot/osk-sdl/files/osk-sdl-pp.service
@@ -0,0 +1,21 @@
+#  SPDX-License-Identifier: LGPL-2.1-or-later
+#
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Run on screen keyboard to unlock root
+DefaultDependencies=no
+Conflicts=shutdown.target
+After=systemd-modules-load.service systemd-udevd.service
+Before=systemd-ask-password-console.service 
systemd-ask-password-plymouth.service systemd-fsck-root.service
+ConditionPathExists=!/dev/mapper/root
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/osk-sdl.sh
+RemainAfterExit=true

diff --git a/sys-boot/osk-sdl/files/osk-sdl.sh 
b/sys-boot/osk-sdl/files/osk-sdl.sh
new file mode 100755
index 000000000..36cba93e8
--- /dev/null
+++ b/sys-boot/osk-sdl/files/osk-sdl.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+# stolen from postmarket
+# 
https://gitlab.com/postmarketOS/pmaports/-/blob/master/main/postmarketos-mkinitfs/init_functions.sh
+find_crypt_partition() {
+       # The partition layout is one of the following:
+       # a) boot, root partitions on sdcard
+       # b) boot, root partition on the "system" partition (which has its
+       #    own partition header! so we have partitions on partitions!)
+       #
+       # mount_subpartitions() must get executed before calling
+       # find_root_partition(), so partitions from b) also get found.
+
+       # Short circuit all autodetection logic if pmos_root= is supplied
+       # on the kernel cmdline
+       # shellcheck disable=SC2013
+       for x in $(cat /proc/cmdline); do
+               [ "$x" = "${x#cryptroot=}" ] && continue
+               DEVICE="${x#cryptroot=}"
+       done
+       echo "$DEVICE"
+}
+
+setup_directfb_tslib() {
+       # Set up directfb and tslib
+       # Note: linux_input module is disabled since it will try to take over
+       # the touchscreen device from tslib (e.g. on the N900)
+       export SDL_VIDEO_DRIVER="kmsdrm"
+       export SDL_RENDER_DRIVER="software"
+       #export DFBARGS="system=fbdev,no-cursor,disable-module=linux_input"
+       # shellcheck disable=SC2154
+       if [ -n "$deviceinfo_dev_touchscreen" ]; then
+               export TSLIB_TSDEVICE="$deviceinfo_dev_touchscreen"
+       fi
+}
+
+start_onscreen_keyboard() {
+       setup_directfb_tslib
+       sleep 1 # wait for dev settle
+       /usr/bin/osk-sdl -n root -d "$partition" -c /etc/osk.conf 
+       unset DFBARGS
+       unset TSLIB_TSDEVICE
+}
+
+unlock_root_partition() {
+       partition="$(find_crypt_partition)"
+       start_onscreen_keyboard
+}
+
+unlock_root_partition

diff --git a/sys-boot/osk-sdl/metadata.xml b/sys-boot/osk-sdl/metadata.xml
new file mode 100644
index 000000000..144c8091c
--- /dev/null
+++ b/sys-boot/osk-sdl/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <maintainer type="person">
+               <email>ma...@scardovi.com</email>
+               <name>Marco Scardovi</name>
+       </maintainer>
+</pkgmetadata>

diff --git a/sys-boot/osk-sdl/osk-sdl-0.64.ebuild 
b/sys-boot/osk-sdl/osk-sdl-0.64.ebuild
new file mode 100644
index 000000000..1f8daa085
--- /dev/null
+++ b/sys-boot/osk-sdl/osk-sdl-0.64.ebuild
@@ -0,0 +1,62 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit meson
+
+COMMIT="69fb2d943a8664d5a587c967ac828f9ed5acd7ce"
+
+DESCRIPTION="Lightweight On-Screen-Keyboard based on SDL2"
+HOMEPAGE="https://gitlab.com/postmarketOS/osk-sdl";
+SRC_URI="https://gitlab.com/postmarketOS/osk-sdl/-/archive/${COMMIT}.tar.gz -> 
${P}.tar.gz"
+
+LICENSE="GPL-3"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64"
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+       app-portage/gentoolkit
+       media-libs/cogl
+       media-fonts/dejavu
+       media-libs/libglvnd
+       media-libs/libsdl2[kms,haptic]
+       media-libs/mesa
+       media-libs/sdl2-ttf
+       sys-fs/cryptsetup
+       sys-kernel/dracut
+"
+
+BDEPEND="
+       app-text/scdoc
+       test? ( x11-misc/xvfb-run )
+"
+
+S="${WORKDIR}/${PN}-${COMMIT}"
+
+src_prepare() {
+       default
+       sed -e s/ttf-dejavu/dejavu/ -i osk.conf || die "Failed to sed"
+}
+
+src_install() {
+       meson_src_install
+       insinto /etc
+       doins osk.conf
+       insinto /etc/dracut.conf.d/
+       doins "${FILESDIR}"/osk-sdl-pp.conf
+       insinto /usr/lib/dracut/modules.d/50osk-sdl
+       doins "${FILESDIR}"/osk-sdl-pp.path
+       doins "${FILESDIR}"/osk-sdl-pp.service
+       exeinto /usr/lib/dracut/modules.d/50osk-sdl
+       doexe "${FILESDIR}"/module-setup.sh
+       doexe "${FILESDIR}"/osk-sdl.sh
+}
+
+pkg_postinst() {
+       einfo "For more info on how to test osk-sdl, and how to report 
problems, see: ${HOMEPAGE}"
+       einfo "To use osk-sdl to unlock encrypted root at bootime, check 
osk-sdl-pp.conf in /etc/dracut.conf.d"
+       einfo "and add these boot option 'root=/dev/mapper/root 
cryptroot=/dev/path/to/encrypted_partition' "
+}

Reply via email to