summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8b86d0cfa0760b01bbaa90d7835d7a305aaed9f3 (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

# Maintainer: Chakib Benziane (blob42) <contact@blob42.xyz>

pkgname=gosuki-git
_pkgname=${pkgname%-git}
pkgver=v1.3.0.r38.g346c366
pkgrel=1
pkgdesc="Multi-browser, real-time, extension-free bookmark manager with p2p synchronization and archiving"
arch=('i686' 'x86_64')
makedepends=(git git-lfs go make sqlite)
url='https://github.com/blob42/gosuki'
license=(AGPL3)
sha256sums=(SKIP)
provides=("$_pkgname")
conflicts=("$_pkgname")
source=("git+$url.git")

pkgver() {
  cd ${pkgname%-git}
  git describe --tags | sed "s+-+.r+" | tr - .

}

prepare() {
    msg2 'Setting up repository...'
    cd "${_pkgname}"
    git lfs install --local
    if ! git remote -v | grep -q 'network-origin'; then
      git remote add network-origin ${url};
    fi
    git lfs fetch network-origin
    git lfs checkout
}

build() {
  cd "${_pkgname}"

  msg2 'Building...'
  make SYSTRAY=true release

  msg2 'Generating shell completions...'
  make -B completions
}

package() {
  cd ${_pkgname}


  install -Dm 755 build/gosuki -t "$pkgdir"/usr/bin
  install -Dm 755 build/suki -t "$pkgdir"/usr/bin

  install -Dm 644 contrib/linux/etc/systemd/user/${_pkgname}.service \
    "$pkgdir/usr/lib/systemd/user/${_pkgname}.service"


  # Completions
  for completion_file in contrib/*-*.completions; do
      # Skip if no files match the pattern
      [[ -e "$completion_file" ]] || continue

      # Extract the completion type (e.g., fish, bash, zsh) from filename
      basename=$(basename "$completion_file")
      basename=${basename%.completions}
      type=${basename#*-}
      bin=${basename%-*}

      case "$type" in
          fish)
              install -Dm 644 "$completion_file" "${pkgdir}/usr/share/fish/completions/${bin}.fish"
              ;;
          bash)
              install -Dm 644 "$completion_file" "${pkgdir}/usr/share/bash-completion/completions/${bin}"
              ;;
          zsh)
              install -Dm 644 "$completion_file" "${pkgdir}/usr/share/zsh/site-functions/_${bin}"
              ;;
          *)
              exit 1
              echo "Unsupported completion type: $type"
              ;;
      esac
  done


  # documentation
  for _doc in README.md; do
    install -Dm 644 $_doc -t "$pkgdir"/usr/share/doc/"${_pkgname}"
  done

  install -Dm 755 contrib/rofi.sh "${pkgdir}/usr/share/${_pkgname}/scripts/rofi-suki.sh"


  # marktab
  install -Dm 644 contrib/marktab/example.marktab "${pkgdir}/usr/share/doc/${_pkgname}/example.marktab"

  for mt_script in $(find contrib/marktab/scripts -type f -print); do
    msg2 $mt_script
    install -Dm 755 $mt_script "${pkgdir}/usr/share/${_pkgname}/scripts/marktab/$(basename $mt_script)"
  done

  install -Dm 644 contrib/${_pkgname}.1 \
    "${pkgdir}/usr/share/man/man1/${_pkgname}.1"

  install -Dm 644 contrib/suki.1 -t \
    "${pkgdir}/usr/share/man/man1/"


  # cleaning up pkgdir"
  find "$pkgdir" -type d -name .git -exec rm -r '{}' + 2>/dev/null || true
}