summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c1d30d4c61f2662ffb60b2f8e9221ffa15239bae (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
# Maintainer: MoetaYuko <loli at yuko dot moe>

# options
if [ x"$_srcinfo" == "xt" ] ; then
  : ${_autoupdate:=false}
elif [ -z "$_pkgver" ] ; then
  : ${_autoupdate:=true}
else
  : ${_autoupdate:=false}
fi

# basic info
pkgbase=material-symbols-git
pkgname=(
  ttf-material-symbols-variable-git
  woff2-material-symbols-variable-git
)
pkgver=4.0.0.r91.ga90037f8
pkgrel=1
pkgdesc="Material Design icons by Google"
url="https://github.com/google/material-design-icons"
license=('Apache')
arch=(any)

# autoupdate
if [[ x"${_autoupdate::1}" == "xt" ]] ; then
  _repo="${url#*//*/}"
  _path="variablefont"
  _response=$(curl -Ssf "https://api.github.com/repos/$_repo/commits?path=$_path")

  _hash=$(
    echo "$_response" \
      | grep -E '^\s*"sha": "' \
      | sed -E 's@^\s*"sha": "([a-f0-9]+)".*$@\1@' \
      | head -1
  )
  _date=$(
    echo "$commit_history" \
      | grep -E '^\s*"(committer|date)": "' \
      | sort -ur | head -1 \
      | sed -E 's@^.*"([0-9]{4})-([0-9]{2})-([0-9]{2})T.*$@\1.\2.\3@'
  )
  _tag=$(
    git ls-remote --tags "$url" \
      | sed -E 's@.*/v?@@' \
      | sort -V \
      | tail -1
  )
  _response_2=$(curl -Ssf "https://api.github.com/repos/$_repo/compare/$_hash...$_tag")

  _revision=$(
    echo "$_response_2" \
      | grep '"behind_by"' \
      | sed -E 's@^\s*"behind_by": ([0-9]+),$@\1@' \
      | head -1
  )

  _pkgver="${_tag}.r${_revision}.g${_hash::8}"
else
  : ${_pkgver:=$pkgver}
fi

# sources
_dl_url="https://raw.githubusercontent.com/google/material-design-icons/master"
_dl_files=(
  "variablefont/MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].ttf"
  "variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf"
  "variablefont/MaterialSymbolsSharp[FILL,GRAD,opsz,wght].ttf"
  "variablefont/MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].woff2"
  "variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].woff2"
  "variablefont/MaterialSymbolsSharp[FILL,GRAD,opsz,wght].woff2"
)
for _src in ${_dl_files[@]} ; do
  local _name="${_src#*/}"
  local _base="${_name%.*}"
  local _ext="${_name##*.}"
  source+=("$_base-$_pkgver.$_ext"::"$_dl_url/$_src")
  sha256sums+=('SKIP')
done

# common functions
pkgver() {
  echo "${_pkgver:?}"
}

package_ttf-material-symbols-variable-git() {
  pkgdesc+=" - variable fonts"
  provides=("${pkgname%-git}")
  conflicts=("${pkgname%-git}")

  for i in *wght*.ttf ; do
    local _ext="${i##*.}"
    local _filename="${i%-$_pkgver.$_ext}"
    install -Dm644 "$i" "$pkgdir/usr/share/fonts/${pkgname%-git}/$_filename.$_ext"
  done
}

package_woff2-material-symbols-variable-git() {
  pkgdesc+=" - variable fonts"
  provides=("${pkgname%-git}")
  conflicts=("${pkgname%-git}")

  for i in *.woff2 ; do
    local _ext="${i##*.}"
    local _filename="${i%-$_pkgver.$_ext}"
    install -Dm644 "$i" "$pkgdir/usr/share/fonts/${pkgname%-git}/$_filename.$_ext"
  done
}