1414import sys
1515import tarfile
1616import shutil
17+ import glob
1718
1819try :
1920 # python3
@@ -66,7 +67,7 @@ def __init__(self):
6667 self .bundles_path = None
6768 self .should_clean = False
6869 # filename -> symlink path e.g 'config.localhost.json' => '../localhost/config.json'
69- self .config_locations = {}
70+ self .symlink_paths = {}
7071 self .verify_signature = True
7172
7273 def deploy (self , tarball , extract_path ):
@@ -98,11 +99,11 @@ def deploy(self, tarball, extract_path):
9899
99100 print ("Extracted into: %s" % extracted_dir )
100101
101- if self .config_locations :
102- for config_filename , config_loc in self .config_locations .iteritems ():
102+ if self .symlink_paths :
103+ for link_path , file_path in self .symlink_paths .iteritems ():
103104 create_relative_symlink (
104- target = config_loc ,
105- linkname = os .path .join (extracted_dir , config_filename )
105+ target = file_path ,
106+ linkname = os .path .join (extracted_dir , link_path )
106107 )
107108
108109 if self .bundles_path :
@@ -165,9 +166,10 @@ def download_file(self, url):
165166 )
166167 )
167168 parser .add_argument (
168- "--config" , nargs = '?' , default = './config.json' , help = (
169- "Write a symlink at config.json in the extracted tarball to this \
170- location. (Default: '%(default)s')"
169+ "--include" , nargs = '*' , default = './config*.json' , help = (
170+ "Symlink these files into the root of the deployed tarball. \
171+ Useful for config files and home pages. Supports glob syntax. \
172+ (Default: '%(default)s')"
171173 )
172174 )
173175 parser .add_argument (
@@ -182,8 +184,8 @@ def download_file(self, url):
182184 deployer .packages_path = args .packages_dir
183185 deployer .bundles_path = args .bundles_dir
184186 deployer .should_clean = args .clean
185- deployer . config_locations = {
186- "config.json" : args .config ,
187- }
187+
188+ for include in args .include :
189+ deployer . symlink_paths . update ({ os . path . basename ( pth ): pth for pth in glob . iglob ( include ) })
188190
189191 deployer .deploy (args .tarball , args .extract_path )
0 commit comments