File PKGBUILD of Package kscreenlocker-git

# Maintainer: neycrol <your@email.com>
pkgname=kscreenlocker-git
_pkgname=kscreenlocker
pkgver=6.5.90
pkgrel=2
pkgdesc='Library and components for secure lock screen architecture (Git)'
arch=(x86_64)
url='https://invent.kde.org/plasma/kscreenlocker'
license=(LGPL-2.0-or-later)
depends=(
  gcc-libs
  glibc
  kconfig
  kcoreaddons
  kcrash
  kdeclarative
  kglobalaccel
  ki18n
  kidletime
  kio
  kirigami
  knotifications
  kpackage
  ksvg
  kwindowsystem
  kxmlgui
  layer-shell-qt-git
  libkscreen
  libx11
  libxcb
  libxi
  pam
  libplasma-git
  qt6-base
  qt6-declarative
  wayland
  xcb-util-keysyms
)
makedepends=(
  extra-cmake-modules
  kcmutils
  kdoctools
  cmake
  ninja
)
provides=(kscreenlocker)
conflicts=(kscreenlocker)
source=("${_pkgname}.tar.gz")
sha256sums=('SKIP')

prepare() {
  # Allow building against stable PlasmaQuick if git is unavailable in repo
  if [[ -d "$srcdir/${_pkgname}" ]]; then
    find "$srcdir/${_pkgname}" -type f \( -name 'CMakeLists.txt' -o -name '*.cmake' \) -print0 \
      | xargs -0 sed -i -E 's/find_package[[:space:]]*[(]PlasmaQuick[[:space:]]+[^ )]+/find_package(PlasmaQuick 6.5.5/'
  fi
}

pkgver() {
  local _ver _ts
  if [[ -f "${srcdir}/kscreenlocker.obsinfo" ]]; then
    _ver=$(sed -n 's/^version: //p' "${srcdir}/kscreenlocker.obsinfo" | head -n1)
  fi
  if [[ -z "$_ver" && -f "${srcdir}/._servicedata" ]]; then
    _ver=$(sed -n 's/.*<param name="version">\(.*\)<\/param>.*/\1/p' "${srcdir}/._servicedata" | head -n1)
  fi
  if [[ -z "$_ver" && -d "${srcdir}/kscreenlocker" ]]; then
    _ts=$(find "${srcdir}/kscreenlocker" -type f -printf '%T@\n' 2>/dev/null | sort -n | tail -n1 | cut -d. -f1)
    if [[ -n "$_ts" ]]; then
      _ver=$(date -u -d "@${_ts}" +%Y%m%d.%H%M%S 2>/dev/null)
    fi
  fi
  if [[ -z "$_ver" ]]; then
    _ver="${pkgver}"
  fi
  echo "${_ver//-/_}"
}


build() {
  cmake -B build -S "${_pkgname}" \
    -DBUILD_TESTING=OFF \
    -DCMAKE_INSTALL_LIBEXECDIR=lib \
    -DCMAKE_INSTALL_PREFIX=/usr
  cmake --build build
}

package() {
  DESTDIR="${pkgdir}" cmake --install build

  # kscreenlocker must ship dedicated PAM service files.
  # If missing, authentication falls back to pam "other" and always fails.
  install -d "${pkgdir}/usr/lib/pam.d"

  cat > "${pkgdir}/usr/lib/pam.d/kde" <<'EOF'
#%PAM-1.0

auth       include                     system-local-login

account    include                     system-local-login

password   include                     system-local-login

session    include                     system-local-login
EOF

  cat > "${pkgdir}/usr/lib/pam.d/kde-fingerprint" <<'EOF'
#%PAM-1.0

auth       required                    pam_shells.so
auth       requisite                   pam_nologin.so
auth       requisite                   pam_faillock.so      preauth
-auth      required                    pam_fprintd.so
auth       optional                    pam_permit.so
auth       required                    pam_env.so

account    include                     system-local-login

password   required                    pam_deny.so

session    include                     system-local-login
EOF

  cat > "${pkgdir}/usr/lib/pam.d/kde-smartcard" <<'EOF'
#%PAM-1.0

auth       requisite                   pam_nologin.so
auth       requisite                   pam_faillock.so      preauth
-auth      required                    pam_pkcs11.so        wait_for_card card_only
auth       required                    pam_shells.so
auth       optional                    pam_permit.so
auth       required                    pam_env.so

account    include                     system-local-login

password   required                    pam_deny.so

session    include                     system-local-login
EOF

  chmod 644 \
    "${pkgdir}/usr/lib/pam.d/kde" \
    "${pkgdir}/usr/lib/pam.d/kde-fingerprint" \
    "${pkgdir}/usr/lib/pam.d/kde-smartcard"
}
openSUSE Build Service is sponsored by