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

_pkgname=automirror
pkgname="${_pkgname}-git"
pkgdesc="An xrandr-wrapper that automatically configures the attached monitors in a mirror configuration that is optimized for the primary display and makes all other outputs scale to that."
url="https://github.com/schlomo/${_pkgname}"
arch=('any')
license=('GPL3')
epoch=1
pkgver=r54.20210616.f0af34a
pkgrel=1
depends=(
  'bash'
  'sed'
  'xorg-xrandr'
)
makedepends=(
  'git'
  'ruby-ronn' # To generate manpage. Used in Makefile.
)
optdepends=(
  "libnotify: For displaying notification about the script's action."
  'zenity: For using a GUI in interactive mode.'
)
provides=(
  "${_pkgname}=${pkgver}"
)
conflicts=(
  "${_pkgname}"
)
source=(
  "${_pkgname}::git+https://github.com/schlomo/${_pkgname}.git"
)
sha256sums=(
  'SKIP'
)

prepare() {
  printf '%s\n' "${url}" > "${srcdir}/upstream.url"
}

pkgver() {
  cd "${srcdir}/${_pkgname}"
  _date="$(git log -1 --format=%cd --date=format:%Y%m%d)"
  _hash="$(git rev-parse --short HEAD)"
  _ver="$(git rev-list HEAD --count --no-merges)"
  if [ -z ${_ver} ]; then
    error "Could not determine version."
    exit 1
  else
    printf '%s' "r${_ver}.${_date}.${_hash}"
  fi
}

check() {
  cd "${srcdir}/${_pkgname}"
  make test
}

package() {
  # This actually also builds the manpage. But in the `Makefile` this is incorporated in the `install` target, so we have building of documentation in `package()`.
  cd "${srcdir}/${_pkgname}"
  make DESTDIR="${pkgdir}" install

  install -D -v -m644 "${srcdir}/upstream.url" "${pkgdir}/usr/share/doc/${_pkgname}/upstream.url"
  for _docfile in README.md; do
    install -D -v -m644 "${_docfile}" "${pkgdir}/usr/share/doc/${_pkgname}/${_docfile}"
  done

  install -d -v -m755 "${pkgdir}/usr/share/doc/${_pkgname}/tests"
  install -D -v -m755 runtests.sh "${pkgdir}/usr/share/doc/${_pkgname}/tests/runtests.sh"
  cp -rv testdata "${pkgdir}/usr/share/doc/${_pkgname}/tests/"
  ln -sv /usr/bin/automirror "${pkgdir}/usr/share/doc/${_pkgname}/tests/automirror.sh"

  install -D -v -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  ln -svr "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" "${pkgdir}/usr/share/doc/${_pkgname}/LICENSE"
}