66import yaml
77
88import llnl .util .tty as tty
9- from llnl .util .filesystem import mkdirp
9+ from llnl .util .filesystem import mkdirp , join_path
1010
1111from spack .util .executable import which
1212import spack .cmd
@@ -113,7 +113,7 @@ def tarball_directory_name(spec):
113113def tarball_name (spec , ext ):
114114 """
115115 Return the name of the tarfile according to the convention
116- <os>-<architecture>-<package>-<dag_hash>.tar.gz
116+ <os>-<architecture>-<package>-<dag_hash><ext>
117117 """
118118 return "%s-%s-%s-%s%s" % (get_full_system_from_platform (),
119119 spec .name ,
@@ -136,43 +136,45 @@ def build_tarball(spec, outdir, force=False, key=None):
136136 Build a tarball from given spec and put it into the directory structure
137137 used at the mirror (following <tarball_directory_name>).
138138 """
139- tarfile_dir = os .path .join (outdir , tarball_directory_name (spec ))
140- tarfile_path = os .path .join (outdir , tarball_path_name (spec , '.tar.gz' ))
141- if force :
142- os .remove (tarfile )
143- else :
144- tty .warn ("file exists, use -f to force overwrite: %s" % tarfile )
145- return
146- if not os .path .exists (tarfile_dir ):
147- mkdirp (tarfile_dir )
148-
149- dirname = os .path .dirname (spec .prefix )
150- basename = os .path .basename (spec .prefix )
151- spec_file = os .path .join (spec .prefix , ".spack" , "spec.yaml" )
139+ tarfile_name = tarball_name (spec , '.tar.gz' )
140+ tarfile_dir = join_path (outdir , tarball_directory_name (spec ))
141+ tarfile_path = join_path (tarfile_dir ,tarfile_name )
142+ mkdirp (tarfile_dir )
143+ if os .path .exists (tarfile_path ):
144+ if force :
145+ os .remove (tarfile_path )
146+ else :
147+ tty .warn ("file exists, use -f to force overwrite: %s" % tarfile )
148+ return
149+
150+ spec_file = join_path (spec .prefix , ".spack" , "spec.yaml" )
152151
153152 # create info for later relocation and create tar
153+ write_buildinfo_file (spec )
154154 with tarfile .open (tarfile_path , 'w:gz' ) as tar :
155- write_buildinfo_file (spec )
156-
157- tar .add (basename )
158-
159- spec_info = tar .gettarinfo (spec_file , arcname = '.spack/spec.yaml' )
160- tar .addfile (spec_info )
155+ tar .add (name = '%s' % spec .prefix
156+ , arcname = '%s' % os .path .basename (spec .prefix ))
161157
162158 # Sign the packages.
163159 #spack gpg sign [--key key] tarfile_path
164- #spack gpg sign [--key key] spec_file
160+ #spack gpg sign [--key key] tarfile_path + '/spec.yaml'
161+ path1 = '%s.asc' % tarfile_path
162+ with open (path1 ,'a' ):
163+ os .utime (path1 , None )
164+ path2 = '%s.asc' % spec_file
165+ with open (path2 ,'a' ):
166+ os .utime (path2 , None )
167+
165168
166169 spackfile_path = os .path .join (outdir , tarball_path_name (spec , '.spack' ))
167170 with tarfile .open (spackfile_path , 'w' ) as tar :
168- tar .add (tarfile_path )
169- #tar.add(tarfile_path + '.asc')
170-
171- spec_info = tar .gettarinfo (spec_file , arcname = 'spec.yaml' )
172- tar .addfile (spec_info )
173-
174- #tar.add(spec_file + '.asc')
175-
171+ tar .add (name = '%s' % tarfile_path , arcname = '%s' % tarfile_name )
172+ tar .add (name = '%s' % spec_file , arcname = 'spec.yaml' )
173+ tar .add (name = '%s.asc' % tarfile_path , arcname = '%s.asc' % tarfile_name )
174+ tar .add (name = '%s.asc' % spec_file , arcname = 'spec.yaml.asc' )
175+ os .remove (tarfile_path )
176+ os .remove (path1 )
177+ os .remove (path2 )
176178 tty .msg (tarfile_path )
177179
178180
0 commit comments