summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e47b6048345aeef81afe0417444c04e4ab82f5fb (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
# Maintainer: Kevin Brodsky <corax26 'at' gmail 'dot' com>

pkgname=xnviewmp-system-libs
_pkgname=xnviewmp
pkgver=1.7.1
srcrel=1 # Incremented when there is a new release for the same version number
pkgrel=1
pkgdesc="An efficient multimedia viewer, browser and converter (using system libraries)."
url="https://www.xnview.com/en/xnviewmp/"

arch=('x86_64')
license=('custom')
depends=(
  # Main Qt dependencies
  'qt5-location' 'qt5-multimedia' 'qt5-quickcontrols2' 'qt5-sensors' 'qt5-svg' 'qt5-x11extras'
  # libmdk dependency
  'libc++'
  # Plugin libs
  'libwebp' 'openjpeg2' 'openexr'
)
optdepends=('glib2: support for moving files to trash')
conflicts=('xnviewmp')

source=("XnViewMP-linux-x64_${pkgver}-rel${srcrel}.tgz::https://download.xnview.com/old_versions/XnView_MP/XnView_MP-${pkgver}-linux-x64.tgz"
        'xnview.sh'
        'xnviewmp.desktop'
        'qt5_std_fun_forwarder.S'
        'qt5_std_fun_forwarder.lds')
sha256sums=('58FDD3D76DF9D5AC0D20811722AAAA95CF8109B24C42826F8501073F968D625D'
            '87ec80c5049745dc3018fcdcf4dddf0e877ae3b20706705f2a80715232ad2141'
            'F6B3A4AAA0A55B5F21D9B91AB6F3DA3D6EE077BA7FDD17E7C4AB1C69AD2A9E3A'
            'D16B4F1ABA4664B169211FD0FE2FF27892AA02F60A5C7C50F55D43FAB0E255DC'
            '3D6DA484CD55EAC8910D5CF87F9057E6EADEAC842A249DCBDA35E1C6F3FCDC0D')

# There is a lot of useless files in the archive, only install those from that
# list.
installed_files_dirs=(
  AddOn
  country.txt
  language
  license.txt
  PrintPresets.txt
  ResizePresets.txt
  UI
  WhatsNew.txt
  XnView
  xnview_2.png
  xnview.png
)

executable_files=(
  AddOn/exiftool
  XnView
)

build() {
  # This is massive hack to work around an incompatibility with the system Qt5
  # libraries. On 0.93.1, the dynamic linker fails to start XnView, complaining
  # that:
  #   symbol _ZNSt20bad_array_new_lengthD1Ev version Qt_5 not defined in file libQt5Gui.so.5 with link time reference
  # (and other functions related to the std::bad_array_new_length class).
  #
  # It seems that the Qt5 libraries shipped in the archive changed in 0.93.1,
  # and they now declare these functions, but our system libs on Arch don't!
  # Since these are STL functions, the workaround is to manually define these
  # functions in a tiny shared library, and implement them by calling the STL
  # functions in libstdc++. This is frankly horrible, but it has worked fine
  # since 0.93.1 so fingers crossed it will stay this way!
  gcc -fPIC -shared -lstdc++ \
    -Wl,--version-script="${srcdir}/qt5_std_fun_forwarder.lds" \
    -o "${srcdir}/qt5_std_fun_forwarder.so" \
    "${srcdir}/qt5_std_fun_forwarder.S"
}

package() {
  cd "${srcdir}/XnView"

  local pkg_opt_dir=${pkgdir}/opt/${_pkgname}

  install -d -m755 "${pkg_opt_dir}"
  # The permissions set in the archive are unreliable and excessive (too many
  # executable files). Instead of copying them, we chmod the files that
  # actually need to be executable.
  cp -r --no-preserve=mode "${installed_files_dirs[@]}" "${pkg_opt_dir}"
  for file in "${executable_files[@]}"; do
    chmod a+x "${pkg_opt_dir}/${file}"
  done

  # The plugin libs that XnView packages are included as dependencies, but
  # XnView will only look for them in the Plugins directory (regardless of the
  # linker paths). Create symlinks as needed.
  install -d -m755 "${pkg_opt_dir}/Plugins"
  ln -s /usr/lib/libwebp.so "${pkg_opt_dir}/Plugins/libwebp.so"
  ln -s /usr/lib/libOpenEXR.so "${pkg_opt_dir}/Plugins/libOpenEXR.so"
  ln -s /usr/lib/libopenjp2.so "${pkg_opt_dir}/Plugins/openjp2.so"

  # Using the system libraw doesn't seem to work (assertion failure in libc when
  # attempting to view a RAW file), use the one provided.
  install -D -m644 "lib/liblibraw.so.1" -t "${pkg_opt_dir}/lib"
  # There is no package for libmdk, which is anyway distributed as binary, so
  # just use the one provided.
  install -D -m644 "lib/libmdk.so.0" -t "${pkg_opt_dir}/lib"

  install -m755 "${srcdir}/xnview.sh" "${pkg_opt_dir}"

  # Install our "function forwarder library" (see build()). xnview.sh forces the
  # dynamic linker to use it by adding it to LD_PRELOAD.
  install -D -m644 "${srcdir}/qt5_std_fun_forwarder.so" -t "${pkg_opt_dir}/lib"

  install -d -m755 "${pkgdir}/usr/bin"
  ln -s "/opt/${_pkgname}/xnview.sh" "${pkgdir}/usr/bin/${_pkgname}"

  install -D -m644 "${srcdir}/${_pkgname}.desktop" -t "${pkgdir}/usr/share/applications/"
  install -D -m644 "${srcdir}/XnView/license.txt" "${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE"
}

# vim:set ts=2 sw=2 et: