summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b5c40bc00105e0c55926686c696b8fafa2f75315 (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
134
135
136
137
# Maintainer:  dreieck
# Contributor: Nils Werner <nils.werner@gmail.com>

_pkgbase="crestic"
_gitname="${_pkgbase}"
_githubuser="nils-werner"
pkgbase="${_pkgbase}-git"
pkgname=(
  "${_pkgbase}-git"
  "${_pkgbase}-docs-git"
)
pkgver=1.0.0+6.r123.20240618.4c735ad
pkgrel=2
pkgdesc="Configurable restic wrapper. Lastest git checkout. Split package: Software and documentation."
arch=('any')
url="https://github.com/${_githubuser}/${_gitname}"
license=('MIT')
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-wheel'
)
# checkdepends=(
#   'python-pytest'
#   'python-pytest-cov'
#   'python-pytest-mock'
#   'python-pytest-mypy'
#   'python-pytest-pycodestyle' # Not available, so we skip `check()` for now.
# )
source=(
    "${_pkgbase}::git+${url}.git"
    "crestic-backup@.service"
    "crestic-backup@.timer"
    "crestic-forget@.service"
    "crestic-forget@.timer"
)
sha256sums=(
    "SKIP"
    "487bdee984708f7c8e3fdf300d372a9cf60ac212c3898231011d50b4bb2161e6"
    "be3b2461029a2d92329bcc1b42a8207f1c75ce03a6df86d72788ff2b8772ba70"
    "d8a94324994b2caae186f70f1463bee7b998547e31739c6e790f9fca37019022"
    "ea0050225c6527f8ebcc146f6dd60e15dede64b5820e25d94e511f7c01594ffc"
)

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

  git log > "${srcdir}/git.log"
}

pkgver () {
  cd "${srcdir}/${_pkgbase}"
  _ver="$(git describe --tags | sed -E -e 's|^[vV]||' -e 's|\-g[0-9a-f]*$||' | tr '-' '+')"
  _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 "${_ver}" ]; then
    error "Version could not be determined."
    return 1
  else
    printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi
}

build () {
  cd "${srcdir}/${_pkgbase}"
  python -m build --wheel --no-isolation
}

# check() {
#   # `python-pytest-pycodestyle` is needed but not in the repositories or the AUR, so whe skip for now.
#   cd "${srcdir}/${_pkgbase}"
# 
#   pytest
# }

package_crestic-git() {
  pkgdesc="Configurable restic wrapper. Lastest git checkout."
  depends=(
    'python>=3.6'
    'restic'
  )
  optdepends=(
    "crestic-docs: Documentation for this software."
  )
  provides=(
    "crestic=${pkgver}"
    "python-crestic=${pkgver}"
  )
  conflicts=(
    "crestic"
    "python-crestic"
  )

  cd "${srcdir}"
  install -Dvm 0644 crestic-backup@.service -t "$pkgdir"/usr/lib/systemd/system/
  install -Dvm 0644 crestic-backup@.timer -t "$pkgdir"/usr/lib/systemd/system/
  install -Dvm 0644 crestic-backup@.service -t "$pkgdir"/usr/lib/systemd/user/
  install -Dvm 0644 crestic-backup@.timer -t "$pkgdir"/usr/lib/systemd/user/
  install -Dvm 0644 crestic-forget@.service -t "$pkgdir"/usr/lib/systemd/system/
  install -Dvm 0644 crestic-forget@.timer -t "$pkgdir"/usr/lib/systemd/system/
  install -Dvm 0644 crestic-forget@.service -t "$pkgdir"/usr/lib/systemd/user/
  install -Dvm 0644 crestic-forget@.timer -t "$pkgdir"/usr/lib/systemd/user/

  cd "${srcdir}/${_pkgbase}"

  python -m installer --destdir="$pkgdir" dist/*.whl

  install -Dvm 0644 LICENSE -t "${pkgdir}"/usr/share/licenses/"${pkgname}"/
}

package_crestic-docs-git() {
  pkgdesc="Documentation for 'crestic'. Latest git checkout."
  provides=(
    "crestic-docs=${pkgver}"
  )
  conflicts=(
    "crestic-docs"
    "crestic-doc<=1.0.0+6.r123.20240618.4c735ad"  # Because we initially had 'crestic-doc' in the 'provides'-array of 'crestic-git', and now the package is split  out _and_ renamed to 'crestic-docs' (with 's' suffix).
  )
  replaces=(
    "crestic-doc<=1.0.0+6.r123.20240618.4c735ad"  # Because we initially had 'crestic-doc' in the 'provides'-array of 'crestic-git', and now the package is split  out _and_ renamed to 'crestic-docs' (with 's' suffix).
  )
  optdepends=(
    "crestic: The software this documentation is for."
  )

  cd "${srcdir}/${_pkgbase}"

  install -Dvm 0644 "${srcdir}/git.log" CHANGELOG.md README.md RELEASE.md -t "${pkgdir}/usr/share/doc/${_pkgbase}"/
  install -Dvm 0644 LICENSE -t "${pkgdir}"/usr/share/licenses/"${pkgname}"/
  ln -svr "${pkgdir}"/usr/share/licenses/"${pkgname}"/LICENSE "${pkgdir}/usr/share/doc/${_pkgbase}"/LICENSE

  cp -rv docs "${pkgdir}/usr/share/doc/${_pkgbase}/docs"
}