summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e58460b7cc341ed0c4ffbb0583ad5072387c6918 (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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# Maintainer:

: ${_plugins:=addons:autoclose:automark:geanylua:git-changebar:lsp:overview:projectorganizer:spellcheck:treebrowser:webhelper}

_plugins_split=(${_plugins//:/ })

: ${_lua_sys:=lua55}
: ${_lua:=lua55}
: ${_libsoup_ver=3}
: ${_webkit2gtk_ver=-4.1}

_pkgbase="geany-plugins-split"
pkgbase="$_pkgbase-git"
pkgver=2.1.0.r42.gd41be8b
pkgrel=2
pkgdesc="Plugins for Geany (split)"
url="https://github.com/geany/geany-plugins"
license=('GPL-2.0-or-later')
arch=('x86_64')

depends=(
  'geany'
)
makedepends=(
  'git'
  'intltool'
  'lua'
  'python-docutils'
  'vte3'
)

_pkgsrc="geany-plugins"
source=(
  "$_pkgsrc"::"git+https://github.com/geany/geany-plugins.git"
  '0001-GeanyLua-PR1238-Multiple-Lua.patch'
  '0002-Project-Organizer-Find-in-Project-Files-fallback.patch'
)
sha256sums=(
  'SKIP'
  'SKIP'
  'SKIP'
)

prepare() {
  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    src="${src%.zst}"
    if [[ $src == *.patch ]]; then
      printf '\nApplying patch: %s\n' "$src"
      patch -d "$_pkgsrc" -Np1 -F100 -i "${srcdir:?}/$src"
    fi
  done

  printf '\nRegenerating geanylua headers...\n'
  pushd /usr/include/geany/scintilla > /dev/null
  local _plugin_path="$srcdir/$_pkgsrc/geanylua"
  lua "$_plugin_path/util/mkiface.lua" > "$_plugin_path/glspi_sci.h"

  sed -E \
    -e '/keydummy\.h/c "cpp -P `pkgconf --cflags geany` /usr/include/geany/keybindings.h"' \
    -i "$_plugin_path/util/mk-keytab.lua"
  lua "$_plugin_path/util/mk-keytab.lua" > "$_plugin_path/glspi_keycmd.h"
  popd > /dev/null
}

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

build() {
  export CFLAGS+=' -w'
  export PYTHON=/usr/bin/python

  # map folder name to flag name
  local -A _flag_map=(
    ['git-changebar']='gitchangebar'
    ['utils']='utilslib'
  )

  cd "$_pkgsrc"
  autoreconf -fi

  local _opts=(
    --prefix=/usr
    --libexecdir=/usr/lib
    --disable-static
    --with-lua-pkg="$_lua"
    --disable-all-plugins
  )

  for _plugin in utils "${_plugins_split[@]}"; do
    local flag="${_flag_map["${_plugin}"]:-$_plugin}"
    _opts+=(--enable-"${flag}")
  done

  ./configure "${_opts[@]}"
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make

  for _plugin in utils "${_plugins_split[@]}"; do
    # utils needed for some plugins
    if [[ ${_plugin} =~ (debugger|geanynumberedbookmarks|scope|treebrowser|workbench) ]]; then
      make -C utils DESTDIR="$srcdir/$_plugin" install
    fi

    make -C "$_plugin" DESTDIR="$srcdir/$_plugin" install

    # unwanted
    rm -rf "$srcdir/$_plugin/usr/share/doc"

    # remove utils
    if [ "$_plugin" != "utils" ]; then
      rm -rf "$srcdir/$_plugin/usr/lib"/libgeanypluginutils.so*
    fi
  done
}

_pkgtype="${pkgbase#$_pkgbase}"
pkgname=("geany-plugin-utilslib${_pkgtype:-}")

eval "package_geany-plugin-utilslib${_pkgtype:-}() {
  pkgdesc='Plugin for Geany - Utils Library'

  optdepends=('vte3')

  provides=(
    'geany-plugin-conflict'
    'geany-plugin-utilslib'
  )
  conflicts=(
    'geany-plugin-conflict'
    'geany-plugin-utilslib'
    'geany-plugins'
  )

  cp -r utils/* \"\$pkgdir/\"
}"

declare -A _seen
for _plugin in "${_plugins_split[@]}"; do
  pkgname+=("geany-plugin-${_plugin}${_pkgtype:-}")

  # clear from last loop
  _depends=()
  _makedeps=()
  _optdeps=()

  case "$_plugin" in
    debugger | geanynumberedbookmarks | scope | treebrowser)
      _depends=('geany-plugin-utilslib' 'vte3')
      ;;
    geanygendoc)
      _depends=('ctpl')
      _makedeps=("${_depends[@]}")
      ;;
    geanylua)
      _depends=("${_lua//${_lua_sys}/lua}")
      _makedeps=("${_depends[@]}")
      ;;
    geanypg)
      _depends=('gpgme')
      _makedeps=("${_depends[@]}")
      ;;
    geniuspaste | updatechecker)
      _depends=("libsoup${_libsoup_ver:-}")
      _makedeps=("${_depends[@]}")
      ;;
    git-changebar)
      _depends=('libgit2')
      _makedeps=("${_depends[@]}")
      ;;
    markdown | webhelper)
      _depends=("webkit2gtk${_webkit2gtk_ver:-}")
      _makedeps=(
        "${_depends[@]}"
        'glib2-devel'
      )
      ;;
    pretty-printer)
      _depends+=('libxml2')
      _makedeps=("${_depends[@]}")
      ;;
    spellcheck)
      _depends=('enchant')
      _makedeps=("${_depends[@]}")
      _optdeps=('hunspell-dictionary')
      ;;
    workbench)
      _depends=('geany-plugin-utilslib' 'vte3')
      _makedeps=('libgit2')
      ;;
  esac

  for _dep in "${_makedeps[@]}"; do
    if [ -z "${_seen[$_dep]}" ]; then
      makedepends+=("$_dep")
      _seen[$_dep]=1
    fi
  done

  if [[ "$_plugin" == "geanylua" ]]; then
    _plugin_desc="Plugin for Geany - $_plugin ($_lua)"
  else
    _plugin_desc="Plugin for Geany - $_plugin"
  fi

  eval "package_geany-plugin-${_plugin}${_pkgtype:-}() {
    pkgdesc='$_plugin_desc'

    provides=('geany-plugin-${_plugin}')
    conflicts=('geany-plugin-${_plugin}')

    depends+=(
      ${_depends[*]}
      geany-plugin-conflict
    )

    $(if [ -n "${_optdeps[*]}" ]; then
    echo "optdepends=(${_optdeps[*]})"
  fi)

    cp -r $_plugin/* \"\$pkgdir/\"
  }"
done