summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 14cdb5c743db04d65e21ece856efe35cb2b0f4f1 (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
121
122
123
124
125
126
# Maintainer: Georg Nagel <g.schlmm at gmail dot com>

_pkgbase=penpot
pkgname=(penpot penpot-exporter penpot-frontend)
pkgver=2.1.4
babashka_version="1.3.189"
pkgrel=3
pkgdesc="The open-source design tool for design and code collaboration "
arch=('x86_64')
url="https://penpot.app"
license=('MPL-2.0')
# penpot is using 19, but archlinux only has 17 and 21. 17 and > 21 doesnt work
# also jdk is needed and not only jre
_jdkver="21"
depends=(
  "java-environment>=${_jdkver}" "java-environment<=${_jdkver}"
  'nodejs'
  'redis'
  'postgresql'
  'imagemagick'
  'poppler'
  'potrace'
  'woff2'
  'fontforge'
  'rlwrap'
  'libwebp'
  'fontconfig'
  'ghostscript'
  'netpbm'
  'potrace'
)
makedepends=('clojure' 'git' 'curl' 'npm' 'rsync' 'babashka')
optdepends=(
  "python-tabulator: for the penbot-manage script"
  "sfnt2woff: for uploading own fonts"
  "chromium: for making the exporter work"
)
source=(
  https://github.com/penpot/penpot/archive/refs/tags/$pkgver.tar.gz
  sysusers.conf
  penpot.conf.d
  penpot-exporter.conf.d
  penpot.service
  penpot-exporter.service
  penpot.tmpfiles.d
  penpot-update-flags.sh
  nginx.conf
)
noextract=($pkgname-$pkgver.tgz)
sha256sums=(
  'fcc1bb377c3163e9c6ad8218d8f876f7bfa36f227fdd3030cf05e6a0ea0eceb7'
  '4b82b8a79d8a143fd8a6e4473447f8946c095e2617ba5fcba4cb5b1fdd840c2c'
  'bc133ba7409921978655c488293ef83f77250fd65cb7d574c3cba9f34ff42523'
  '828087c8fab14fb481b4bd01d92f47e9ecc9c07551a7a873bcfbafd1e3644afb'
  'a95f1029cec7cf408cf19cb97cf235c48f671aa93424c138759ee77e239d1c6a'
  '865ac061c90c1f64b60af7f1e36938748e2e2bd45e680b429e41dc9db6892bf8'
  'f3208349de006fc26119cd9b034958bbfa3c161bfb76a752d43d5b563df6e33d'
  'b759994786bcbba553ba50837c8f222760b344319e81655f32ea6e68097ec02a'
  '29f5cde4d5ba6d73b14d6fd88a0be930c6bcf5eff3512332cba50a30316c6621'
)

build() {
  # build the frontend
  cd "${srcdir}/${_pkgbase}-${pkgver}/frontend"
  # we dont have yarn @ version 4 as package, so use npm
  sed -i s/yarn\ /npm\ / ./scripts/build
  sed -i 's/npm install/npm install --dev/' ./scripts/build
  # add buffer to dependencies?
  sed -i 's/"dependencies": {/"dependencies": {"buffer": "*",/' package.json
  sed -i 's/\.git#commit=/.git#/' package.json
  rm -f package-lock.json
  # somehow shadow-cljs is needed but isnt installed (maybe because of not using yarn?)
  npm install --save-dev shadow-cljs
  CURRENT_HASH=$(echo $sha256sums[0] | head -c 7) ./scripts/build $pkgver

  # build the exporter
  cd "${srcdir}/${_pkgbase}-${pkgver}/exporter"
  sed -i s/yarn\ /npm\ / ./scripts/build
  sed -i 's/cp npm.lock target/#/' ./scripts/build
  # patch playwright to use chromium from archlinux
  # so we don't have to install the playwright binaries
  sed -i 's|:args #js|:executablePath "/usr/bin/chromium", :args #js|' src/app/browser.cljs
  ./scripts/build "${pkgver}"
  cd target
  sed -i 's#"packageManager": ".*",#"bin": "./app.js",#' package.json
  sed -i 's#"name": "exporter",#"name": "penpot-exporter",#' package.json
  tar cvf penpot-exporter.tgz .

  # build the backend
  cd "${srcdir}/${_pkgbase}-${pkgver}/backend"
  ./scripts/build "${pkgver}"
  sed -i "2 i JAVA_HOME='$JAVA_HOME'" target/dist/run.sh
  sed -i s#penpot.jar#/usr/share/java/penpot/backend.jar# target/dist/run.sh
}

package_penpot-exporter() {
  npm install -g \
    --cache "${srcdir}/npm-cache" \
    --prefix "${pkgdir}/usr" \
    "${srcdir}/${_pkgbase}-${pkgver}/exporter/target/penpot-exporter.tgz"
  install -Dm644 penpot-exporter.service "${pkgdir}/usr/lib/systemd/system/penpot-exporter.service"
}

package_penpot-frontend() {
  install -dm 755 "${pkgdir}/usr/share/webapps/penpot"
  cp -r "${srcdir}/${_pkgbase}-${pkgver}/frontend/target/dist/"* \
    "${pkgdir}/usr/share/webapps/penpot/"
}

package_penpot() {
  backup=("etc/conf.d/penpot")

  install -Dm644 "${srcdir}/${_pkgbase}-${pkgver}/backend/target/dist/penpot.jar" \
    "${pkgdir}/usr/share/java/penpot/backend.jar"
  install -Dm755 "${srcdir}/${_pkgbase}-${pkgver}/backend/target/dist/run.sh" \
    "${pkgdir}/usr/bin/penpot"
  install -Dm755 "${srcdir}/${_pkgbase}-${pkgver}/backend/target/dist/manage.py" \
    "${pkgdir}/usr/bin/penpot-manage"

  install -Dm755 penpot-update-flags.sh "${pkgdir}/usr/bin/penpot-update-flags.sh"
  install -Dm644 penpot.conf.d "${pkgdir}/etc/conf.d/penpot"
  install -Dm644 penpot.service "${pkgdir}/usr/lib/systemd/system/penpot.service"
  install -Dm644 sysusers.conf "${pkgdir}/usr/lib/sysusers.d/penpot.conf"
  install -Dm644 penpot.tmpfiles.d "${pkgdir}/usr/lib/tmpfiles.d/penpot.conf"
  install -Dm644 nginx.conf "${pkgdir}/usr/share/penpot/nginx.conf"
}