summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b67e427f8acc361f8fdf3fb5a96d93f1451b2623 (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
# Maintainer: Dominic Giebert <dominic.giebert@gmail.com>
# Contributor: Parker Johansen <johansen.parker@gmail.com>

pkgname=rancher-desktop
pkgdesc='Rancher Desktop is an open-source project to bring Kubernetes and container management to the desktop'
pkgver=1.16.0
pkgrel=1
arch=('x86_64')
license=('Apache')
url='https://rancherdesktop.io/'
makedepends=('npm' 'nvm' 'nodejs' 'imagemagick' 'go')
provides=('rancher-desktop' 'docker' 'helm' 'kubectl' 'nerdctl' 'limactl')
depends=('qemu')
source=("https://github.com/rancher-sandbox/rancher-desktop/archive/refs/tags/v${pkgver}.tar.gz")
sha256sums=('0242a086e3e033e70dca82bc7eb3a9f5684a89bda164001b1d6259e75bc76ec5')
options=(!debug)

# https://wiki.archlinux.org/title/Node.js_package_guidelines#Using_nvm
_ensure_local_nvm() {
    which nvm >/dev/null 2>&1 && nvm deactivate && nvm unload
    export NVM_DIR="${srcdir}/.nvm"
    source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]]
}

prepare() {
    _ensure_local_nvm
    nvm install 18

    cd "${pkgname}-${pkgver}"
    sed -i "s|childProcess.execFileSync('git', \['describe', '--tags'\]).toString().trim()|'v${pkgver}'|g" scripts/package.ts

}

build() {
   _ensure_local_nvm
  cd "${pkgname}-${pkgver}"
  # Generate icons
    icon="resources/icons/logo-square-512.png"
    for size in 512x512 256x256 128x128 96x96 64x64 48x48 32x32 24x24 16x16; do
        mkdir "share/icons/hicolor/${size}/apps" -p
        magick "${icon}" -resize "${size}" "share/icons/hicolor/${size}/apps/${pkgname}.png"
    done

  sed -i "s|target: \[ zip \]|target: [ dir ]|g" packaging/electron-builder.yml

  # Remove Flatpak and appimage as they are not needed
  rm packaging/linux/appimage.yml
  rm packaging/linux/flatpak.yaml
  # https://github.com/rancher-sandbox/rancher-desktop#how-to-run
  npm install --global yarn
  yarn install
  yarn build
  yarn package --publish=never
}

package() {
  cd "${pkgname%-bin}-$pkgver"

  # Copy over the data
  install -d "$pkgdir/opt/${pkgname}"
  install -d "$pkgdir/usr/share/icons/hicolor/"
  cp -r dist/linux-unpacked/* "$pkgdir/opt/${pkgname}/"
  cp -r share/icons/hicolor/* "$pkgdir/usr/share/icons/hicolor/"
  install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"

  # Some weird fix
  # Add integration for desktop env
  install -Dm644 dist/linux-unpacked/resources/resources/linux/rancher-desktop.desktop -t "$pkgdir/usr/share/applications"
  install -Dm644 dist/linux-unpacked/resources/resources/linux/rancher-desktop.appdata.xml -t "$pkgdir/usr/share/metainfo"

  # Creating the symlink for better usage
  install -d "$pkgdir"/usr/bin/
  ln -sf /opt/${pkgname}/${pkgname} ${pkgdir}/usr/bin/${pkgname}
}