summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: edc77063baec7c3ce41df46bd46ef2e86fbc8f63 (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
# Maintainer: Jean Lucas <jean@4ray.co>
# Maintainer: taotieren <admin@taotieren.com>
# Contributor: Quey-Liang Kao <s101062801@m101.nthu.edu.tw>

pkgname=kpatch-git
pkgver=0.9.9.r64.gcbf2bc9
pkgrel=1
pkgdesc='Live kernel patching (git)'
arch=($CARCH)
url=https://github.com/dynup/kpatch
license=(GPL-2.0-only)
depends=(
  sh
  libelf)
makedepends=(git)
checkdepends=(
  shellcheck)
provides=(kpatch)
conflicts=(kpatch)
source=("${pkgname}::git+$url.git"
  "objs::git+https://github.com/dynup/kpatch-unit-test-objs.git")
sha512sums=('SKIP'
  'SKIP')

pkgver() {
  cd "${srcdir}/${pkgname}/"
  git describe --long --tags | sed 's/^v//g;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  git -C "${srcdir}/${pkgname}" clean -dfx
  cd "${srcdir}/${pkgname}/"

  # Fix search structure
  sed -i 's#libexec#lib#g' kpatch-build/kpatch-build

  # Change default bindir
  sed -i 's#SBIN#BIN#g' kpatch/Makefile

  # Fix file path in systemd service file
  sed -i 's#sbin#bin#' contrib/kpatch.service

  # Linux 5.2 introduced API changes to the stack trace code
  # The kmod core module hasn't been updated to support them, so it currently doesn't build
  # It's functionality can however be provided by Linux's livepatch API
  # See https://github.com/dynup/kpatch/issues/966
  # Disable kmod for now
  sed -i '3s#kmod ##' Makefile

  git submodule init
  git config submodule.test/unit/objs.url "$srcdir/objs"
  git -c protocol.file.allow=always submodule update
}

build() {
  cd "${srcdir}/${pkgname}/"
  make PREFIX=/usr
}

check() {
  cd "${srcdir}/${pkgname}/"
  make unit
  #   see: https://github.com/dynup/kpatch/issues/1371
  #   make check
}

package() {
  cd "${srcdir}/${pkgname}/"
  make PREFIX=/usr LIBEXEC=lib DESTDIR="$pkgdir" install

  cd "$pkgdir"

  # Remove incompatible init system file
  rm etc/init/kpatch.conf
  rmdir -p etc/init
}