summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a366b9dd971a4c1354a196133c58e04827826232 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Maintainer: xiota / aur.chaotic.cx
# Contributor: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: David Mougey <imapiekindaguy at gmail dot com>

## options
# set to two letter code of language to keep
: ${_localepurge=}

: ${_build_git:=true}

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

# basic info
_pkgname=sigil
pkgname="$_pkgname${_pkgtype:-}"
pkgver=2.0.2.r66.gafab2835
pkgrel=1
pkgdesc='multi-platform EPUB2/EPUB3 ebook editor'
url="https://github.com/Sigil-Ebook/Sigil"
license=('GPL-3.0-or-later')
arch=('x86_64')

# main package
_main_package() {
  depends=(
    'hicolor-icon-theme'
    'hunspell'
    'mathjax'
    'minizip'
    'python-css-parser'
    'python-dulwich'
    'python-lxml'
    'qt6-5compat'
    'qt6-svg'
    'qt6-webengine'
  )
  makedepends=(
    'cmake'
    'git'
    'qt6-tools'
  )
  optdepends=(
    'hunspell-en_US: for English dictionary support'
    'hyphen-en: for English hyphenation support in plugins'
    'pageedit: external editor to replace BookView'
    'pyside6: recommended for plugins'
    'python-chardet: recommended for plugins'
    'python-cssselect: recommended for plugins'
    'python-html5lib: recommended for plugins'
    'python-pillow: recommended for plugins'
    'python-regex: recommended for plugins'
    'tk: recommended for plugins'
  )

  options=(!debug)

  if [ "${_build_git::1}" != "t" ] ; then
    _main_stable
  else
    _main_git
  fi

  source+=(
    '0001-modify-default-navigation-css.patch'
    '0002-skip-epub-version-check.patch'
    '0003-don-t-write-version-and-modified-tags.patch'
  )

  sha256sums+=(
    '157504daff4a410fc14cbe78820940b27e6790e5cd723f1764ca78134630dbee'
    '7d213fa2b5eae33723b1e1a17f0ed28a518e9edcc0496e2a67afc8d0e5cb36e3'
    '820e012907c70260af2cc2be6d1697037e1527f346727f3b4378ea215038b0d6'
  )
}

# stable package
_main_stable() {
  : ${_pkgver:=${pkgver%%.r*}}

  _pkgsrc="$_pkgname"
  source+=("$_pkgsrc"::"git+$url.git#tag=$_pkgver")
  sha256sums+=('SKIP')

  pkgver() {
    echo "${_pkgver:?}"
  }
}

# git package
_main_git() {
  provides=("$_pkgname=${pkgver%%.r*}")
  conflicts=("$_pkgname")

  _pkgsrc="$_pkgname"
  source+=("$_pkgsrc"::"git+$url.git")
  sha256sums+=('SKIP')

  pkgver() {
    cd "$_pkgsrc"
    git describe --long --tags --abbrev=8 --exclude='*[a-zA-Z][a-zA-Z]*' 2>/dev/null \
      | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g'
  }
}

# common funtions
prepare() {
  apply-patch() {
    printf '\nApplying patch %s\n' "$1"
    patch -Np1 -F100 -i "$1"
  }

  cd "$_pkgsrc"

  apply-patch "$srcdir/0001-modify-default-navigation-css.patch"
  apply-patch "$srcdir/0002-skip-epub-version-check.patch"
  apply-patch "$srcdir/0003-don-t-write-version-and-modified-tags.patch"

  # Set _localepurge to disable or keep translations.
  # Specify the two-letter language code of the translation to keep.
  # If language does not exist, all languages will be purged.
  if [[ "${_localepurge}" != "" ]]; then
    for trans in src/Resource_Files/ts/*; do
      if [[ "$(basename $trans | sed -r 's/(_.*)_.*/\1/g')" != "sigil_${_localepurge}" ]]; then
        rm $trans
      fi
    done
  fi
}

build() {
  local _cmake_config=(
    -B build
    -S "$_pkgname"
    -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_INSTALL_PREFIX='/usr'
    -DCMAKE_INSTALL_LIBDIR='lib'
    -DMATHJAX3_DIR='/usr/share/mathjax'
    -DSYSTEM_LIBS_REQUIRED=1
    -DUSE_SYSTEM_LIBS=1
    -DDISABLE_UPDATE_CHECK=1
    -DINSTALL_BUNDLED_DICTS=0
    -DINSTALL_HICOLOR_ICONS=1
    -DCMAKE_SKIP_RPATH=ON
    -Wno-dev
  )

  cmake "${_cmake_config[@]}"
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  # Compile python bytecode
  python -m compileall "${pkgdir:?}/usr/share/sigil/"{plugin_launchers/python/,python3lib}
  python -O -m compileall "$pkgdir/usr/share/sigil/"{plugin_launchers/python/,python3lib}
}

# execute
_main_package