summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0e46449ca3b6e90a7ffe98e070d0fd9d35f650aa (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
# Maintainer: SpacingBat3 <git@spacingbat3.anonaddy.com>
_suffix="arkenfox-autoconfig"
pkgbase=gecko-$_suffix
pkgname=($_suffix) # Will be generated by shell
pkgver=128.0
pkgrel=1
pkgdesc="A split package which installs arkenfox as autoconfig.js policy on many browsers."
arch=(any)
url="https://github.com/arkenfox/user.js"
license=('MIT')

_gist_author=SpacingBat3
_gist_id=d9b56e0ee88f7a7201e6a45f4858b5e0
_gist_rev=d37c1853333fb7448ecb7124671a40f792751cac

_gh_author=arkenfox
_gh_name=user.js
_gh_rev=$pkgver

_cdn_origin=githubusercontent.com

source=("autoconfig.js"
        "https://gist.$_cdn_origin/$_gist_author/$_gist_id/raw/$_gist_rev/ujs2cfg.sh"
        "arkenfox-v$pkgver.js::https://raw.$_cdn_origin/$_gh_author/$_gh_name/$_gh_rev/user.js"
        "LICENSE-arkenfox-v$pkgver.txt::https://raw.$_cdn_origin/$_gh_author/$_gh_name/$_gh_rev/LICENSE.txt")
md5sums=('f500bce7ef057a7db6c78bed2fe38609'
         '121a7c8c67b8668f8553fcc49e18b4b2'
         'c2ce2302fb2dfdbf70c218ba2bfb1ca9'
         '05ef200686826459427e9769f7aa2c53')
sha512sums=('695695e1279b829b4999bd0c55ad9ab5a1fca4bf67a58568c072a324781df0a712597192005ed69dc63d22cd58bd057d24858a3e445518265d785b0d0f24a9ed'
            '7d66fce8be8ac9ec2df5fe14c5492401e6d5deb04134232e94358f6bd2535ec14245d22194d9da6c93b972fa12d66e0029be8d233c1e0e497d673fd59a1674ec'
            '96173a3abf5d800bbdcfa76d4eaf1b93a843f30d38ed56c631f1cd7adba3c7b6db68d5e7840dcae84cd8bcb1c0cccd286f66772a923e4214e4b83f5560554bf1'
            'e6bda049f5a259d23026c2e7f294d6c0e7eec3be21e07e734e83c89f1509df62112b4d4ef6474593e564a55ed511d17f9294a22b47ebe4dade825c92100b4e1d')
b2sums=('6b379e58ee3768d70cd6abdd61e36c4c01f2903ec2c24bcdae4a71d5e5f1c1961eeced5e5c63474566c9369e50f28338066e1ad3ecdf5bcbd54630b9d510340b'
        'dc413423d7c55223b8dbb61f8417ea199ed53af910d3bdd29add4c0dd2bf9a011535125fbbd74c1a3031be48d48e91f9d63ef4be21e214c8c428014d64595e7c'
        '685a0124dcc092f1452d458e839e262a312f94740088d449988a2e3a3f61f423d3d9547a5e3d254d16b9c614e3bb31c11d704575d0257d22357ea454ddf6aabf'
        'c6a031cb7012627068355909c9ffd70a8d94edc9ddb5834fc6d7722856b21747671f5070c59e73b240303346ee98d117e8cfc656d11caddebf61ac43516f4cc2')

# List of browsers, which install their data in /usr/lib/
_browsers_lib=(firefox{,-{esr,developer-edition}} icecat palemoon)

# List of browsers, which install their data in /opt/
_browsers_opt=(waterfox-g)

# Browsers' full name map (using BASH associative array)
# This is optional to be defined.
declare -A _fn;
_fn["firefox"]="Firefox"
_fn["firefox-esr"]="Firefox ESR"
_fn["firefox-developer-edition"]="Firefox Developer Edition"
_fn["icecat"]="GNU IceCat"
_fn["palemoon"]="Palemoon"
_fn["waterfox-g"]="Waterfox"

# Common package description.
_cdesc() {
	echo "Use arkenfox user.js system-wide, as ${_fn[$1]:-$1} autoconfig.js policy"
}

build() {
	printf '%s' "- Generating a '.cfg' policy from 'user.js' file..."
	sh "$srcdir/ujs2cfg.sh" "$srcdir/arkenfox-v$pkgver.js" > "$srcdir/arkenfox.cfg"
	echo " DONE!"
}

package_arkenfox-autoconfig() {
	pkgdesc="Common files for packages from '$pkgbase' split package"
	install -Dm644 -t "$pkgdir/usr/share/$pkgname/" \
		"$srcdir/"{arkenfox.cfg,autoconfig.js}
	install -Dm644 "LICENSE-arkenfox-v$pkgver.txt" "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt"
}

_package() {
	_moddir="$pkgdir/usr/share/$_suffix/"
	install -dm755 "$pkgdir/$2/$1/defaults/pref"
	ln -sr "$_moddir/arkenfox.cfg" "$pkgdir/$2/$1/"
	ln -sr "$_moddir/autoconfig.js" "$pkgdir/$2/$1/defaults/pref/"
}

_count=0
# Generate `pkgname` and `package_XXX-arkenfox-autoconfig()`:
for _browser in "${_browsers_lib[@]}" "${_browsers_opt[@]}"; do
	pkgname+=("$_browser-$_suffix")
	[ $_count -lt "${#_browsers_lib[@]}" ] && _path='/usr/lib' || _path='/opt'
	_count=$(($_count+1));
	if [ "$DEBUG" = true ]; then
		echo "- Generating scripts for $_browser, installed in $_path..." >&2
	fi
	# Yes, we eval because we're too lazy to type such stuff and update it by hand.
	#
	# It should be safe tho, as most variables store predictible values and
	# we generate stuff at top-level of script, so makepkg should not be able
	# to mess with stuff at that point nor even have a way to stop it if.
	#
	eval \
"package_$_browser-$_suffix(){
	pkgdesc='$(_cdesc "$_browser")'
	provides=('$_browser'-{autoconfig,policy});
	conflicts=('$_browser'-{autoconfig,policy} '$_browser'-user-autoconfig);
	depends=('$_browser' '$_suffix=$pkgver');
	_package '$_browser' '$_path';
}"
done