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

_pkgname=j2j
pkgname="${_pkgname}-git"
epoch=0
pkgver=r9.20230914.133a478
pkgrel=1
pkgdesc='Small utility to convert certain Java serialized objects into JSON.'
url='https://github.com/Zerocopter/J2J'
arch=(any)
license=(BSD)
depends=(
  'python>=3'
  "python-javaobj-py3"
)
makedepends=(
  'dos2unix'
  'git'
)
optdepends=()
provides=(
  "${_pkgname}"
  "python-${_pkgname}"
  "python-${_pkgname}-git=${pkgver}"
)
conflicts=(
  "${_pkgname}"
  "python-${_pkgname}"
  "python-${_pkgname}-git"
)
source=(
  "${_pkgname}::git+${url}.git"
)
sha256sums=(
  'SKIP'
)

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

  dos2unix J2J.py
  dos2unix JAVA_SERIALIZED_OBJECT.yar

  git log > 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
    error "Could not determine Git commit count."
    return 1
  else
    printf '%s' "r${_rev}.${_date}.${_hash}"
  fi
}

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

  _pythonver="$(python --version | awk '{print $2}' | awk -F. '{print $1"."$2}')"
  _sitepackagedir="${pkgdir}/usr/lib/python${_pythonver}/site-packages/J2J"

  install -D -v -m755 'J2J.py' "${_sitepackagedir}/J2J.py"
  install -d -v -m755 "${pkgdir}/usr/bin"

  ln -svr "${_sitepackagedir}/J2J.py" "${pkgdir}/usr/bin/j2j"

  for _docfile in README.md git.log JAVA_SERIALIZED_OBJECT.yar; do
    install -D -v -m644 "${_docfile}" "${pkgdir}/usr/share/doc/${_pkgname}/${_docfile}"
  done
  install -D -v -m 644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  ln -svr "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" "${pkgdir}/usr/share/doc/${_pkgname}/LICENSE"
}