device-purism-librem5: add smartcard reader support (MR 1993)

This adds a new subpackage that installs dependencies and configures the
smartcard reader on the librem 5. Some setup is required before this
will work (e.g. upgrading reader firmware), the L5 wiki page will have
this information.

The pcsc init script was forked into this package to allow for powering
on the reader *before* the service started. Doing this in a separate
init script would have caused the reader to power on regardless of
whether the pcsc service was set to start, which is not desirable since
it should *only* be powered on when pcsc is starting
This commit is contained in:
Clayton Craft 2021-02-25 17:02:26 -08:00 committed by Alexey Min
parent bf1e0b82bc
commit 3ed8a1b07c
No known key found for this signature in database
GPG key ID: 0B19D2A65870B448
4 changed files with 70 additions and 1 deletions

View file

@ -2,7 +2,7 @@
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=device-purism-librem5
pkgdesc="Purism Librem 5 Phone"
pkgver=1.13
pkgver=1.14
pkgrel=0
_confver=35
url="https://postmarketos.org"
@ -32,12 +32,15 @@ source="
librem5-shipmode.initd
modprobe.d_rsi.conf
modules-load.d_librem5.conf
pcscd-librem5-reader.conf
pcscd-librem5.initd
uboot-script.cmd
xorg.conf
"
subpackages="
$pkgname-phosh
$pkgname-pulseaudio
$pkgname-smartcard
"
install="$pkgname.post-install"
@ -67,6 +70,19 @@ pulseaudio() {
cp -r "$builddir"/default/audio/profile-sets "$subpkgdir"/usr/share/pulseaudio/alsa-mixer/
}
smartcard() {
pkgdesc="OpenPGP SmartCard support for the Librem 5"
depends="$pkgname ccid gnupg-scdaemon pcsc-lite pcsc-tools"
install_if="$pkgname pcsc-tools"
install="$install $subpkgname.post-install"
install -D -m644 "$srcdir"/pcscd-librem5-reader.conf \
"$subpkgdir"/etc/reader.conf.d/librem5-ttxs-reader
install -D -m755 "$srcdir"/pcscd-librem5.initd \
"$subpkgdir"/etc/init.d/pcscd-librem5
}
package() {
install -D -m644 "$srcdir"/boot.scr \
"$pkgdir"/boot/boot.scr
@ -108,5 +124,7 @@ d033df2b9125622c946af67dad83070473c86937b5825f57ad272c9145b594071dd6913949127803
76b06cc1ac82c3fc0e298c9d7d5c9139624b1269bf846fe3bc07b9af877d882362b60ba90028ad3182cb1d6426aacdb560fe060b026778a56e7f038d495eadd4 librem5-shipmode.initd
9dc018f0de523cbfe5a49cbe831aa30e975a8dd34635197bb52582f072ac356ef2c02223fc794d970380091a69a83a74c3fbe34520190c8536e77f9ea98c7659 modprobe.d_rsi.conf
a0740e405781ec6ef765fdc9f5700c95adbb241c45c97b9384ba68cdece662cb216ca5918640042f6e65a5d1b1a9099936382c99b49a44303f7b6d77a075a471 modules-load.d_librem5.conf
8ef4ec7a9e9a4fb801d207e7d94b627aacc9243a93b0ec28e0823a6f44b8102416c040e4ddf499f87bb9dfa960cf6f627b008b79f197f6814b3fd881e18ae8ef pcscd-librem5-reader.conf
2618b40eebd3602066ee75ab85cbdbb4cfee498def9879c95a304f05a6eeedf1ab28c5dd9fa5efc8f88c790f49c96458c61d5dfe8a3ca0f96bcc0e244313ab01 pcscd-librem5.initd
aa06920d47ca3781d76473a8a4efebd243ebb1c1d81e1714ef5ade3fed91e0a7a7113e5fa00c7c77163556745962e57102469517f9ea3ad868bc4033387bf428 uboot-script.cmd
1cbc65cf2cb8fad4b0332d012a0256a266205b9b64371f5c0dae09dbb7f1e45b254e8c43993b896097e9d7035a72d547d9bce1ab2133addc56a5abdb80b44616 xorg.conf"

View file

@ -0,0 +1,11 @@
#!/bin/sh
# smartcard reader service
rc-update add pcscd-librem5
cat 1>&2 <<EOF
*
* If the smartcard firmware hasn't been upgraded, an upgrade might be necessary!
* For more info: https://wiki.postmarketos.org/wiki/Purism_Librem5_(purism-librem5)#OpenPGP_Smartcard
*
EOF

View file

@ -0,0 +1,3 @@
DEVICENAME /dev/ttymxc2:SEC1210
FRIENDLYNAME "TTXS serial"
LIBPATH /usr/lib/pcsc/drivers/serial/libccidtwin.so

View file

@ -0,0 +1,37 @@
#!/sbin/openrc-run
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/pcsc-lite/files/pcscd-init.7,v 1.1 2014/02/14 23:11:54 flameeyes Exp $
#
# Forked from Alpine's pcsc-lite package to start the cardreader hardware on
# the librem 5
name="PC/SC Daemon for the Librem 5"
pidfile=/run/pcscd/pcscd.pid
command=/usr/sbin/pcscd
command_args="${EXTRA_OPTS}"
start_stop_daemon_args="--user pcscd:pcscd"
depend() {
need localmount
after udev openct dbus
use logger
}
start_pre() {
checkpath -d -m 0755 -o pcscd:pcscd /run/pcscd
# power on smartcard reader
echo 1 > /sys/class/leds/smc_en/brightness
# delay to give card reader time to start up
sleep 2
}
stop_post() {
# power off smartcard reader
echo 0 > /sys/class/leds/smc_en/brightness
}