@@ -2772,15 +2772,30 @@ def get_source_tarball_from_git(filename, target_dir, git_config):
27722772
27732773 if keep_git_dir :
27742774 # create archive of git repo including .git directory
2775- tar_cmd = [ ' tar' , ' cfvz' , archive_path , repo_name ]
2775+ tar_cmd = f" tar cfvz { archive_path } { repo_name } "
27762776 else :
27772777 # create reproducible archive
2778- # see https://reproducible-builds.org/docs/archives/
2779- tar_cmd = [
2778+ tar_cmd = reproducible_archive_cmd (repo_name , archive_path )
2779+
2780+ run_shell_cmd (tar_cmd , work_dir = tmpdir , hidden = True , verbose_dry_run = True )
2781+
2782+ # cleanup (repo_name dir does not exist in dry run mode)
2783+ remove (tmpdir )
2784+
2785+ return archive_path
2786+
2787+
2788+ def reproducible_archive_cmd (dir_name , archive_name ):
2789+ """
2790+ Return string with command to make reproducible archive from a given directory
2791+ see https://reproducible-builds.org/docs/archives/
2792+ """
2793+ try :
2794+ cmd_pipe = [
27802795 # stop on failure of any command in the pipe
27812796 'set' , '-eo pipefail' , ';' ,
27822797 # print names of all files and folders excluding .git directory
2783- 'find' , repo_name , '-name ".git"' , '-prune' , '-o' , '-print0' ,
2798+ 'find' , str ( dir_name ) , '-name ".git"' , '-prune' , '-o' , '-print0' ,
27842799 # reset access and modification timestamps to epoch 0
27852800 '-exec' , 'touch' , '--date=1970-01-01T00:00:00.00Z' , '{}' , r'\;' ,
27862801 # reset file permissions of cloned repo (equivalent to --mode in GNU tar)
@@ -2791,14 +2806,12 @@ def get_source_tarball_from_git(filename, target_dir, git_config):
27912806 'tar' , '--create' , '--no-recursion' , '--owner=0' , '--group=0' , '--numeric-owner' ,
27922807 '--format=gnu' , '--null' , '--files-from' , '-' , '|' ,
27932808 # compress tarball with gzip without original file name and timestamp
2794- 'gzip' , '--no-name' , '>' , archive_path
2809+ 'gzip' , '--no-name' , '>' , str ( archive_name )
27952810 ]
2796- run_shell_cmd (' ' .join (tar_cmd ), work_dir = tmpdir , hidden = True , verbose_dry_run = True )
2811+ except TypeError as err :
2812+ raise EasyBuildError ("reproducible_archive_cmd: wrong directory or archive name given" ) from err
27972813
2798- # cleanup (repo_name dir does not exist in dry run mode)
2799- remove (tmpdir )
2800-
2801- return archive_path
2814+ return " " .join (cmd_pipe )
28022815
28032816
28042817def move_file (path , target_path , force_in_dry_run = False ):
0 commit comments