4 from os.path import join
6 # digsigsums.py generate DEBIAN/digsigsums for aegis on meego 1.2 harmattan
7 # it is meant to be run just before dh_builddeb from the builddirectory with the package name as parameter
8 # builds the digsigsums file in ./debian/$packagename/DEBIAN/
10 def check_file(filePath):
11 fh = open(filePath, 'r')
12 if fh.read(2) == '#!':
18 def hash_file(filePath, packageName):
20 # S 15 com.nokia.maemo H 40 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx R 5 abcde
21 # Source (might change) hash (sha1) relative path
22 if '/DEBIAN/' in filePath:
23 relativepath = 'var/lib/dpkg/info/{0}.{1}'.format(packageName, filePath[15+len(packageName):])
25 relativepath = filePath[8+len(packageName):]
27 fileToHash = open (filePath, 'rb')
29 sha1.update(fileToHash.read())
30 hashString = sha1.hexdigest()
32 return 'S 15 com.nokia.maemo H 40 {0} R {1} {2}\n'.format(hashString, len(relativepath), relativepath)
35 if(len(sys.argv) > 1):
36 packageName = sys.argv[1]
38 # generate DEBIAN/digsigsums for control.tar.gz
39 digsigsums = open('debian/'+packageName+'/DEBIAN/digsigsums', 'w')
40 for path, dirs, files in os.walk('debian/'+packageName):
41 for filename in files:
42 if check_file(join(path,filename)):
43 digsigsums.write(hash_file(join(path,filename), packageName))