summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b67e61385e3080e1e31e869374f701901ad79e33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Maintainer: dreieck (https://aur.archlinux.org/account/dreieck)
# Based on aur/uksmd-nosystemd-git by
# Contributor: dreieck (https://aur.archlinux.org/account/dreieck)
#   Based on aur/uksmd-git by
#     Contributor: Yurii Kolesnykov <root [at] yurikoles.com>
#     Based on aur/uksmd by
#       Oleksandr Natalenko <oleksandr [at] natalenko.name>

_pkgname=uksmd
_downloadname="${_pkgname}-CachyOS"
pkgname="${_pkgname}-cachyos-nosystemd-git"
epoch=0
pkgver=1.2.12.r116.20241108.87730a6
pkgrel=2
pkgdesc="Userspace KSM helper daemon. CachyOS-version with 'uksmdstats'. Without systemd dependency, latest git checkout."
url='https://github.com/CachyOS/uksmd'
# Original upstream URL: https://codeberg.org/pf-kernel/uksmd
license=("GPL-3.0-only")
arch=(
  'aarch64'
  'armv7h'
  'armv8h'
  'i686'
  'x86_64'
)
depends=(
  'glibc'
  'libcap-ng'
  'procps-ng'
)
optdepends=(
  'bash: For uksmdstats script.'
  'gettext: For uksmdstats script.'
  'uksmd-openrc: For OpenRC initscript.'
  'UKSMD-BUILTIN: Necessary kernel support.' # This is an optional dependency to not force users to use package management for self-compiled kernels.
)
makedepends=(
  'git'
  'meson'
)
provides=(
  "${_pkgname}"
  "${_pkgname}-cachyos=${pkgver}"
  "${_pkgname}-nosystemd"
  "${_pkgname}-git"
  "uksmdstats=${pkgver}"
  "uksmdstats-git=${pkgver}"
)
conflicts=(
  "${_pkgname}"
  "uksmdstats"
)
source=(
  "${_downloadname}::git+${url}.git"
)
sha256sums=(
  'SKIP'
)

prepare() {
  cd "${srcdir}"

  mkdir -p build

  cd "${srcdir}/${_downloadname}"

  git log > git.log
}

pkgver() {
  cd "${srcdir}/${_downloadname}"

  _ver="$(sed -E 's|#.*$||' meson.build | tr '\n' ' ' | sed -E -e 's|project[[:space:]]*\(([^\)]*)\).*$|\1|' -e 's|.*version:[[:space:]]*([^,]*)[[:space:]]*,.*|\1|' | tr -d \'\")" # Can also be parsed from `git describe --tags`.
  _rev="$(git rev-list --count HEAD)"
  _date="$(git log -1 --date=format:"%Y%m%d" --format="%ad")"
  _hash="$(git rev-parse --short HEAD)"

  if [ -z "${_ver}" ]; then
    error "Version could not be determined."
    return 1
  else
    printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi
}

build() {
  cd "${srcdir}"

  arch-meson -Dsystemd=disabled "${_downloadname}" build
  meson compile -C build
}

package() {
  cd "${srcdir}"

  meson install -C build --destdir "${pkgdir}"

  cd "${srcdir}/${_downloadname}"

  install -Dvm644 git.log "${pkgdir}/usr/share/doc/${_pkgname}/git.log"
  install -Dvm644 README.md "${pkgdir}/usr/share/doc/${_pkgname}/README.md"
  install -Dvm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
  ln -svr "${pkgdir}/usr/share/licenses/${pkgname}/COPYING" "${pkgdir}/usr/share/doc/${_pkgname}/COPYING"
}