summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5ab0fce15e1571cf7211bad06461142e91fdcfb9 (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:

## options
: ${_widgets:=qt6}

## basic info
_pkgname="lazpaint"
pkgname="$_pkgname-git"
pkgver=7.2.2.r94.g45a7a47
pkgrel=1
pkgdesc="Image editor written in Free Pascal with Lazarus (${_widgets^})"
url="https://github.com/bgrabitmap/lazpaint"
license=('GPL-3.0-or-later')
arch=('x86_64')

case "${_widgets::1}" in
  g)
    depends=("${_widgets}")
    ;;
  q)
    depends=("${_widgets}pas")
    ;;
esac
makedepends=(
  'git'
  'lazarus'
  'xmlstarlet'
)

provides=("$_pkgname=${pkgver%%.r*}")
conflicts=("$_pkgname")

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

_pkgsrc="$_pkgname"
source=(
  "git+https://github.com/bgrabitmap/lazpaint.git"
  "git+https://github.com/bgrabitmap/bgrabitmap.git"
  "git+https://github.com/bgrabitmap/bgracontrols.git"
)
sha256sums=(
  'SKIP'
  'SKIP'
  'SKIP'
)

_packets=(
  bgrabitmap/bgrabitmap/bgrabitmappack.lpk
  bgracontrols/bgracontrols.lpk
  lazpaint/lazpaintcontrols/lazpaintcontrols.lpk
  lazpaint/lazpaint/lazpaint.lpi
)

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

prepare() {
  # 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
    --build-mode=Release
    --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() {
  depends+=('python')

  local _release="$_pkgsrc/lazpaint/release"
  local _resources="$_pkgsrc/resources"

  # exec
  install -Dm755 "$_release"/bin/lazpaint -t "$pkgdir/usr/bin/"

  # icon
  install -Dm644 "$_resources"/icon/128x128.png "$pkgdir/usr/share/pixmaps/$_pkgname.png"

  # desktop
  install -Dm644 "$_release"/debian/applications/lazpaint.desktop -t "$pkgdir/usr/share/applications/"

  # man
  install -Dm644 "$_release/debian/man/man1/lazpaint.1" -t "$pkgdir/usr/share/man/man1/"

  # resources
  install -dm755 "$pkgdir/usr/share/$_pkgname/scripts"
  cp --reflink=auto -a "$_release"/bin/i18n "$pkgdir/usr/share/$_pkgname/"
  cp --reflink=auto -a "$_release"/bin/models "$pkgdir/usr/share/$_pkgname/"
  cp --reflink=auto -a "$_resources"/scripts/{lazpaint,*.py} "$pkgdir/usr/share/$_pkgname/scripts/"

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