@@ -128,7 +128,7 @@ def tarball_path_name(spec, ext):
128128 tarball_name (spec , ext ))
129129
130130
131- def build_tarball (spec , outdir , force = False , rel = False , key = None ):
131+ def build_tarball (spec , outdir , force = False , rel = False , sign = False , key = None ):
132132 """
133133 Build a tarball from given spec and put it into the directory structure
134134 used at the mirror (following <tarball_directory_name>).
@@ -172,38 +172,34 @@ def build_tarball(spec, outdir, force=False, rel=False, key=None):
172172 os .path .basename (spec .prefix ))
173173
174174 # Sign the packages.
175- # spack gpg sign [--key key] tarfile_path
176- # spack gpg sign [--key key] tarfile_path + '/spec.yaml'
177- if key == None :
178- keys = Gpg .signing_keys ()
179- # if len(keys) == 1:
180- # key = keys[0]
181- # elif not keys:
182- # raise RuntimeError('no signing keys are available')
183- # else:
184- # raise RuntimeError('multiple signing keys are available; '
185- # 'please choose one')
186- # temporary to test adding and extracting .asc files
187- path1 = '%s.asc' % tarfile_path
188- with open (path1 , 'a' ):
189- os .utime (path1 , None )
190- path2 = '%s.asc' % specfile_path
191- with open (path2 , 'a' ):
192- os .utime (path2 , None )
193- # temporary to test adding and extracting .asc files
194- #Gpg.sign(key, path1, '%s.asc' % path1)
195- #Gpg.sign(key, path2, '%s.asc' % path2)
196-
175+ if sign :
176+ if key == None :
177+ keys = Gpg .signing_keys ()
178+ if len (keys ) == 1 :
179+ key = keys [0 ]
180+ elif not keys :
181+ raise RuntimeError ('no signing keys are available' )
182+ else :
183+ raise RuntimeError ('multiple signing keys are available; '
184+ 'please choose one' )
185+ Gpg .sign (key , specfile_path , '%s.asc' % specfile_path )
186+ Gpg .sign (key , tarfile_path , '%s.asc' % tarfile_path )
187+ else :
188+ path1 = '%s.asc' % tarfile_path
189+ with open (path1 , 'a' ):
190+ os .utime (path1 , None )
191+ path2 = '%s.asc' % specfile_path
192+ with open (path2 , 'a' ):
193+ os .utime (path2 , None )
197194 with closing (tarfile .open (spackfile_path , 'w' )) as tar :
198195 tar .add (name = '%s' % tarfile_path , arcname = '%s' % tarfile_name )
199196 tar .add (name = '%s' % specfile_path , arcname = '%s' % specfile_name )
200197 tar .add (name = '%s.asc' % tarfile_path , arcname = '%s.asc' % tarfile_name )
201198 tar .add (name = '%s.asc' % specfile_path ,
202199 arcname = '%s.asc' % specfile_name )
203- os .remove (tarfile_path )
204-
205- os .remove (path1 )
206- os .remove (path2 )
200+ os .remove (tarfile_path )
201+ os .remove ('%s.asc' % tarfile_path )
202+ os .remove ('%s.asc' % specfile_path )
207203
208204
209205def download_tarball (spec ):
@@ -229,34 +225,38 @@ def download_tarball(spec):
229225 return None
230226
231227
232- def extract_tarball (spec , filename ):
228+ def extract_tarball (spec , filename , verify = False ):
233229 """
234230 extract binary tarball for given package into install area
235231 """
232+ if arg .verify :
233+ verify = True
236234 installpath = install_directory_name (spec )
237235 mkdirp (installpath )
238236 stagepath = os .path .dirname (filename )
237+ spackfile_name = tarball_name (spec , '.spack' )
238+ spackfile_path = os .path .join (stagepath , spackfile_name )
239239 tarfile_name = tarball_name (spec , '.tar.gz' )
240240 tarfile_path = os .path .join (stagepath , tarfile_name )
241241 specfile_name = tarball_name (spec , '.spec.yaml' )
242242 specfile_path = os .path .join (stagepath , tarfile_name )
243- with closing (tarfile .open (filename , 'r' )) as tar :
243+
244+ with closing (tarfile .open (spackfile_path , 'r' )) as tar :
244245 tar .extract (specfile_name , stagepath )
245246 tar .extract (specfile_name + '.asc' , stagepath )
246-
247- # spack gpg verify os.path.join(package.prefix, 'spec.yaml')
248-
249247 tar .extract (tarfile_name , stagepath )
250248 tar .extract (tarfile_name + '.asc' , stagepath )
251249
252- # spack gpg verify tarfile_path
250+ if verify :
251+ Gpg .verify (specfile_path , '%s.asc' % specfile_path )
252+ Gpg .verify (tarfile_path , '%s.asc' % tarfile_path )
253253
254254 with closing (tarfile .open (tarfile_path , 'r' )) as tar :
255255 tar .extractall (path = join_path (installpath , '..' ))
256256
257- # os.remove(tarfile_path)
257+ os .remove (tarfile_path )
258258 os .remove (tarfile_path + '.asc' )
259- # os.remove(specfile_path)
259+ os .remove (specfile_path )
260260 os .remove (specfile_path + '.asc' )
261261
262262
0 commit comments