summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 2f0b4b29ff556e52ebea0b2d0bf586dc47d4149e (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
# Maintainer: XZS <d.f.fischer at web dot de>
# Contributor: Diego Principe <cdprincipe@at@gmail@dot@com>
# This PKGBUILD is maintained on GitHub <https://github.com/dffischer/mozilla-extensions>.
# You may find it convenient to file issues and pull requests there.

pkgbase='firefox-theme-adwaita-git'
pkgname=('firefox-theme-gnome-git' 'firefox-extension-gnome-theme-tweak-git')
pkgver=45.1
pkgrel=3
pkgdesc="Adwaita theme for Firefox (Matches the default Gnome Shell theme)"
url="https://github.com/gnome-integration-team/firefox-gnome"
arch=('any')
license=('MPL')
depends=("firefox")
makedepends=('unzip' 'zip')

makedepends+=('git')
source+=("${_gitname:=${pkgname%-git}}::${_giturl:-git+$url}")
for integ in $(get_integlist)
do
  typeset -n array="${integ}sums"
  array+=('SKIP')
done
provides+=("$_gitname=$pkgver")
conflicts+=("$_gitname")

# Move down repository content for easier access by following functions.
prepare() {
  cp -rfT --reflink=auto "$_gitname" .
  rm -rf "$_gitname"
}

makedepends+=(rasqal)

sparql() {
  roqet -e "PREFIX em: <http://www.mozilla.org/2004/em-rdf#> SELECT ?x WHERE { $1 }" \
    -D "${2:-install.rdf}" -r csv 2>/dev/null | tr -d '\r' | tail -n 1 | head -c -1
}

# Retrieve current compatibility information from install.rdf.
query-version() {
  sparql "[] em:id '$2' ; em:${1}Version ?x" install.rdf
}

pkgver() {
  find -iname '*.json' -exec sed -n \
    's/.*"version"\s*:\s*"\([[:digit:].]*\)"\s*,.*/\1/p' \
    '{}' \; -quit 2>/dev/null | tr '\n' '.'
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  ./make-xpi.py
}

# Version information for this extension is noted in the config.json and only
# inserted into the install.rdf, so overwriting this function directs it to the
# right location.
query-version() {
  sed -n "s/^ *\"$1-version\": \"\\([^\"]\+\\)\",\$/\\1/p" *.json
}

version-range() {
  if [ -z "$(sparql "?x em:type ?type. filter(?type in ('2', '64'))")" ] ||
    [ -n "$(sparql "?x em:strictCompatibility 'true'")" ] ||
    { [ -e chrome.manifest ] &&
      grep '^binary-component[ \t]' chrome.manifest ; }
  then
    local emid=$(emid $1)
    echo "$1>$(version min $emid)" "$1<$(version max $emid)"
  else
    echo "$1>$(version min $(emid $1))"
  fi
}

emid() {
  case $1 in
    firefox)     echo '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}' ;;
    thunderbird) echo '{3550f703-e582-4d05-9a08-453d09bdfdc6}' ;;
    *) return 1 ;;
  esac
}

version() {
  local version="$(query-version $1 $2)"
  if [[ $version =~ ([[:digit:]]+).\* ]]; then
    if [[ $1 = max ]]; then
      echo $(( ${BASH_REMATCH[1]} + 1 ))
    else
      echo "=${BASH_REMATCH[1]}"
    fi
  else
    echo "=$version"
  fi
}
prepare_target() {
  local target=${pkgname%%-*}
  id="$(sparql '<urn:mozilla:install-manifest> em:id ?x')"
  destdir="$pkgdir/usr/lib/${target/firefox/firefox\/browser}/extensions"
  install -d "$destdir"
}

package() {
  cd .build/$1
  prepare_target
  unzip -d "$destdir/$id" ../../gnome-firefox-$1.xpi
}

package_firefox-theme-gnome-git() {
  real_depends

  package theme
}

# Hide the versioned dependency from .SRCINFO generation in a subfunction.
real_depends() {
  depends+=($(version-range firefox))
}

package_firefox-extension-gnome-theme-tweak-git() {
  provides=('firefox-extension-gnome-theme-tweak')
  conflicts=('firefox-extension-gnome-theme-tweak')
  pkgdesc='Extension for customizing GNOME theme.'
  depends=('firefox-theme-gnome')

  package extension
}