@@ -7,11 +7,22 @@ put into postgresql conf.
77
88On success, starts database
99"""
10- import os ,sys ,subprocess ,glob ,re ,os .path ,time
10+ import os ,sys ,subprocess ,glob ,re ,os .path ,time , re
1111
1212if len (sys .argv )!= 2 :
1313print >> sys .stderr ,"Usage %s data-directory" % sys .argv [0 ]
1414sys .exit (1 )
15+
16+ def prepare_extlist (value ):
17+ v = re .sub ("[']" ,'' ,value )
18+ l = re .split ("\s*,\s*" ,v )
19+ if "pg_pathman" in l :
20+ # remove duplicates and reorder extension list to move pg_pathman to tail
21+ nl = sorted (list (set (l )),cmp = lambda a ,b :1 if a == "pg_pathman" else - 1 )
22+ new_value = "'{}'" .format ("," .join (nl ))
23+ return new_value
24+ else :
25+ return value
1526
1627datadir = sys .argv [1 ]
1728
@@ -27,7 +38,7 @@ if exitcode:
2738sys .exit (exitcode )
2839# Collect extra config option
2940addopts = {}
30- for module in sorted ( glob .glob ("contrib/*" ), cmp = lambda a , b : 1 if a == "pg_pathman" else - 1 ):
41+ for module in glob .glob ("contrib/*" ):
3142if not os .path .isdir (module ):
3243continue
3344if not os .access (module + "/Makefile" ,os .R_OK ):
@@ -59,7 +70,7 @@ for module in sorted(glob.glob("contrib/*"), cmp = lambda a,b: 1 if a=="pg_pathm
5970if addopts :
6071with open (datadir + "/postgresql.conf" ,"a" )as f :
6172for opt ,value in addopts .items ():
62- print >> f ,"%s=%s" % (opt ,value )
73+ print >> f ,"%s=%s" % (opt ,prepare_extlist ( value ) )
6374with open ("initdb.log" ,"a" )as f :
6475exitcode = subprocess .call (["pg_ctl" ,"start" ,"-D" ,datadir ,"-l" ,datadir + "/postmaster.log" ],env = env ,stdout = f ,stderr = subprocess .STDOUT )
6576if exitcode :
@@ -73,5 +84,3 @@ while time.time() < failtime:
7384sys .exit (0 )
7485print >> sys .stderr ,"Database havent't started in 60 seconds"
7586sys .exit (1 )
76-
77-