summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6e4b73df8b31dd4da9d0d5172a769ffc5eb1c3ec (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
# Maintainer: George Rawlinson <george@rawlinson.net.nz>
# Maintainer: Bret Comnes <bcomnes@gmail.com>

pkgname=homebridge-config-ui-x
pkgver=4.56.2
pkgrel=1
pkgdesc='Web-based management tool for Homebridge'
arch=('any')
url='https://github.com/oznu/homebridge-config-ui-x'
license=('MIT')
depends=('homebridge' 'nodejs')
makedepends=('npm' 'jq')
options=('!emptydirs' '!strip')
source=(
  "https://registry.npmjs.org/$pkgname/-/$pkgname-$pkgver.tgz"
  'systemd.service'
  'systemd.env'
  'tmpfiles.conf'
  'sysusers.conf'
)
noextract=("$pkgname-$pkgver.tgz")
install="$pkgname.install"
sha512sums=('8ec5abfc4831524c739e543553152365661cfb197df6d5a3ea7e6aa8bed7a5eebcdea8d8bf9840ef5063ef9bfa113c2bcf6b0fb6d51bdac5cc50864336fc6d0c'
            '2802f787e1ed60105c853576294552ab6bf544588576bb07c3c8af2ad98be70d2401ef79d746cfe574dd340ca2121c496c552d8cf84a3ae0bdcf668d3bb5725b'
            'ac1e506ea0ed97580bface4afdeb6535168fc187d3c1e88bd44d7be6cc4ac1f4b030553bcbbaadf8cecbe6847d41f59f0cb7e4dca0eddbe3684f6d33e023badb'
            '68e756b0b6b78a53b1198bf630821abe470293c53ebd74d5a42acd589b41940920cfc949853695270f4b5de7c6e7e1b3d42d408694eec8551782a4ef163baeb1'
            'a1722316d9c2e2130a3a7c808fc6570e0176863b72f0a8c511bd8a5a5a5a3c9064f22c25479ca43c856facdcc67d8c161feeefc1225e543471c73b693a493313')
b2sums=('c89abdd1ab39788ba979bac357a1d23def0e7de71b7aa1aeb7cf1845210d65a3f0811b646485affb2f2c6c9e57d5d88657d7420ca7cd50a2afe14ee04b362894'
        '02079c6475bd1d4a1741dd73a6fb5b5a8fdd41049d85c24247eda8e0614f386f48bff77c49de3772fcf2753d0b64bb5932a40c1c441cf0d7a5b00b1426e9514c'
        '739dedb161f3f35da7c423c1298fbb0d4b88c2886382ea17d842469f8d02a11ea4e8fb3322e9b2c05b5235ce87391dcf205b58b42b7ee2fd8289aa1086edc3a0'
        'c60e965907e85b4a6dac12b60419b5446085794bdbdba0221c41e7557ff520c3688ff79b1219e17ac982d585f2cf616140717b44f8ad2a5e5a72fd360617be65'
        '17039410c1e7aa8efd781a6a9acd31084a632998f0ea57f0df40fa028d12527b24bec71fdf28691b8e23fbfdef10c9b327875477ee113ffa9ad022d84a35552e')

package() {
  npm install \
    --global \
    --cache "${srcdir}/npm-cache" \
    --prefix "$pkgdir/usr" \
    --no-audit --no-fund --no-update-notifier \
    "$srcdir/$pkgname-$pkgver.tgz"

  # remove a non-runtime file that kills the packaging step
  rm -r "$pkgdir/usr/lib/node_modules/$pkgname/node_modules/@fastify/send/test/fixtures/snow ☃/"

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" \
    "$pkgdir/usr/lib/node_modules/$pkgname/LICENSE"

  # systemd integration
  install -vDm644 "$srcdir/sysusers.conf" \
    "$pkgdir/usr/lib/sysusers.d/homebridge.conf"
  install -vDm644 "$srcdir/tmpfiles.conf" \
    "$pkgdir/usr/lib/tmpfiles.d/homebridge.conf"
  install -vDm644 "$srcdir/systemd.service" \
    "$pkgdir/usr/lib/systemd/system/homebridge.service"
  install -vDm644 "$srcdir/systemd.env" \
    "$pkgdir/etc/default/homebridge"


  # Clean up srcdir references
  # https://wiki.archlinux.org/title/Node.js_package_guidelines#Package_contains_reference_to_$srcdir/$pkgdir
  find "$pkgdir" -name package.json -print0 | xargs -r -0 sed -i '/_where/d'

  local tmppackage="$(mktemp)"
  local pkgjson="$pkgdir/usr/lib/node_modules/$pkgname/package.json"
  jq '.|=with_entries(select(.key|test("_.+")|not))' "$pkgjson" > "$tmppackage"
  mv "$tmppackage" "$pkgjson"
  chmod 644 "$pkgjson"

  find "$pkgdir" -type f -name package.json | while read pkgjson; do
    local tmppackage="$(mktemp)"
    jq 'del(.man)' "$pkgjson" > "$tmppackage"
    mv "$tmppackage" "$pkgjson"
    chmod 644 "$pkgjson"
  done
}