summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 23322c2f4105849203f614f28f3c0f597b511c67 (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
# Maintainer:  Vitalii Kuzhdin <vitaliikuzhdin@gmail.com>
# Contributor: ccat3z <c0ldcat3z@gmail.com>

_pkgname="miktex"
pkgname="${_pkgname}-git"
pkgver=24.12.r11.g4910e19
pkgrel=1
pkgdesc="A distribution of the TeX/LaTeX typesetting system"
arch=('x86_64')
url="https://miktex.org"
_url="https://github.com/MiKTeX/${_pkgname}"
license=('custom:MiKTeX License')
depends=('boost-libs' 'bzip2' 'cairo' 'curl' 'expat' 'fontconfig' 'freetype2'
         'fribidi' 'gcc-libs' 'gd' 'glibc' 'graphite' 'harfbuzz' 'hunspell'
         'icu' 'libmspack' 'libpng' 'log4cxx' 'mpfi' 'mpfr' 'openssl'
         'poppler-qt6' 'popt' 'qt6-5compat' 'qt6-base' 'qt6-declarative'
         'qt6-tools' 'uriparser' 'xz' 'zlib' 'zziplib')
makedepends=('apr' 'apr-util' 'boost' 'cmake>=3.12' 'git' 'gmp' 'harfbuzz-icu'
             'libjpeg' 'libxslt' 'pixman' 'poppler' 'potrace')
provides=("${_pkgname}=${pkgver%%.r*}")
conflicts=("${_pkgname}")
_pkgsrc="${_pkgname}"
source=("${_pkgsrc}::git+${_url}.git"
        "${_pkgname}_format_security.patch")
sha256sums=('SKIP'
            'a094dbfb9221664303179e8a3c3093dd4095e05ef0312d41dcd1482bca99b2a5')

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

prepare() {
  cd "${srcdir}/${_pkgsrc}"
  patch -Np1 -i "${srcdir}/${_pkgname}_format_security.patch"

  find . -type f \( -name '*.h' -o -name '*.cpp' \) -exec \
    sed -i 's|log4cxx/rollingfileappender.h|log4cxx/rolling/rollingfileappender.h|g' {} +

  cd "cmake/modules"
  cp "FindPOPPLER_QT5.cmake" "FindPOPPLER_QT6.cmake"
  sed -e 's/QT5/QT6/g' \
      -e 's/qt5/qt6/g' \
      -i "FindPOPPLER_QT6.cmake"
}

build() {
  cd "${srcdir}"
  cmake \
    -G 'Unix Makefiles' \
    -B "${_pkgsrc}/build" \
    -S "${_pkgsrc}" \
    -DCMAKE_BUILD_TYPE:STRING='None' \
    -DCMAKE_INSTALL_PREFIX:PATH="/opt/${_pkgname}" \
    -DWITH_UI_QT=ON \
    -DUSE_SYSTEM_POPPLER=TRUE \
    -DUSE_SYSTEM_POPPLER_QT=TRUE \
    -Wno-dev
  cmake --build "${_pkgsrc}/build"
}

check() {
  cd "${srcdir}"
  ctest --test-dir "${_pkgsrc}/build" --output-on-failure --stop-on-failure
}

package() {
  cd "${srcdir}"
  DESTDIR="${pkgdir}" cmake --install "${_pkgsrc}/build"

  cd "${srcdir}/${_pkgsrc}"
  install -vDm644 "README.md"    "${pkgdir}/usr/share/doc/${_pkgname}/README.md"
  install -vDm644 "HACKING.md"   "${pkgdir}/usr/share/doc/${_pkgname}/HACKING.md"
  install -vDm644 "CHANGELOG.md" "${pkgdir}/usr/share/doc/${_pkgname}/CHANGELOG.md"
  install -vDm644 "COPYING.md"   "${pkgdir}/usr/share/licenses/${_pkgname}/COPYING.md"

  cd "${pkgdir}/opt/${_pkgname}"
  find "share" -type f -exec install -Dm644 "{}" "${pkgdir}/usr/{}" \;
  find "man"   -type f -exec install -Dm644 "{}" "${pkgdir}/usr/share/{}" \;
  rm -rf "share" "man"

  cd "${pkgdir}/usr/share/applications"
  find "icons" -type f -exec install -Dm644 "{}" "${pkgdir}/usr/share/{}" \;
  rm -rf "icons"

  sed -i 's|Exec=|Exec=/opt/miktex/bin/|' "miktex-console.desktop"

  cd "${pkgdir}/usr/share/polkit-1/actions"
  sed -i 's|/usr/bin|/opt/miktex/bin|' "miktex-console.policy"

  cd "${pkgdir}/opt/${_pkgname}/bin"
  for _gsu in pkexec kdesu gksu; do
    ln -s "/usr/bin/${_gsu}" "${_gsu}"
  done

  install -dm755 "${pkgdir}/usr/bin"
  find . -type f -name 'miktex*' -exec ln -s "/opt/miktex/bin/{}" "${pkgdir}/usr/bin/{}" \;
}