summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c6f34bce036d9d8bcd0b16b37f69c7a4bc2bc5f1 (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
pkgname=atproto-pds
pkgver=0.4.74
pkgrel=1
pkgdesc='AT Protocol PDS (Personal Data Server)'
url='https://github.com/bluesky-social/pds'
license=(MIT Apache-2.0)
arch=(x86_64 aarch64)
depends=(nodejs)
makedepends=(npm)
source=(
  "git+https://github.com/bluesky-social/pds.git#tag=v$pkgver"
  pdsadmin.sh
  pds.service
  pds.sysusers
  pds.tmpfiles
  pds.env
)
md5sums=(
  SKIP
  6f8dd2c85a0ee59ed4209e059ff84040
  d1c418dcce88825a1df3a2c53953f2ea
  1428828b56dbcb0e7ffaf91b6ce13657
  255bc1f00bfd37afe0c683a46028f049
  157ab2cc7800ec447b2a4508df8867b2
)
backup=(etc/pds.env)

build() {
  cd "$srcdir/pds/service"
  # Patch newer better-sqlite3 for Node.js 23.x support
  head -n-1 package.json >package.json.tmp
  cat >>package.json.tmp <<EOF
  ,"overrides": {
    "@atproto/pds": {
      "better-sqlite3": "11.5.0"
    }
  }
EOF
  tail -n1 package.json >>package.json.tmp
  mv package.json.tmp package.json
  # Install library files
  npm install
}

package() {
  mkdir -p "$pkgdir"/{etc,usr/{bin,lib/atproto-pds{,admin}}}
  # Add library files
  install -Dm 0644 "$srcdir/pds/service/index.js" "$pkgdir/usr/lib/atproto-pds/"
  cp -ar "$srcdir/pds/service/node_modules" "$pkgdir/usr/lib/atproto-pds/"
  # Add entrypoint script for pds application
  cat >"$pkgdir/usr/bin/pds" <<EOF
#!/usr/bin/env sh
cd /usr/lib/atproto-pds
node --enable-source-maps index.js
EOF
  chmod +x "$pkgdir/usr/bin/pds"
  # Add pdsadmin scripts
  for script in "$srcdir/pds/pdsadmin"/*.sh; do
    target="$pkgdir/usr/lib/atproto-pdsadmin/$(basename "$script")"
    install -Dm 0755 "$script" "$target"
    sed -i 's!/pds/pds.env!/etc/pds.env!g' "$target"
  done
  # Add custom script dispatcher
  install -Dm 0755 "$srcdir/pdsadmin.sh" "$pkgdir/usr/bin/pdsadmin"
  # Add user configuration
  install -Dm 0644 pds.service "${pkgdir}/usr/lib/systemd/system/pds.service"
  install -Dm 0644 pds.sysusers "${pkgdir}/usr/lib/sysusers.d/pds.conf"
  install -Dm 0644 pds.tmpfiles "${pkgdir}/usr/lib/tmpfiles.d/pds.conf"
  # Add default configuration
  install -Dm 0640 pds.env "${pkgdir}/etc/pds.env"
}