summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 61470620032d7b2257ea03358ae31993ccdf34b3 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Maintainer:  dreieck (https://aur.archlinux.org/account/dreieck)

_pkgbase='amdgpu-test-scripts'
_vcssuffix="-git"
pkgbase="${_pkgbase}${_vcssuffix}"
pkgname=(
  "amdgpu-test-scripts-common${_vcssuffix}"
  "amd-s2idle-analysis-script${_vcssuffix}"
  "amd-psr-identification-script${_vcssuffix}"
)
epoch=0
pkgver=r227.20241107.15506e5
pkgrel=1
pkgdesc="Test scripts for open source AMD graphics driver."
arch=(
  'any'
)
url="https://gitlab.freedesktop.org/drm/amd"
license=(
  'MIT'
)
makedepends=(
  'git'
)
checkdepends=()
source=(
  "${_pkgbase}::git+${url}.git"
)
sha256sums=(
  'SKIP'                                                              # upstream git source
)

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

  git log > git.log
  printf '%s\n' "${url}" > website.url
  printf '%s\n' "The only license information that could be found is '# SPDX-License-Identifier: MIT' at the top of the scripts." > license-info.txt
}

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

  _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 commit count."
    return 1
  else
    printf '%s' "r${_rev}.${_date}.${_hash}"
  fi
}

_package_amdgpu-test-scripts-common() {
  pkgdesc="Common files (README, License) for 'amd-s2idle-analysis-script' and 'amd-psr-identification-script'."
  url="https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py"
  depends=()
  optdepends=(
    "amd-s2idle-analysis-script: The software this common files are for."
    "amd-psr-identification-script: The software this common files are for."
  )
  provides=()
  conflicts=()
  replaces=()
  if [ -n "${_vcssuffix}" ]; then
    provides+=("amdgpu-test-scripts-common")
    conflicts+=("amdgpu-test-scripts-common")
  fi

  for _docfile in git.log license-info.txt website.url README.md; do
    install -Dvm644 -t "${pkgdir}/usr/share/doc/${_pkgbase}" "${srcdir}/${_pkgbase}/${_docfile}"
  done

  install -dvm755 "${pkgdir}/usr/share/licenses/${pkgname}"
  ln -svr "${pkgdir}/usr/share/doc/${_pkgbase}/license-info.txt" "${pkgdir}/usr/share/licenses/${pkgname}/license-info.txt"
}

_package_amd-s2idle-analysis-script() {
  pkgdesc="S0i3/s2idle analysis script ('s2idle.py') for AMD systems."
  url="https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py"
  depends=(
    "amdgpu-test-scripts-common${_vcssuffix}=${pkgver}"
    'acpica'
    'dbus-python'
    'python>=3'
    'python-distro'
    'python-packaging'
    'python-pyudev'
  )
  provides=()
  conflicts=()
  replaces=()
  if [ -n "${_vcssuffix}" ]; then
    provides+=("amd-s2idle-analysis-script")
    conflicts+=("amd-s2idle-analysis-script")
  fi

  install -Dvm755 "${srcdir}/${_pkgbase}/scripts/amd_s2idle.py" "${pkgdir}/usr/bin/amd_s2idle-analysis"

  install -dvm755 "${pkgdir}/usr/share/licenses/${pkgname}"
  ln -svr "${pkgdir}/usr/share/doc/${_pkgbase}/license-info.txt" "${pkgdir}/usr/share/licenses/${pkgname}/license-info.txt"
}

_package_amd-psr-identification-script() {
  pkgdesc="PSR identification script ('psr.py') for AMD systems."
  url="https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/psr.py"
  depends=(
    "amdgpu-test-scripts-common${_vcssuffix}=${pkgver}"
    'python>=3'
    'python-pyudev'
  )
  provides=()
  conflicts=()
  replaces=()
  if [ -n "${_vcssuffix}" ]; then
    provides+=("amd-psr-identification-script")
    conflicts+=("amd-psr-identification-script")
  fi

  install -Dvm755 "${srcdir}/${_pkgbase}/scripts/psr.py" "${pkgdir}/usr/bin/amd_psr-identification"

  install -dvm755 "${pkgdir}/usr/share/licenses/${pkgname}"
  ln -svr "${pkgdir}/usr/share/doc/${_pkgbase}/license-info.txt" "${pkgdir}/usr/share/licenses/${pkgname}/license-info.txt"
}


for _pkg in "${pkgname[@]}"; do
  eval "package_${_pkg} () {
    _package_${_pkg%${_vcssuffix}}
  }"
done