File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 33# Builds an sqlite DB containing all the rulesets, indexed by target.
44
55import glob
6+ import locale
67import os
78import sqlite3
89import subprocess
1112from collections import Counter
1213from lxml import etree
1314
15+ # Explicitly set locale so sorting order for filenames is consistent.
16+ # This is important for deterministic builds.
17+ # https://trac.torproject.org/projects/tor/ticket/11630#comment:20
18+ # It's also helpful to ensure consistency for the lowercase check below.
19+ locale .setlocale (locale .LC_ALL , 'en_US.UTF8' )
20+
1421conn = sqlite3 .connect (os .path .join (os .path .dirname (__file__ ), '../src/defaults/rulesets.sqlite' ))
1522c = conn .cursor ()
1623c .execute ('''DROP TABLE IF EXISTS rulesets''' )
3441xpath_host = etree .XPath ("/ruleset/target/@host" )
3542xpath_ruleset = etree .XPath ("/ruleset" )
3643
37- filenames = glob .glob ('src/chrome/content/rules/*' )
44+ # Sort filenames so output is deterministic.
45+ filenames = sorted (glob .glob ('src/chrome/content/rules/*' ))
3846
3947counted_lowercase_names = Counter ([name .lower () for name in filenames ])
4048most_common_entry = counted_lowercase_names .most_common (1 )[0 ]
You can’t perform that action at this time.
0 commit comments