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

_modulename="gpd-fan"
_gitname="${_modulename}-driver"
_githost="github.com"
_gituser="Cryolitia"
_pkgbase="${_gitname}-dkms"
pkgbase="${_pkgbase}-git"
_pkgname="${_pkgbase}"
pkgname="${pkgbase}"
groups=(
  "gpd"
)
pkgver=r23.20241016.2a59f63
_gpdfanspeedver="$("${startdir}"/gpdfanspeed --version)"
pkgrel=1
pkgdesc="Fan hwmon speed report and speed control driver for GPD Win Mini, GPD Win Max2 and GPD Win 4 laptops. Latest git checkout. Includes a command line control utility."
url="https://${_githost}/${_gituser}/${_gitname}"
arch=('any')
license=('GPL-2.0-or-later')
depends=(
  'dkms'
)
makedepends=(
  'git'
)
optdepends=(
  "bash: For 'gpdfanspeed' control utility."
)
provides=(
  "${_gitname}"
  "${_gitname}-git=${pkgver}"
  "${_pkgname}"
  "GPD-FAN-DRIVER"  # This means kernel-side support; packages providing kernel module, but also kernel packages which have that builtin, can set this.
  "gpdfanspeed=${_gpdfanspeedver}"
)
conflicts=(
  "${_gitname}"
  "${_pkgname}"
  "gpdfanspeed"
)
install="${_gitname}.install"
source=(
  "${_gitname}::git+${url}.git"
  "dkms.conf.in"
  "gpdfanspeed"
  "${install}"
)
sha256sums=(
  'SKIP'
  'f3f6f913c82b58f9e4811a04449a17ce88af57a0a4ba7fad05cfdbe3689b7863'  # dkms.conf.in
  'f1f49a4aa40d098c476b24c52b3ca7a15ea86d571751b1d0ebfb8333efe9dfa6'  # gpdfanspeed
  '52b499321ed838fa91a788e7fbf118a9cbeb9367e131aa924a6fa03afd20c922'  # $install
)

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

  ## Generate GIT log
  git log > "${srcdir}/git.log"
}

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

  # _ver="$(grep -E '^[[:space:]]*VERSION[[:space:]]*=' Makefile | tail -n1 | sed -E -e 's|^[[:space:]]*VERSION[[:space:]]*=[[:space:]]*||' -e 's|[[:space:]]*#.*$||')"
  # _upstreamrev="$(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 "${_rev}" ]; then
    error "Could not determine git commit count."
    return 1
  else
    printf '%s' "r${_rev}.${_date}.${_hash}"
  fi
}

build() {
  cd "${srcdir}"

  sed -E -e "s|%%VERSION%%|${pkgver}|g" dkms.conf.in > dkms.conf
}

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

  install -Dvm755 -t "${pkgdir}/usr/bin"                        "${srcdir}/gpdfanspeed"

  umask 022
  install -Dvm644 -t "${pkgdir}/usr/src/${_gitname}-${pkgver}"  'gpd-fan.c' 'Makefile' "${srcdir}/dkms.conf"

  install -Dvm644 -t "${pkgdir}/usr/share/doc/${_gitname}"      'README.md' "${srcdir}"/git.log
  install -Dvm644 -t "${pkgdir}/usr/share/licenses/${pkgname}"  'LICENSE'
  ln -svr "/usr/share/licenses/${pkgname}/LICENSE" "${pkgdir}/usr/share/doc/${_gitname}/LICENSE"
}