diff options
author | Xiao Pan <xyz@flylightning.xyz> | 2024-12-16 18:44:05 -0800 |
---|---|---|
committer | Xiao Pan <xyz@flylightning.xyz> | 2024-12-16 18:48:49 -0800 |
commit | cf6365c0957253940b8fae7e1a606105c6a2754c (patch) | |
tree | df259da4c45432c0fc3d2d2b496d226664ca94ce | |
parent | 75c587ea9c4b8bf19ef6eec11a6e0aed508f3dac (diff) |
Add osk-sdl PKGBUILD from danctnix Pine64-Arch
https://github.com/dreemurrs-embedded/Pine64-Arch
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | pkgbuilds/osk-sdl/PKGBUILD | 44 | ||||
-rw-r--r-- | pkgbuilds/osk-sdl/fix-compiling-for-gcc12.patch | 10 | ||||
-rw-r--r-- | pkgbuilds/osk-sdl/fix-config-parsing-with-libstdc++.patch | 39 | ||||
-rw-r--r-- | pkgbuilds/osk-sdl/osk-sdl-hooks | 69 | ||||
-rw-r--r-- | pkgbuilds/osk-sdl/osk-sdl-install | 59 |
6 files changed, 222 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index 5ed126e..89f14ef 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /*/** !/*/*/ !/*/*/PKGBUILD +!/pkgbuilds/*/* diff --git a/pkgbuilds/osk-sdl/PKGBUILD b/pkgbuilds/osk-sdl/PKGBUILD new file mode 100644 index 0000000..8f1a9e3 --- /dev/null +++ b/pkgbuilds/osk-sdl/PKGBUILD @@ -0,0 +1,44 @@ +# Maintainer: Danct12 <danct12@disroot.org> +# Contributor: Lance G. <gero3977@gmail.com> + +pkgname=osk-sdl +pkgver=0.66 +pkgrel=5 +pkgdesc="SDL2 On-screen Keyboard for FDE" +arch=(x86_64 armv7h aarch64) +url="https://gitlab.com/postmarketOS/osk-sdl" +license=('GPL3') +depends=(device-mapper cryptsetup sdl2 sdl2_ttf mesa ttf-dejavu) +makedepends=(scdoc meson) +source=($pkgname-$pkgver.tar.gz::https://gitlab.com/postmarketOS/osk-sdl/-/archive/$pkgver/$pkgname-$pkgver.tar.gz + osk-sdl-hooks + osk-sdl-install + fix-compiling-for-gcc12.patch + fix-config-parsing-with-libstdc++.patch) + +prepare() { + cd "$pkgname-$pkgver" + patch -u -p0 --input="${srcdir}/fix-compiling-for-gcc12.patch" + patch -u -p0 --input="${srcdir}/fix-config-parsing-with-libstdc++.patch" +} + +build() { + arch-meson "$pkgname-$pkgver" _build + meson compile -C _build +} + +package() { + DESTDIR="$pkgdir" meson install --no-rebuild -C _build + + # DejaVu is on a different directory than default + sed -i 's/\/usr\/share\/fonts\/ttf-dejavu/\/usr\/share\/fonts\/TTF/g' ${pkgdir}/etc/osk.conf + + # Install initramfs + install -Dm644 ${srcdir}/osk-sdl-hooks ${pkgdir}/usr/lib/initcpio/hooks/osk-sdl + install -Dm644 ${srcdir}/osk-sdl-install ${pkgdir}/usr/lib/initcpio/install/osk-sdl +} +md5sums=('fb608060dea423d221bdfff9a6101624' + '32b89734fc22fe0dc470e10c3c2e8034' + '1b164376ca6c3ee358d5cdd7533a20da' + '8fef952dada64ff63040b5406e71ecac' + 'e6dff50a2f9a27d5de92437394e9cfda') diff --git a/pkgbuilds/osk-sdl/fix-compiling-for-gcc12.patch b/pkgbuilds/osk-sdl/fix-compiling-for-gcc12.patch new file mode 100644 index 0000000..424b691 --- /dev/null +++ b/pkgbuilds/osk-sdl/fix-compiling-for-gcc12.patch @@ -0,0 +1,10 @@ +--- src/keyboard.h ++++ src/keyboard.h +@@ -22,6 +22,7 @@ + #include "config.h" + #include <SDL2/SDL.h> + #include <SDL2/SDL_ttf.h> ++#include <array> + #include <cmath> + #include <cstdint> + #include <list> diff --git a/pkgbuilds/osk-sdl/fix-config-parsing-with-libstdc++.patch b/pkgbuilds/osk-sdl/fix-config-parsing-with-libstdc++.patch new file mode 100644 index 0000000..2e60e4f --- /dev/null +++ b/pkgbuilds/osk-sdl/fix-config-parsing-with-libstdc++.patch @@ -0,0 +1,39 @@ +--- src/config.cpp ++++ src/config.cpp +@@ -175,24 +175,26 @@ + std::istringstream iss(line); + std::string id, eq, val; + +- bool error = false; +- +- if (!(iss >> id)) { +- continue; +- } else if (id[0] == '#') { ++ iss >> id; ++ if (iss.fail()) { + continue; + } else if (id.empty()) { + continue; +- } else if (!(iss >> eq >> val >> std::ws) || eq != "=" || iss.get() != EOF) { +- error = true; ++ } else if (id[0] == '#') { ++ continue; + } + +- if (error) { ++ iss >> eq >> val; ++ // check that: ++ // 1) fail/bad bits aren't set ++ // 2) eq field is '=' ++ // 3) that there are no trailing fields, after ignoring any trailing whitespace ++ if (iss.fail() || eq.compare("=") || !(iss >> std::ws).eof()) { + SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Syntax error on line %d", lineno); + return false; +- } else { +- Config::options[id] = val; + } ++ ++ Config::options[id] = val; + } + return true; + } diff --git a/pkgbuilds/osk-sdl/osk-sdl-hooks b/pkgbuilds/osk-sdl/osk-sdl-hooks new file mode 100644 index 0000000..4c73056 --- /dev/null +++ b/pkgbuilds/osk-sdl/osk-sdl-hooks @@ -0,0 +1,69 @@ +#!/usr/bin/ash + +run_hook() { + + # Set these variables to help osk-sdl display correctly. + export ETNA_MESA_DEBUG=no_supertile + export SDL_VIDEODRIVER=kmsdrm + + modprobe -a -q dm-crypt >/dev/null 2>&1 + [ "${quiet}" = "y" ] && CSQUIET=">/dev/null" + + if [ -n "${cryptdevice}" ]; then + DEPRECATED_CRYPT=0 + IFS=: read cryptdev cryptname <<EOF +$cryptdevice +EOF + else + DEPRECATED_CRYPT=1 + cryptdev="${root}" + cryptname="root" + fi + + # This may happen if third party hooks do the crypt setup + if [ -b "/dev/mapper/${cryptname}" ]; then + echo "Device ${cryptname} already exists, not doing any crypt setup." + return 0 + fi + + warn_deprecated() { + echo "The syntax 'root=${root}' where '${root}' is an encrypted volume is deprecated" + echo "Use 'cryptdevice=${root}:root root=/dev/mapper/root' instead." + } + + if resolved=$(resolve_device "${cryptdev}" ${rootdelay}); then + if cryptsetup isLuks ${resolved} >/dev/null 2>&1; then + [ ${DEPRECATED_CRYPT} -eq 1 ] && warn_deprecated + dopassphrase=1 + # Ask for a passphrase + if [ ${dopassphrase} -gt 0 ]; then + echo "" + echo "A password is required to access the ${cryptname} volume" + + #loop until we get a real password + while ! [ -b "/dev/mapper/${cryptname}" ]; do + osk-sdl -G -d ${resolved} -n ${cryptname} -c /etc/osk.conf + done + fi + if [ -e "/dev/mapper/${cryptname}" ]; then + if [ ${DEPRECATED_CRYPT} -eq 1 ]; then + export root="/dev/mapper/root" + fi + else + err "Password succeeded, but ${cryptname} creation failed, aborting..." + return 1 + fi + else + err "Failed to open encryption mapping: The device ${cryptdev} is not a LUKS volume." + fi + fi + + IFS=, + if [ -n "${osk_kms}" ]; then + for i in $osk_kms + do + echo "Resetting $i module" + rmmod -f "$i" + done + fi +} diff --git a/pkgbuilds/osk-sdl/osk-sdl-install b/pkgbuilds/osk-sdl/osk-sdl-install new file mode 100644 index 0000000..a1df1d2 --- /dev/null +++ b/pkgbuilds/osk-sdl/osk-sdl-install @@ -0,0 +1,59 @@ +#!/bin/bash + +build() { + local mod + + add_module "lima" + add_module "panfrost" + + add_module "dm-crypt" + add_module 'dm-integrity' + if [[ $CRYPTO_MODULES ]]; then + for mod in $CRYPTO_MODULES; do + add_module "$mod" + done + else + add_all_modules "/crypto/" + fi + + add_binary 'cryptsetup' + + map add_udev_rule \ + '10-dm.rules' \ + '13-dm-disk.rules' \ + '95-dm-notify.rules' \ + '/usr/lib/initcpio/udev/11-dm-initramfs.rules' + + # cryptsetup calls pthread_create(), which dlopen()s libgcc_s.so.1 + add_binary '/usr/lib/libgcc_s.so.1' + + add_binary /usr/bin/osk-sdl + add_file /etc/osk.conf + + # add DRI drivers so we can have hw accel + add_binary /usr/lib/dri/sun4i-drm_dri.so + + # HACK: mkinitcpio does not understand hardlinks, symlink those DRI libs + add_symlink /usr/lib/dri/rockchip_dri.so /usr/lib/dri/sun4i-drm_dri.so + + add_binary /usr/lib/libGL.so.1 + add_binary /usr/lib/libEGL.so.1 + add_binary /usr/lib/libEGL_mesa.so.0 + + [ -f /usr/share/glvnd/egl_vendor.d/50_mesa.json ] && add_file /usr/share/glvnd/egl_vendor.d/50_mesa.json + + ttf_font=$(grep "^keyboard-font\s" /etc/osk.conf|cut -f3 -d' ') + [ -f "$ttf_font" ] && add_file "$ttf_font" + + add_runscript +} + +help() { + cat <<HELPEOF +This hook loads osk-sdl to decrypt the filesystem. Used on touchscreen devices like tablets and phones to provide an on screen keyboard in order to enter in a passphrase for decrypting encrypted systems when an keyboard is not present. + +Users should specify the device to be unlocked using 'cryptdevice=device:dmname' on the kernel command line, where 'device' is the path to the raw device, and 'dmname' is the name given to the device after unlocking, and will be available as /dev/mapper/dmname. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: |