import struct
import sha
from dbparse import DBParser
+import sys
MAGIC = 0x52474442
VERSION = 19
+if len(sys.argv) < 3:
+ print 'Usage: %s output-file input-file [key-file]' % sys.argv[0]
+ sys.exit(2)
+
def create_rules(countries):
result = {}
for c in countries.itervalues():
return self._offset
p = DBParser()
-countries = p.parse(file('db.txt'))
+countries = p.parse(file(sys.argv[2]))
power = []
bands = []
for c in countries.itervalues():
# struct regdb_file_reg_country
output.write(struct.pack('>ccxxI', str(alpha2[0]), str(alpha2[1]), reg_rules_collections[coll.permissions]))
-# Load RSA only now so people can use this script
-# without having those libraries installed to verify
-# their SQL changes
-from M2Crypto import RSA
-
-# determine signature length
-key = RSA.load_key('key.priv.pem')
-hash = sha.new()
-hash.update(output.getvalue())
-sig = key.sign(hash.digest())
-# write it to file
-siglen.set(len(sig))
-# sign again
-hash = sha.new()
-hash.update(output.getvalue())
-sig = key.sign(hash.digest())
-
-output.write(sig)
-
-outfile = open('regulatory.bin', 'w')
+
+if len(sys.argv) > 3:
+ # Load RSA only now so people can use this script
+ # without having those libraries installed to verify
+ # their SQL changes
+ from M2Crypto import RSA
+
+ # determine signature length
+ key = RSA.load_key(sys.argv[3])
+ hash = sha.new()
+ hash.update(output.getvalue())
+ sig = key.sign(hash.digest())
+ # write it to file
+ siglen.set(len(sig))
+ # sign again
+ hash = sha.new()
+ hash.update(output.getvalue())
+ sig = key.sign(hash.digest())
+
+ output.write(sig)
+else:
+ siglen.set(0)
+
+outfile = open(sys.argv[1], 'w')
outfile.write(output.getvalue())