-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_pothos_debian_module_names
executable file
·65 lines (53 loc) · 1.99 KB
/
update_pothos_debian_module_names
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
#!/usr/bin/env python3
import os
import re
import sys
from pothos_scripts_common import *
SUBMODULES = [
'PothosAudio',
'PothosBlocks',
'PothosComms',
'PothosFlow',
'PothosPlotters',
'PothosPython',
'PothosSoapy',
'PothosWidgets',
]
def main():
if len(sys.argv) != 3:
print("Usage: %s [root path] [branch name]"%sys.argv[0])
exit(-1)
ROOT = sys.argv[1]
BRANCH = sys.argv[2]
#extract ABI
for line in open(os.path.join(ROOT, 'PothosCore', 'include', 'Pothos', 'System', 'Version.hpp')).readlines():
m = re.match('#define POTHOS_ABI_VERSION "(.+)"', line.strip())
if m: libraryABI = m.groups()[0]
assert(libraryABI)
print("libraryABI=%s"%libraryABI)
for SUBMODULE in SUBMODULES:
debianDir = os.path.join(ROOT, SUBMODULE, 'debian')
#switch to branch
git_cmd(debianDir, 'checkout', BRANCH)
git_cmd(debianDir, 'pull', 'origin', BRANCH)
#rewrite files
for resource in ['control', 'rules']:
outputLines = list()
outputFile = os.path.join(debianDir, resource)
for line in open(outputFile).readlines():
m = re.match('.*pothos(.+)-modules', line.strip())
if m: line = line.replace('pothos'+m.groups()[0], 'pothos'+libraryABI)
outputLines.append(line)
open(outputFile, 'w').write(''.join(outputLines))
#ensure rules is executable
os.system('chmod +x %s'%os.path.join(debianDir, 'rules'))
#move file for new ABI
for fileName in os.listdir(debianDir):
m = re.match('.*pothos(.+)-modules', fileName)
if m:
newFileName = fileName.replace('pothos'+m.groups()[0], 'pothos'+libraryABI)
git_cmd(debianDir, 'mv', fileName, newFileName)
#make the commit
git_cmd(debianDir, 'commit', '-a', '-m', 'debian: updated to pothos%s module ABI'%libraryABI)
git_cmd(debianDir, 'push', 'origin', BRANCH)
if __name__ == '__main__': main()