|
32 |
# <http://www.gnu.org/licenses/>. |
32 |
# <http://www.gnu.org/licenses/>. |
33 |
|
33 |
|
34 |
import os, sys |
34 |
import os, sys |
|
|
35 |
from optparse import OptionParser |
35 |
import subprocess |
36 |
import subprocess |
36 |
import univention.config_registry |
37 |
import univention.config_registry |
37 |
|
38 |
|
|
40 |
if os.environ.get('DH_VERBOSE', False): |
41 |
if os.environ.get('DH_VERBOSE', False): |
41 |
print '\t%s' % ' '.join(argv) |
42 |
print '\t%s' % ' '.join(argv) |
42 |
return subprocess.call(argv) |
43 |
return subprocess.call(argv) |
43 |
|
44 |
|
|
|
45 |
def check_path(path): |
46 |
if not os.path.exists(path): |
47 |
error_path(path) |
48 |
return path |
49 |
|
50 |
def error_path(path): |
51 |
print >> sys.stderr, "File %s was not found" % path |
52 |
sys.exit(1) |
53 |
|
44 |
def getPackages(): |
54 |
def getPackages(): |
45 |
packages = [] |
55 |
packages = [] |
46 |
fp = open('debian/control') |
56 |
fp = open(check_path('debian/control')) |
47 |
for line in fp.readlines(): |
57 |
for line in fp.readlines(): |
48 |
if not line.startswith('Package: '): |
58 |
if not line.startswith('Package: '): |
49 |
continue |
59 |
continue |
|
67 |
if file.startswith('etc/'): |
77 |
if file.startswith('etc/'): |
68 |
f = 'conffiles/'+file[4:] |
78 |
f = 'conffiles/'+file[4:] |
69 |
if os.path.exists(f): return f |
79 |
if os.path.exists(f): return f |
70 |
print "file "+file+" was not found" |
80 |
error_path(file) |
71 |
sys.exit(1) |
|
|
72 |
|
81 |
|
73 |
def destPath(file, package, type='files'): |
82 |
def destPath(file, package, type='files'): |
74 |
return tmpDir(package)+'/etc/univention/templates/'+type+'/'+file |
83 |
return tmpDir(package)+'/etc/univention/templates/'+type+'/'+file |
|
81 |
return type |
90 |
return type |
82 |
else: |
91 |
else: |
83 |
return 'file' |
92 |
return 'file' |
84 |
|
93 |
|
85 |
if __name__ == '__main__': |
94 |
if __name__ == '__main__': |
|
|
95 |
parser = OptionParser( version='univention-install-config-registry @%@package_version@%@') |
96 |
parser.set_usage("Usage: %prog") |
97 |
|
98 |
parser.set_description("""Description: univention-install-config-registry is a debhelper like programm that is responsible for installing template files using univention config registry (UCR) variables into etc/univention/templates/ in the package build directory. The templates references by debian/PACKAGE.univention-config-registry are installed.""") |
99 |
|
100 |
parser.parse_args() |
101 |
|
86 |
for package in getPackages(): |
102 |
for package in getPackages(): |
87 |
file = extFile(package, 'univention-config-registry') |
103 |
file = extFile(package, 'univention-config-registry') |
88 |
if not os.path.exists(file): |
104 |
if not os.path.exists(file): |
|
97 |
try: bla=open('debian/'+package+'.conffiles').readlines() |
113 |
try: bla=open('debian/'+package+'.conffiles').readlines() |
98 |
except IOError: bla=[] |
114 |
except IOError: bla=[] |
99 |
conffiles = open('debian/'+package+'.conffiles','a') |
115 |
conffiles = open('debian/'+package+'.conffiles','a') |
100 |
fp = open(file) |
116 |
fp = open(check_path(file)) |
101 |
filelist = [] |
117 |
filelist = [] |
102 |
for item in univention.config_registry.parseRfc822(fp.read()): |
118 |
for item in univention.config_registry.parseRfc822(fp.read()): |
103 |
if item['Type'][0] == 'file': |
119 |
if item['Type'][0] == 'file': |