summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 48a7b42e5a21b1d1951e68ae90d8d6d71a5e2dd0 (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
# Maintainer: Mario Finelli <mario at finel dot li>
# Contributor: Igor Dyatlov <dyatlov.igor@protonmail.com>

pkgname=gnome-shell-extension-randomwallpaper
pkgver=3.0.2
pkgrel=1
pkgdesc="Random Wallpapers for Gnome 3"
arch=(any)
url=https://github.com/ifl0w/RandomWallpaperGnome3
license=(MIT)
depends=(gnome-shell)
makedepends=(blueprint-compiler npm)
source=(RandomWallpaperGnome3-$pkgver.tar.gz::${url}/archive/v$pkgver.tar.gz)
sha256sums=('b1fcbe4db1da19215d29629230b071692d5100a1d343d4bfdb26ea8519c9f0bf')

prepare() {
  cd RandomWallpaperGnome3-$pkgver
  npm ci
}

build() {
  cd RandomWallpaperGnome3-$pkgver

  local uuid="$(grep -Po '(?<="uuid": ")[^"]*' src/metadata.json)"
  local schema=$(grep -Po '(?<="settings-schema": ")[^"]*' \
    src/metadata.json).gschema.xml
  mkdir "$uuid"

  # UI
  blueprint-compiler batch-compile "$uuid/ui" src/ui src/ui/*.blp

  # JS
  npx tsc

  # schemas
  mkdir "$uuid/schemas"
  glib-compile-schemas --targetdir="$uuid/schemas" src/schemas

  # static files
  cp "src/schemas/$schema" "$uuid/schemas"
  cp src/metadata.json "$uuid"
  cp src/stylesheet.css "$uuid"

  # pack into zip
  local extra_source=()
  for file in "$uuid"/*; do
    extra_source+=("--extra-source=$file")
  done

  gnome-extensions pack "${extra_source[@]}" "$uuid"
}

package() {
  cd RandomWallpaperGnome3-$pkgver

  local uuid="$(grep -Po '(?<="uuid": ")[^"]*' src/metadata.json)"
  local schema=$(grep -Po '(?<="settings-schema": ")[^"]*' \
    src/metadata.json).gschema.xml
  local destdir="${pkgdir}/usr/share/gnome-shell/extensions/${uuid}"

  install -dm0755 "$destdir"
  bsdtar xvf ${uuid}.shell-extension.zip -C "$destdir/" --no-same-owner
  install -Dm0644 "$destdir/schemas/$schema" \
    -t "$pkgdir/usr/share/glib-2.0/schemas/"

  install -Dm0644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  # gnome-extensions pack doesn't seem to include the extra-source options
  # no matter what I try, so we'll just manually add them to the package now...
  cd "$uuid"
  find ui -type f -name '*.ui' -exec install -Dm0644 {} -t "$destdir/ui/" \;

  for s in adapter manager ui; do
    find $s -type f -name '*.js' -exec install -Dm0644 {} -t "$destdir/$s/" \;
  done

  for js in *.js; do
    [[ $js == extension.js ]] && continue
    [[ $js == prefs.js ]] && continue
    install -Dm0644 $js -t "$destdir/"
  done

  rm -rf "${destdir}/schemas"
}

# vim: set ts=2 sw=2 et: