forked from secureblue/hardened-chromium-subresource-filter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardened-chromium-subresource-filter.spec
182 lines (163 loc) · 5.9 KB
/
hardened-chromium-subresource-filter.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
%global numjobs %{_smp_build_ncpus}
%global build_target() \
export NINJA_STATUS="[%2:%f/%t] " ; \
ninja -j %{numjobs} -C '%1' '%2'
%global chromium_pybin %{__python3}
%global chromebuilddir out/Release
Name: hardened-chromium-subresource-filter
BuildArch: noarch
Requires: hardened-chromium
License: GPL-2.0
Summary: Subresource filter for hardened-chromium
# This doesn't need to be incremented often
Version: 130.0.6723.116
# Automatically generated version number, so that it doesn't need to be incremented manually
%{lua: print("Release: "..os.time().."\n")}
Source0: chromium-%{version}-clean.tar.xz
Source1: install_filter.sh
Source2: easylist.txt
Source3: easyprivacy.txt
Source4: fanboy-annoyance.txt
Source5: abpindo.txt
Source6: abpvn-IPl6HE.txt
Source7: adblock_bg.txt
Source8: NordicFiltersABP-Inclusion.txt
Source9: easylistchina.txt
Source10: filters.txt
Source11: easylistdutch.txt
Source12: easylistgermany.txt
Source13: EasyListHebrew.txt
Source14: easylistitaly.txt
Source15: easylistlithuania.txt
Source16: easylistpolish.txt
Source17: easylistportuguese.txt
Source18: easylistspanish.txt
Source19: indianlist.txt
Source20: koreanlist.txt
Source21: latvian-list.txt
Source22: liste_ar.txt
Source23: liste_fr.txt
Source24: rolist.txt
Source25: ruadlist.txt
Source26: antiadblockfilters.txt
Source27: SerboCroatianList.txt
Source28: Frellwits-Swedish-Filter.txt
# Dependencies required
BuildRequires: gn
BuildRequires: ninja-build
BuildRequires: clang
BuildRequires: llvm
BuildRequires: lld
BuildRequires: rustc
BuildRequires: nss-devel >= 3.26
BuildRequires: glib2-devel
BuildRequires: %{chromium_pybin}
BuildRequires: cups-devel
BuildRequires: libxkbcommon-devel
BuildRequires: libudev-devel
BuildRequires: dbus-devel
BuildRequires: libdrm-devel
BuildRequires: atk-devel
BuildRequires: libcurl-devel
BuildRequires: at-spi2-atk-devel
BuildRequires: pango-devel
BuildRequires: mesa-libgbm-devel
BuildRequires: gtk3-devel
BuildRequires: mesa-libGL-devel
# One of the python scripts invokes git to look for a hash. So helpful.
BuildRequires: /usr/bin/git
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Widgets)
BuildRequires: pkgconfig(Qt6Core)
BuildRequires: pkgconfig(Qt6Widgets)
BuildRequires: libva-devel
BuildRequires: libatomic
%description
Filter used by hardened-chromium to provide content blocking.
%prep
%setup -q -n chromium-%{version}
%build
FLAGS=' -Wno-deprecated-declarations -Wno-unknown-warning-option -Wno-unused-command-line-argument'
FLAGS+=' -Wno-unused-but-set-variable -Wno-unused-result -Wno-unused-function -Wno-unused-variable'
FLAGS+=' -Wno-unused-const-variable -Wno-unneeded-internal-declaration -Wno-unknown-attributes -Wno-unknown-pragmas'
CFLAGS="$FLAGS"
CXXFLAGS="$FLAGS"
LDFLAGS="-Wl,-z,now -Wl,-z,pack-relative-relocs"
export CC=clang
export CXX=clang++
export AR=llvm-ar
export NM=llvm-nm
export READELF=llvm-readelf
export CFLAGS
export CXXFLAGS
export LDFLAGS
export RUSTC_BOOTSTRAP=1
rustc_version="$(rustc --version)"
rust_bindgen_root="%{_prefix}"
# set clang version
clang_version="20"
clang_base_path="$(pwd)/third_party/llvm-build/Release+Asserts/"
CHROMIUM_GN_DEFINES=""
CHROMIUM_GN_DEFINES+=' custom_toolchain="//build/toolchain/linux/unbundle:default"'
CHROMIUM_GN_DEFINES+=' host_toolchain="//build/toolchain/linux/unbundle:default"'
CHROMIUM_GN_DEFINES+=' system_libdir="%{_lib}"'
CHROMIUM_GN_DEFINES+=' is_clang=true'
CHROMIUM_GN_DEFINES+=" clang_base_path=\"$clang_base_path\""
CHROMIUM_GN_DEFINES+=" clang_version=\"$clang_version\""
CHROMIUM_GN_DEFINES+=' clang_use_chrome_plugins=false'
CHROMIUM_GN_DEFINES+=' use_lld=true'
CHROMIUM_GN_DEFINES+=' rust_sysroot_absolute="%{_prefix}"'
CHROMIUM_GN_DEFINES+=" rust_bindgen_root=\"$rust_bindgen_root\""
CHROMIUM_GN_DEFINES+=" rustc_version=\"$rustc_version\""
CHROMIUM_GN_DEFINES+=' use_sysroot=false'
CHROMIUM_GN_DEFINES+=' chrome_pgo_phase=0'
export CHROMIUM_GN_DEFINES
mkdir -p %{chromebuilddir} && cp -a %{_bindir}/gn %{chromebuilddir}/
# Build the converter tool
%{chromebuilddir}/gn --script-executable=%{chromium_pybin} gen --args="$CHROMIUM_GN_DEFINES" %{chromebuilddir}
%build_target %{chromebuilddir} subresource_filter_tools
# Run the tool to generate the blocklist
cp %{SOURCE2} .
cp %{SOURCE3} .
cp %{SOURCE4} .
cp %{SOURCE5} .
cp %{SOURCE6} .
cp %{SOURCE7} .
cp %{SOURCE8} .
cp %{SOURCE9} .
cp %{SOURCE10} .
cp %{SOURCE11} .
cp %{SOURCE12} .
cp %{SOURCE13} .
cp %{SOURCE14} .
cp %{SOURCE15} .
cp %{SOURCE16} .
cp %{SOURCE17} .
cp %{SOURCE18} .
cp %{SOURCE19} .
cp %{SOURCE20} .
cp %{SOURCE21} .
cp %{SOURCE22} .
cp %{SOURCE23} .
cp %{SOURCE24} .
cp %{SOURCE25} .
cp %{SOURCE26} .
cp %{SOURCE27} .
cp %{SOURCE28} .
./%{chromebuilddir}/ruleset_converter --input_format=filter-list --output_format=unindexed-ruleset --input_files=easylist.txt,easyprivacy.txt,fanboy-annoyance.txt,abpindo.txt,abpvn-IPl6HE.txt,adblock_bg.txt,NordicFiltersABP-Inclusion.txt,easylistchina.txt,filters.txt,easylistdutch.txt,easylistgermany.txt,EasyListHebrew.txt,easylistitaly.txt,easylistlithuania.txt,easylistpolish.txt,easylistportuguese.txt,easylistspanish.txt,indianlist.txt,koreanlist.txt,latvian-list.txt,liste_ar.txt,liste_fr.txt,rolist.txt,ruadlist.txt,antiadblockfilters.txt,SerboCroatianList.txt,Frellwits-Swedish-Filter.txt --output_file=hardened-chromium-blocklist > /dev/null
cp hardened-chromium-blocklist ../
# Cleanup
rm -r %{chromebuilddir}
%install
INSTALL_DIR="%{buildroot}%{_sysconfdir}/chromium/filter"
SCRIPT_DIR="%{buildroot}%{_libdir}/chromium-browser/"
mkdir -p "$INSTALL_DIR"
mkdir -p "$SCRIPT_DIR"
install -m 0644 hardened-chromium-blocklist "$INSTALL_DIR/hardened-chromium-blocklist"
install -m 0755 %{SOURCE1} "$SCRIPT_DIR/install_filter.sh"
echo "%{release}" > $INSTALL_DIR/hardened-chromium-blocklist-version.txt
chmod a+r $INSTALL_DIR/hardened-chromium-blocklist-version.txt
%files
%{_sysconfdir}/chromium/filter/hardened-chromium-blocklist
%{_sysconfdir}/chromium/filter/hardened-chromium-blocklist-version.txt
%{_libdir}/chromium-browser/install_filter.sh