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

_pkgname=linux-terminal-battery-status
pkgname="${_pkgname}-git"
pkgver=20231201.02.r44.g7e677e3
pkgrel=2
pkgdesc="Prints information about system batteries and power supplies to the terminal, optionally also from devices connected via KDE Connect."
url="https://gitlab.com/dreieckli/linux-terminal-battery-status"
license=(
  'GPL3'
  'custom: CC_BY-SA_3.0'
)
arch=(any)
depends=(
  'bash'
  'coreutils'
  'gawk'
)
optdepends=(
  'acpi: To display remaining battery time.'
  'grep: To display remaining battery time.'
  'sed: To display remaining battery time.'
  'kdeconnect: To display information about devices connected via KDE Connect.'
  'qt5-tools: To display information about devices connected via KDE Connect.'
)
makedepends=(
  'git'
)
provides=(
  "${_pkgname}=${pkgver}"
)
conflicts=(
  "${_pkgname}"
)
source=(
  "${_pkgname}::git+${url}.git"
)
sha256sums=(
  'SKIP'
)

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

  git log > git.log
}

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

  _ver="$(bash linux-terminal-battery-status.sh --version)"
  _rev="$(git rev-list --count HEAD)"
  # _date="$(git log -1 --date=format:"%Y%m%d" --format="%ad")" # Don't process date since the upstream version also has some notion of date.
  _hash="$(git rev-parse --short HEAD)"

  if [ -z "${_ver}" ]; then
    error "Version could not be determined."
    return 1
  else
    # printf '%s' "${_ver}.r${_rev}.${_date}.g${_hash}"
    printf '%s' "${_ver}.r${_rev}.g${_hash}"
  fi
}

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

  install -Dvm755 'linux-terminal-battery-status.sh' "${pkgdir}/usr/bin/linux-terminal-battery-status"
  install -Dvm644 'logo.svg' "${pkgdir}/usr/share/pixmaps/${_pkgname}.svg"
  install -Dvm644 'logo.png' "${pkgdir}/usr/share/pixmaps/${_pkgname}.png"

  install -Dvm644 README.md "${pkgdir}/usr/share/doc/${_pkgname}/README.md"
  install -Dvm644 git.log "${pkgdir}/usr/share/doc/${_pkgname}/git.log"
  install -Dvm644 COPYING.md "${pkgdir}/usr/share/licenses/${pkgname}/COPYING.md"
  install -Dvm644 COPYING.logo.txt "${pkgdir}/usr/share/licenses/${pkgname}/COPYING.logo.txt"
  install -Dvm644 logo_source.md "${pkgdir}/usr/share/licenses/${pkgname}/logo_source.md"
  ln -svr "${pkgdir}/usr/share/licenses/${pkgname}/COPYING.md" "${pkgdir}/usr/share/doc/${_pkgname}/COPYING.md"
  ln -svr "${pkgdir}/usr/share/licenses/${pkgname}/COPYING.logo.txt" "${pkgdir}/usr/share/doc/${_pkgname}/COPYING.logo.txt"
  ln -svr "${pkgdir}/usr/share/licenses/${pkgname}/logo_source.md" "${pkgdir}/usr/share/doc/${_pkgname}/logo_source.md"
}