summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4ab5a648959bc7a1d52b4c56ddacc5790268f218 (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
# Maintainer:
# Contributor: Yamada Hayao <hayao@fascode.net>
# Contributer: rilian-la-te <ria.freelander@gmail.com>

# options
: ${_autoupdate:=false}

: ${_build_git:=false}

unset _pkgtype
[[ "${_build_git::1}" == "t" ]] && _pkgtype+="-git"

# basic info
_name="vala-panel-appmenu"
_pkgname="$_name-registrar"
pkgname="$_pkgname${_pkgtype:-}"
pkgver=24.02
pkgrel=1
pkgdesc="Small utility to hold DBusMenu menus"
url="https://gitlab.com/vala-panel-project/vala-panel-appmenu"
license=('LGPL-3.0-or-later')
arch=('i686' 'x86_64')

# main package
_main_package() {
  depends=(
    'glib2'

    ## implicit
    #gcc-libs
    #glibc
  )
  makedepends=(
    'git'
    'meson'
  )

  if [ "${_build_git::1}" != "t" ] ; then
    _update_version
    _main_stable
  else
    _main_git
  fi
}

# stable package
_main_stable() {
  conflicts+=("$_pkgname-git")

  _pkgsrc="$_name"
  _path="subprojects/registrar"
  source+=("$_pkgsrc"::"git+$url.git#tag=$_pkgver")
  sha256sums+=('SKIP')

  pkgver() {
    echo "${_pkgver:?}"
  }
}

# git package
_main_git() {
  provides+=("$_pkgname=${pkgver%%.r*}")
  conflicts+=("$_pkgname")

  _pkgsrc="$_name"
  _path="subprojects/registrar"
  source+=("$_pkgsrc"::"git+$url.git")
  sha256sums+=('SKIP')

  pkgver() {
    cd "$_pkgsrc"

    git describe --long --tags --abbrev=8 --exclude='*[a-zA-Z][a-zA-Z]*' \
      | sed -E 's/^[^0-9]*//;s/([^-]*-g)/r\1/;s/-/./g'
  }
}

# common functions
build() {
  arch-meson "$_pkgsrc/$_path" build
  meson compile -C build
}

package() {
  meson install -C build --destdir "$pkgdir"
}

# update version
_update_version() {
  : ${_pkgver:=${pkgver%%.r*}}

  if [[ "${_autoupdate::1}" != "t" ]] ; then
    return
  fi

  local _response=$(curl -Ssf "$url/-/tags?format=atom")
  local _tag=$(
    printf '%s' "$_response" \
      | grep '"https://.*/tags/.*"' \
      | sed -E 's@^.*/tags/(.*)".*$@\1@' \
      | grep -Ev '[a-z]{2}' | sort -rV | head -1
  )
  local _pkgver_new="${_tag#v}"

  # update _pkgver
  if [ "$_pkgver" != "${_pkgver_new:?}" ] ; then
    _pkgver="${_pkgver_new:?}"
  fi
}

# execute
_main_package