summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 2026246e5c8c6ec4c117650917544ce09fe89ff9 (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
# Maintainer: Aleksandr Beliaev <trap000d at gmail dot com>

pkgname=quarto-cli-git
pkgver=1.4.516.r8.g7d95eb886
pkgrel=1

_pkgbasename=quarto-cli
_denodomver="0.1.35-alpha-artifacts"
_deno_arch="deno-x86_64-unknown-linux-gnu"
pkgdesc="Quarto is an open-source scientific and technical publishing system built on [Pandoc](https://pandoc.org). This package tracks main git branch of Quarto."
arch=('x86_64' 'i686')
depends=('nodejs' 'deno' 'dart-sass' 'esbuild' 'pandoc' 'lua-lpeg' 'typst')
makedepends=('git' 'npm' 'rust')
url="https://quarto.org/"
license=('MIT')
provides=("quarto")
conflicts=('quarto-cli-bin' 'quarto-cli' 'quarto-cli-pre-release')
options=(!strip)

source=("git+https://github.com/quarto-dev/quarto-cli.git"
        "https://github.com/b-fuze/deno-dom/archive/refs/tags/v${_denodomver}.tar.gz"
       )

sha256sums=('SKIP'
            '14fb042a6912041b9fda91fd643cf278764d075bc9539aa1e107475915cd896c')

pkgver() {
  cd ${_pkgbasename}
  git describe --tags | sed 's/^v//' | sed 's/\([^-v]*-g\)/r\1/;s/-/./g'
}

build() {
  cd "${srcdir}/${_pkgbasename}"
  source configuration
  source "${srcdir}/${_pkgbasename}/package/src/set_package_paths.sh"
  export QUARTO_VERSION=${pkgver}
  export QUARTO_VENDOR_BINARIES='false'
  export DENO_DOM_PLUGIN="${srcdir}/deno-dom-${_denodomver}/target/release/libplugin.so"
  if [ -z "$QUARTO_DENO" ]; then
    export QUARTO_DENO=$SCRIPT_PATH/../dist/bin/tools/deno
  fi
  # keep deno cache directory out of default $home/.cache/deno
  export DENO_DIR="${srcdir}/${_pkgbasename}/package/cache"
  # Rust optimizations
  export CARGO_HOME="${srcdir}/${_pkgbasename}/.cargo"
  export RUSTFLAGS="-C strip=symbols"

  mkdir -p package/dist/bin/tools/${arch}/dart-sass
  mkdir -p package/dist/bin/tools/${arch}/deno_dom
  cp /usr/bin/deno package/dist/bin/tools
  ln -sfT /usr/bin/pandoc package/dist/bin/tools/${arch}/pandoc
  ln -sfT /usr/bin/sass package/dist/bin/tools/${arch}/dart-sass/sass
  ln -sfT /usr/bin/esbuild package/dist/bin/tools/${arch}/esbuild

  msg "Building Deno Stdlib..."
  cd "${srcdir}/deno-dom-${_denodomver}"
  cargo build --release

  cd "${srcdir}/${_pkgbasename}"
  # unsure if it's needed at all
  # package/dist/bin/tools/deno run --allow-all package/src/common/create-deno-config.ts > deno.jsonc
  cd package/src
  #../dist/bin/tools/deno run --unstable --allow-env --allow-read --allow-write --allow-run --allow-net --allow-ffi --importmap=../../src/dev_import_map.json bld.ts configure --log-level info
  ../dist/bin/tools/deno run --unstable --allow-env --allow-read --allow-write --allow-run --allow-net --allow-ffi --importmap=../../src/import_map.json bld.ts prepare-dist --log-level info

}

package() {
  cd "${srcdir}/${_pkgbasename}"
  mkdir -p package/pkg-working/bin/tools/${arch}/dart-sass
  mkdir -p package/pkg-working/bin/tools/${arch}/deno_dom
  cp "${srcdir}/deno-dom-${_denodomver}/target/release/libplugin.so" "${srcdir}/${_pkgbasename}/package/pkg-working/bin/tools/${arch}/deno_dom"
  # keep legacy pandoc location, see https://github.com/quarto-dev/quarto/issues/237
  ln -sfT /usr/bin/pandoc package/pkg-working/bin/tools/pandoc
  ln -sfT /usr/bin/pandoc package/pkg-working/bin/tools/${arch}/pandoc
  ln -sfT /usr/bin/deno package/pkg-working/bin/tools/${arch}/deno
  ln -sfT /usr/bin/sass package/pkg-working/bin/tools/${arch}/dart-sass/sass
  ln -sfT /usr/bin/esbuild package/pkg-working/bin/tools/${arch}/esbuild
  ln -sfT /usr/bin/typst package/pkg-working/bin/tools/${arch}/typst
  ## 2. Remove symlinks created by build script in ~/bin and ~/.local/bin directories
  rm -f "$HOME/.local/bin/quarto"
  rm -f "$HOME/bin/quarto"

  install -d ${pkgdir}/usr/{bin,lib/${_pkgbasename}/{bin,share}}
  cp -R package/pkg-working/* "${pkgdir}/usr/lib/${_pkgbasename}"
  ln -sf "/usr/lib/${_pkgbasename}/bin/quarto" "$pkgdir/usr/bin/quarto"
}