summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3df48865342fcc52c347d3522503a9ce44cd3d94 (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
# Maintainer:
# Contributor: Fedor Suchkov <f.suchkov@gmail.com>

# options
: ${_build_git:=true}

unset _pkgtype
[[ "${_build_git::1}" == "t" ]] && _pkgtype+="-git"

# basic info
_pkgname="fanficfare"
pkgname="$_pkgname${_pkgtype:-}"
pkgver=4.40.0.r0.g9005f9d
pkgrel=2
pkgdesc="Tool to make eBooks from stories on fanfiction and other websites"
url="https://github.com/JimmXinu/FanFicFare"
license=(
  'Apache-2.0'
  'GPL-3.0-only' # calibre plugin
)
arch=('any')

depends=(
  'python'
  'python-beautifulsoup4'
  'python-brotli'
  'python-chardet'
  'python-cloudscraper' # AUR
  'python-colorama'
  'python-html2text'
  'python-requests'
  'python-requests-file'
  'python-six'
  'python-urllib3'
)
makedepends=(
  'git'
  'python-setuptools'
  'python-wheel'
  'python-installer'
  'python-build'
)
optdepends=(
  'calibre: use as a plugin for calibre'
  'python-pillow: convert and resize covers and images'
)

_pkgsrc="$_pkgname"
source=(
  "$_pkgsrc"::"git+$url.git"
  "0001-makeplugin-do-not-bundle-system-dependencies.patch"
)
sha256sums=(
  'SKIP'
  '6d172dcc98a8f6dcef2048272bfabd810ceeb5740969fbe406ebcd7b638e072c'
)

if [ "${_build_git::1}" != "t" ]; then
  # stable
  _prepare() {
    cd "$_pkgsrc"
    local _tag=$(git tag | grep -Ev '[A-Za-z]{2}' | sort -rV | head -1)
    git -c advice.detachedHead=false checkout -f "${_tag:?}"
    git describe --tags --long
  }

  pkgver() {
    cd "$_pkgsrc"
    git describe --tags --exclude='*[a-zA-Z][a-zA-Z]*' \
      | sed -E 's/^[^0-9]*//'
  }
else
  # git
  provides=("$_pkgname=${pkgver%%.r*}")
  conflicts=("$_pkgname")

  _prepare() {
    cd "$_pkgsrc"
    git describe --tags --long
  }

  pkgver() {
    cd "$_pkgsrc"
    local _pkgver=$(
      git describe --long --tags --abbrev=7 --exclude='*[a-zA-Z][a-zA-Z]*' \
        | sed -E 's/^[^0-9]*//;s/-([^-]*-g)/+r\1/;s/-/./g'
    )
    echo "${_pkgver//+/.}"

    # update version string
    sed -E -e 's&^(\s*version)="([0-9\.]+)"$&\1="'"${_pkgver//+/.}"'"&' -i "fanficfare/cli.py"
  }
fi

prepare() {
  (_prepare)

  cd "$_pkgsrc"
  patch -p1 -i ../0001-makeplugin-do-not-bundle-system-dependencies.patch
}

build() {
  cd "$_pkgsrc"
  python -m build --wheel --no-isolation

  for i in calibre-plugin/translations/*.po; do
    msgfmt -vv "$i" -o "${i%.po}.mo"
  done
  python makeplugin.py
}

package() {
  cd "$_pkgsrc"
  python -m installer --destdir="$pkgdir" dist/FanFicFare-*.whl
  install -Dm644 FanFicFare.zip "$pkgdir"/usr/share/calibre/system-plugins/FanFicFare.zip
}