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

## options
: ${_widgets=qt6}
: ${_commit=c68f4cda022fed633c1b51cbe7718d60c58da2ba} # 10.1.0

_pkgname="peazip"
pkgname="$_pkgname"
pkgver=10.1.0
pkgrel=1
pkgdesc="Cross-platform file and archive manager (${_widgets^})"
url="https://github.com/peazip/PeaZip"
license=('LGPL-3.0-or-later')
arch=('i686' 'x86_64')

makedepends=(
  'git'
  'lazarus'
  'xmlstarlet'
)
optdepends=(
  'unace'
  'upx'
)

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

options=('!debug')

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

_packets=(
  "$_pkgsrc"/peazip-sources/dev/metadarkstyle/metadarkstyle.lpk
  "$_pkgsrc"/peazip-sources/dev/project_pea.lpi
  "$_pkgsrc"/peazip-sources/dev/project_peach.lpi
)

prepare() {
  # support qt6
  sed -E -e 's&IFDEF LCLQT5&IF DEFINED(LCLQT5) OR DEFINED(LCLQT6)&g' -i "$_pkgsrc/peazip-sources/dev/peach.pas"

  # use system binaries
  sed -E -e 's&(\bHSYSBIN\b\s*)=\s*[0-9];&\1= 2;&' \
    -i "$_pkgsrc/peazip-sources/dev/peach.pas"

  # set p7zip version to 17.05
  sed -E -e '/IFDEF LINUX/s/syntaxlevel7z:=[0-9]+/syntaxlevel7z:=3/' \
    -i "$_pkgsrc/peazip-sources/dev/peach.pas"

  # set paths, needs trailing slash
  sed -E \
    -e 's&(\bHBINPATH\b\s*)=\s*'\'\'';&\1= '\''/usr/bin/'\'';&' \
    -e 's&(\bHSHAREPATH\b\s*)=\s*'\'\'';&\1= '\'"/usr/share/$_pkgname/"\'';&' \
    -i "$_pkgsrc/peazip-sources/dev/peach.pas"

  # 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() {
  local _laz_opts=(
    --build-all
    --cpu="$CARCH"
    --lazarusdir='/usr/lib/lazarus'
    --os='linux'
    --primary-config-path='config'
    --widgetset="$_widgets"
  )

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

package() {
  depends+=(
    'brotli'
    'p7zip'
    'zstd'
  )
  depends+=('hicolor-icon-theme')

  local _path_src

  # binaries
  _path_src="$_pkgsrc/peazip-sources/dev"
  install -Dm755 "$_path_src/peazip" "$pkgdir/usr/bin/peazip"
  install -Dm755 "$_path_src/pea" "$pkgdir/usr/bin/pea"

  # icons
  _path_src="$_pkgsrc/peazip-sources/res/share/icons"
  install -Dm644 "$_path_src"/peazip_{7z,rar,zip}.png -t "$pkgdir/usr/share/icons/hicolor/256x256/mimetypes"
  install -Dm644 "$_path_src"/peazip_{add,extract,browse,convert}.png -t "$pkgdir/usr/share/icons/hicolor/256x256/actions"

  # launcher
  _path_src="$_pkgsrc/peazip-sources/res/share/batch/freedesktop_integration"
  install -Dm644 "$_path_src"/peazip.png -t "${pkgdir}/usr/share/icons/hicolor/256x256/apps"
  install -Dm644 "$_path_src"/peazip.desktop -t "$pkgdir/usr/share/applications"

  # res
  _path_src="$_pkgsrc/peazip-sources/res/share"
  install -dm755 "$pkgdir/usr/share/$_pkgname"
  cp --reflink=auto -a "$_path_src"/{icons,lang,themes} "$pkgdir/usr/share/$_pkgname/"

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