summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a1fee7628b5fb2b0dae371b8837912c2bf2f96f0 (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
127
128
129
130
131
132
133
# Maintainer: Zoey Bauer <zoey.erin.bauer@gmail.com>

pkgbase=shelly-cli
pkgname=('shelly-cli' 'shelly-cli-flatpak-backend')
pkgver=3.1.2
pkgrel=1
arch=('x86_64')
url='https://github.com/Seafoam-Labs/Shelly-ALPM'
license=('GPL-3.0-only')
makedepends=(
  'git'
  'pkgconf'
  'zig>=0.16.0'
  'flatpak'
  'ripgrep'
  'go-md2man'
)
source=("${pkgname}::git+https://github.com/Seafoam-Labs/Shelly-ALPM.git#branch=development"
        'shellybuild.conf')
sha256sums=('SKIP'
            '0aff9177498bd94e90c937076d15ac76116c628ec3504a7c1b8c9ea086336ca6')
conflicts=('shelly' 'shelly-git' 'shelly-bin')

pkgver() {
  cd "${srcdir}/${pkgname}"

  printf '3.1.2r%s.g%s' \
    "$(git rev-list --count HEAD)" \
    "$(git rev-parse --short=7 HEAD)"
}

build() {
  cd "${srcdir}/${pkgbase}"

  (cd Shelly.Flatpak.Backend && zig build --verbose \
    --prefix "${srcdir}/zig-out-flatpak-backend" \
    -Dcpu=baseline \
    -Doptimize=ReleaseSafe)

  (cd Shelly.Cli.Zig && zig build --verbose \
    --prefix "${srcdir}/zig-out" \
    -Dcpu=baseline \
    -Doptimize=ReleaseSmall)

  for shell in bash fish zsh; do
    "${srcdir}/zig-out/bin/shelly" utility --completions "${shell}" \
      > "${srcdir}/shelly.${shell}"
  done

  "${srcdir}/zig-out/bin/shelly" utility --docs | go-md2man > "${srcdir}/shelly.1"
  sed -i "s|^\\.TH .*|.TH \"SHELLY-BETA\" \"1\" \"\" \"Shelly CLI Beta ${pkgver}\" \"Shelly CLI Manual\"|" "${srcdir}/shelly.1"
  printf '\n.SH AUTHORS\nSeafoam Labs.\n' >> "${srcdir}/shelly.1"

  sed -i \
    -e 's/_shelly/_shelly_beta/g' \
    -e 's/complete -F _shelly_beta shelly/complete -F _shelly_beta shelly-beta/' \
    "${srcdir}/shelly.bash"
  sed -i 's/complete -c shelly/complete -c shelly-beta/g' \
    "${srcdir}/shelly.fish"
  sed -i \
    -e 's/^#compdef shelly$/#compdef shelly-beta/' \
    -e 's/_shelly/_shelly-beta/g' \
    "${srcdir}/shelly.zsh"
}

check() {
  cd "${srcdir}/${pkgbase}"

  (cd Shelly.Flatpak.Backend && zig build test abi-test integration-test)
  (cd Shelly.PackageManager && zig build flatpak-test)
  (cd Shelly.Cli.Zig && zig build test)
}

package_shelly-cli() {
  pkgdesc='Native Shelly package-manager CLI beta'
  provides=('shelly-beta')
  backup=('etc/shellybuild.conf')
  depends=(
    'diffutils'
    'git'
    'glibc'
    'libarchive'
    'pacman'
    'sudo'
  )
  optdepends=(
    'arch-install-scripts: provision fresh roots for --isolated builds'
    'base-devel: build and install AUR packages'
    'devtools: build AUR packages in a clean chroot'
    'desktop-file-utils: update AppImage desktop entries'
    'fuse2: run AppImages that require FUSE 2'
    'shelly-cli-flatpak-backend: Flatpak package management support'
    'gtk-update-icon-cache: update AppImage icons'
    'opendoas: alternative privilege elevator to sudo'
    'plocate: locate-based pacfile discovery'
    'vim: default visual pacfile diff viewer'
  )

  cd "${srcdir}/${pkgbase}"

  install -Dm755 "${srcdir}/zig-out/bin/shelly" \
    "${pkgdir}/usr/bin/shelly"
  install -Dm644 "${srcdir}/shellybuild.conf" \
    "${pkgdir}/etc/shellybuild.conf"
  install -Dm644 "${srcdir}/shelly.bash" \
    "${pkgdir}/usr/share/bash-completion/completions/shelly-beta"
  install -Dm644 "${srcdir}/shelly.fish" \
    "${pkgdir}/usr/share/fish/vendor_completions.d/shelly-beta.fish"
  install -Dm644 "${srcdir}/shelly.zsh" \
    "${pkgdir}/usr/share/zsh/site-functions/_shelly-beta"
  install -Dm644 "${srcdir}/shelly.1" \
    "${pkgdir}/usr/share/man/man1/shelly-beta.1"
  install -Dm644 LICENSE \
    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

package_shelly-cli-flatpak-backend() {
  pkgdesc='Optional native Flatpak backend for the Shelly CLI beta'
  depends=("shelly-cli=${pkgver}-${pkgrel}" 'flatpak')
  provides=("shelly-flatpak-backend=${pkgver}")
  conflicts=(
    'shelly-flatpak-backend'
    'shelly-flatpak-backend-git'
    'shelly-flatpak-backend-bin'
  )
  optdepends=()

  install -Dm755 \
    "${srcdir}/zig-out-flatpak-backend/lib/libshelly-flatpak-backend.so.1.0.0" \
    "${pkgdir}/usr/lib/shelly/libshelly-flatpak-backend.so.1.0.0"
  ln -s libshelly-flatpak-backend.so.1.0.0 \
    "${pkgdir}/usr/lib/shelly/libshelly-flatpak-backend.so.1"
}