-
Notifications
You must be signed in to change notification settings - Fork 0
/
v2ray-cap.spec
80 lines (62 loc) · 1.95 KB
/
v2ray-cap.spec
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
%global v2ray_path %{_bindir}/v2ray
Name: v2ray-cap
Version: 1.0.5
Release: 1%{?dist}
Summary: A script for grant network capabilities to v2ray binary.
License: MIT
URL: https://github.com/sixg0000d-copr/v2ray-cap
Requires: libcap
Requires(post): libcap
Requires(preun): libcap
Requires: %{v2ray_path}
BuildArch: noarch
%description
Installing this package will grant V2Ray core binary the capabilities for transparent proxies.
%prep
%build
%install
# Scriptlets >>
%define grant_cap(p:) %{expand:
if [ -z $1 ] || [ $1 -ne 2 ] && [ -x /usr/sbin/setcap ]; then
# Not upgrade
echo ' Granting capabilities to %{-p*}'
/usr/sbin/setcap 'cap_net_bind_service=+ep cap_net_admin=+ep' %{-p*} || :
fi
}
%define revoke_cap(p:) %{expand:
if [ $1 -eq 0 ] && [ -x /usr/sbin/setcap ]; then
# Package removal, not upgrade
echo ' Revoking capabilities from %{-p*}'
/usr/sbin/setcap 'cap_net_bind_service=-ep cap_net_admin=-ep' %{-p*} || :
fi
}
%post
%grant_cap -p %{v2ray_path}
%filetriggerin -- %{v2ray_path}
if (grep 'v2ray$' &>/dev/null); then
%grant_cap -p %{v2ray_path}
fi || :
%preun
%revoke_cap -p %{v2ray_path}
# << Scriptlets
%files
%changelog
* Sun Jan 17 2021 sixg0000d <[email protected]> - 1.0.5 - 1
- Triggered by precise path
* Thu Nov 19 2020 sixg0000d <[email protected]> - 1.0.4 - 1
- Add qualifier requires
- Improve scriptlets
- Change Comments
* Sat Sep 26 2020 sixg0000d <[email protected]> - 1.0.3 - 1
- Fix changelog order
- Improve defined function macros
- Improve scriptlets
- Add dependency for v2ray_path
- Change summary and url
- Add real license
* Tue Sep 22 2020 sixg0000d <[email protected]> - 1.0.2 - 1
- Fix can not remove when v2ray not exists
* Tue Sep 22 2020 sixg0000d <[email protected]> - 1.0.1 - 1
- Remove build arch
* Tue Sep 22 2020 sixg0000d <[email protected]> - 1.0.0 - 1
- Inital v2ray-cap