summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f0a97a1237c1dab2cda24fe7457bf03913f78fb1 (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
# Maintainer:  dreieck (https://aur.archlinux.org/account/dreieck)
# Contributor: quang (https://aur.archlinux.org/account/quang)
# Contributor: Samega7Cattac (https://aur.archlinux.org/account/Samega7Cattac)
# Contributor: max_meyer
# Contributor: Stefan Husmann

pkgname=svg2tikz-git
_gitname="svg2tikz"
pkgver=3.0.1+4.r481.20240321.2b8b19c
pkgrel=1
pkgdesc="Set of tools for converting SVG graphics to TikZ/PGF code."
arch=('any')
url="https://github.com/kjellmf/svg2tikz"
license=('GPL2')
depends=(
  'python>=3'
  'python-inkex'
)
optdepends=(
  'inkscape: for using the inksape extension files.'
  'python-lxml'
  'xclip'
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
  'python-poetry'
  'python-sphinx'          # For building the documentation.
  'python-sphinx-argparse' # For building the documentation.
  'texlive-bin'            # For building the documentation.
)
checkdepends=(
  'python-pytest'
)
provides=(
  "inkscape-tikz=${pkgver}"
  "svg2tikz=${pkgver}"
  "svg2tikz-doc=${pkgver}"
  "python-svg2tikz=${pkgver}"
)
conflicts=(
  'inkscape-tikz'
  'svg2tikz'
  'svg2tikz-doc'
  'python-svg2tikz'
)
replaces=(
  'inkscape-tikz-hg'
)
source=(
  "${_gitname}::git+https://github.com/kjellmf/${_gitname}"
)
sha256sums=(
  'SKIP'
)

prepare() {
  cd "$srcdir"/"$_gitname"

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

pkgver() {
  cd "$srcdir"/"$_gitname"

  _ver="$(git describe  --tags | sed 's|^[vV]||' | sed 's|-[^-]*$||' | 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"/"$_gitname"

  python -m build --wheel --no-isolation

  cd docs
  make latex
}

check() {
  cd "$srcdir"/"$_gitname"

  python -m pytest
}

package() {
  cd "$srcdir/$_gitname"

  python -m installer --destdir="$pkgdir" dist/*.whl
  _inkscape_ext="$pkgdir/usr/share/inkscape/extensions"
  install -dvm755 "$_inkscape_ext"
  cp -v ./svg2tikz/tikz_export* "$_inkscape_ext/"

  for _docfile in "${srcdir}/git.log" CHANGELOG.md README.md; do
    install -Dvm644 "${_docfile}" "${pkgdir}/usr/share/doc/svg2tikz/$(basename "${_docfile}")"
  done
  cp -rv docs "${pkgdir}/usr/share/doc/svg2tikz/docs"

  install -Dvm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  ln -svr "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" "${pkgdir}/usr/share/doc/svg2tikz/LICENSE"
}