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

## links
# https://github.com/Alexey-T/CudaText
# https://github.com/Alexey-T/CudaText_up

## options
: ${_widgets=qt6}

## basic info
_pkgname="cudatext"
pkgname="$_pkgname-git"
pkgver=1.219.0.0.r0.gfea21f2
pkgrel=1
pkgdesc="Text editor written in Free Pascal with Lazarus (${_widgets^})"
url="https://github.com/Alexey-T/CudaText"
license=("MPL-2.0")
arch=('x86_64')

depends=(
  'python'
)
makedepends=(
  'git'
  'lazarus'
  'xmlstarlet'
  'imagemagick'
)

case "${_widgets::1}" in
  g)
    depends+=("${_widgets}")
    ;;
  q)
    depends+=("${_widgets}pas")
    ;;
esac

provides=("$_pkgname")
conflicts=("$_pkgname")

options=('!strip' '!debug')

_pkgsrc="CudaText"
source=(
  "git+https://github.com/Alexey-T/ATBinHex-Lazarus"
  "git+https://github.com/Alexey-T/ATFlatControls"
  "git+https://github.com/Alexey-T/ATSynEdit"
  "git+https://github.com/Alexey-T/ATSynEdit_Cmp"
  "git+https://github.com/Alexey-T/ATSynEdit_Ex"
  "git+https://github.com/Alexey-T/CudaText"
  "git+https://github.com/Alexey-T/EControl"
  "git+https://github.com/Alexey-T/Emmet-Pascal"
  "git+https://github.com/Alexey-T/EncConv"
  "git+https://github.com/Alexey-T/Python-for-Lazarus"
  "git+https://github.com/bgrabitmap/bgrabitmap"
)
sha256sums=(
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
)

# order matters; do not alphabetize
_packets=(
  bgrabitmap/bgrabitmap/bgrabitmappack.lpk
  EncConv/encconv/encconv_package.lpk
  ATBinHex-Lazarus/atbinhex/atbinhex_package.lpk
  ATFlatControls/atflatcontrols/atflatcontrols_package.lpk
  ATSynEdit/atsynedit/atsynedit_package.lpk
  ATSynEdit_Cmp/atsynedit_cmp/atsynedit_cmp_package.lpk
  EControl/econtrol/econtrol_package.lpk
  ATSynEdit_Ex/atsynedit_ex/atsynedit_ex_package.lpk
  Python-for-Lazarus/python4lazarus/python4lazarus_package.lpk
  Emmet-Pascal/emmet/emmet_package.lpk
  "$_pkgsrc/app/cudatext.lpi"
)

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

prepare() {
  magick "$_pkgsrc/app/cudatext_fullsize.ico[0]" "$_pkgname.png"

  cat > "$_pkgname.desktop" << END
[Desktop Entry]
Name=CudaText
Comment=$pkgdesc
Exec=$_pkgname %U
Icon=$_pkgname
Terminal=false
Type=Application
Categories=Office;Development;
END

  # modify compiler options
  for i in ${_packets[@]}; do
    xmlstarlet edit --inplace --delete '//Other' "$i"
    sed -E 's&(</CompilerOptions>)&<Other><CustomOptions Value="-O3 -Sa -CX -XX -k'\''--sort-common --as-needed -z relro -z now'\''"/></Other>\n\1&' \
      -i "$i"
  done
}

build() (
  mkdir -p build

  local _laz_opts=(
    --build-all
    --cpu="$CARCH"
    --lazarusdir="/usr/lib/lazarus"
    --os=linux
    --primary-config-path=build
    --widgetset="$_widgets"
  )

  for i in ${_packets[@]}; do
    lazbuild "${_laz_opts[@]}" "$i"
  done
)

package() (
  # binary
  install -Dm755 "$_pkgsrc/app/cudatext" -t "$pkgdir/usr/bin/"

  # launcher
  install -Dm644 "$_pkgname.png" -t "$pkgdir/usr/share/pixmaps/"
  install -Dm644 "$srcdir/$_pkgname.desktop" -t "$pkgdir/usr/share/applications/"

  # share
  for i in data py settings_default; do
    install -dm755 "$pkgdir/usr/share/$_pkgname/$i"
    cp --reflink=auto -a "$_pkgsrc/app/$i"/* "$pkgdir/usr/share/$_pkgname/$i/"
  done

  # permissions
  chmod -R u+rwX,go+rX,go-w "$pkgdir/"
)