summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 84a3742c7de4ccfe3e8e34f5aeefee6d53c4c603 (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
# Maintainer:  dreieck (https://aur.archlinux.org/account/dreieck)
# Contributor: Zile995 (https://aur.archlinux.org/account/Zile995)

_gitname=zswap-cli
pkgname="${_gitname}-nosystemd-git"
pkgver=1.0.0.r465.20241020.82ae7a4
pkgrel=1
pkgdesc="Command-line tool to control ZSwap Linux kernel module. Build without systemd dependency/ support. Latest git checkout."
arch=('x86_64')
url="https://github.com/xvitaly/zswap-cli"
license=('MIT')
depends=(
  'boost-libs'
  'fmt'
  'gcc-libs'
  'glibc'
  'sdbus-cpp'
)
makedepends=(
  'boost'
  'cmake'
  'doxygen'
  'gcc'
  'git'
  'ninja'
  'pandoc'
)
optdepends=(
  'semver: Semantic versioning for C++'
)
provides=(
  "zswap-cli-nosystemd=${pkgver}"
  "zswap-cli-git=${pkgver}"
  "zswap-cli=${pkgver}"
)
conflicts=(
  "zswap-cli"
)
backup=('etc/zswap-cli/zswap-cli.conf')
source=("${_gitname}::git+${url}.git")
sha256sums=('SKIP')

prepare() {
  cd "${srcdir}/${_gitname}"
  git log > git.log
}

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

  _ver="$(git describe --tags | sed -E -e 's|^[vV]||' -e 's|-g[0-9a-f]*$||' -e 's|-|+|g')"
  _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() {
  sed -i \
    's/CMAKE_INSTALL_SBINDIR/CMAKE_INSTALL_BINDIR/g' "${srcdir}/${_gitname}/CMakeLists.txt"

  cmake \
    -G Ninja \
    -B "${_gitname}/build" \
    -S "${_gitname}" \
    -DBUILD_MANPAGE=ON \
    -DBUILD_DOC=ON \
    -DCMAKE_INSTALL_PREFIX:PATH='/usr' \
    -DCMAKE_BUILD_TYPE:STRING='Release' \
    -DFETCHCONTENT_QUIET=OFF \
    -DFETCHCONTENT_FULLY_DISCONNECTED=OFF \
    -DFETCHCONTENT_UPDATES_DISCONNECTED=ON \
    -DFETCHCONTENT_UPDATES_DISCONNECTED_SEMVER=ON \
    -DLINK_ALL_STATICALLY=OFF \
    -DLINK_BOOST_STATICALLY=OFF \
    -DLINK_ENABLE_OPTIMIZATIONS=ON \
    -DSEMVER_OPT_BUILD_EXAMPLES=OFF \
    -DSEMVER_OPT_BUILD_TESTS=OFF \
    -DSEMVER_OPT_INSTALL=ON \
    -DSYSTEMD_INTEGRATION=OFF \
    -Wno-dev

  cmake --build "${_gitname}/build"
}

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

  # README and co
  install -Dvm644 -t "${pkgdir}/usr/share/doc/${_gitname}" "${srcdir}/${_gitname}"/{README.md,git.log}

  # license
  install -Dvm644 "${srcdir}/${_gitname}/LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}"
}