summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0c8fbe032fc86541e3db9318e50ac02e012d9a64 (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
# dreieck

_pkgname='dev_one'
_typesuffix='-dkms'
_vcssuffix='-git'
pkgname="${_pkgname}${_typesuffix}${_vcssuffix}"
pkgver=r15.20230110.0171589
pkgrel=5
pkgdesc="Linux kernel module that creates a device '/dev/one', similar to '/dev/zero' but outputting one-bits (0xFF-bytes)."
url='https://github.com/tinmarino/dev_one'
arch=(
  'any' # It builds binaries via DKMS _after_ module installation, for whatever architecture the current system runs on, so this package is regarded to be architecture independent.
)
license=('GPL-2.0-only')
provides=(
  "${_pkgname}"
  "${_pkgname}${_typesuffix}"
  "${_pkgname}${_vcssuffix}=${pkgver}"
)
conflicts=(
  "${_pkgname}"
  "${_pkgname}${_typesuffix}"
  "${_pkgname}${_vcssuffix}"
)
makedepends=(
  'git'
  'linux'
)
depends=(
  'dkms'
  'linux'
)
install='dev_one-dkms.install'
source=(
  "${_pkgname}::git+${url}.git"
  "adapt_for_linux_6.8+.patch::https://github.com/user-attachments/files/16942789/adapt_for_linux_6.8%2B.patch.txt"
  "${_pkgname}-dkms.conf.in"
  "one.modules-load.conf"
  "${install}"
)
sha256sums=(
  'SKIP'                                                             # Main source (latest git checkout from https://github.com/tinmarino/dev_one.git)
  '9d6077dcbb4e0720fce59ffade0e5384f53762e37895e70583896c2e1fd194d2' # adapt_for_linux_6.8+.patch
  'b31b4d876b2d2b0a27f1eaa1ffa3e746f9692743827702c2dcc77fc360f85d9a' # ${_pkgname}-dkms.conf.in (dev_one-dkms.conf.in)
  '2c8b08da5ce60398e1f19af0e5dccc744df274b826abe585eaba68c525434806' # one.modules-load.conf
  '788c11d95b3e9b4967f4d53b62366209a7af825e26a867ed4a76fc49cf290b05' # ${install} (dev_one-dkms.install)
)

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

  ## Apply patches:

  if stat "${srcdir}"/*.patch > /dev/null 2>&1; then # Do only if at least one patch file is present
    for _patch in "${srcdir}"/*.patch; do
      printf '%s\n' "  -> Applying patch '${_patch}' ..."
      patch -N -p1 --follow-symlinks -i "${_patch}"
    done
  fi


  ## Create further documentation files:

  printf '%s\n' "  -> Creating 'website.url' information file ..."
  printf '%s\n' "${url}" > "${srcdir}/website.url"

  printf '%s\n' "  -> Creating 'git.log' information file ..."
  git log > "${srcdir}/git.log"
}

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

  _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
    printf '%s\n' "  -> ERROR: Git Commit count could not be determined. Aborting." > /dev/stderr
  return 1
  else
    printf '%s' "r${_rev}.${_date}.${_hash}"
  fi
}

build() {
  cd "${srcdir}"

  printf '%s\n' "  -> Creating 'dkms.conf' ..."
  sed -e "s/@_PKGNAME@/${_pkgname}/" \
      -e "s/@PKGVER@/${pkgver}/" \
      "${_pkgname}-dkms.conf.in" > "${_pkgname}-dkms.conf"
}

package() {
  cd "${srcdir}"

  ## Install sources and dkms.conf:
  install -D -m644 -v "${srcdir}/${_pkgname}-dkms.conf" "${pkgdir}/usr/src/${_pkgname}-${pkgver}/dkms.conf"
  cp -rv "${srcdir}/${_pkgname}"/* "${pkgdir}/usr/src/${_pkgname}-${pkgver}"/

  ## Automatically load module at bootup:
  install -D -m644 -v "${srcdir}/one.modules-load.conf" "${pkgdir}/usr/lib/modules-load.d/one.conf"

  ## Install documentation files:
  for _docfile in "${srcdir}"/{"${_pkgname}/README.md","website.url","git.log"}; do
    install -D -m644 -v "${_docfile}" "${pkgdir}/usr/share/doc/${_pkgname}/$(basename "${_docfile}")"
  done
}