@@ -2540,12 +2540,12 @@ def copy(paths, target_path, force_in_dry_run=False, **kwargs):
2540
2540
raise EasyBuildError ("Specified path to copy is not an existing file or directory: %s" , path )
2541
2541
2542
2542
2543
- def get_source_tarball_from_git (filename , targetdir , git_config ):
2543
+ def get_source_tarball_from_git (filename , target_dir , git_config ):
2544
2544
"""
2545
2545
Downloads a git repository, at a specific tag or commit, recursively or not, and make an archive with it
2546
2546
2547
2547
:param filename: name of the archive to save the code to (must be .tar.gz)
2548
- :param targetdir : target directory where to save the archive to
2548
+ :param target_dir : target directory where to save the archive to
2549
2549
:param git_config: dictionary containing url, repo_name, recursive, and one of tag or commit
2550
2550
"""
2551
2551
# sanity check on git_config value being passed
@@ -2584,8 +2584,7 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
2584
2584
raise EasyBuildError ("git_config currently only supports filename ending in .tar.gz" )
2585
2585
2586
2586
# prepare target directory and clone repository
2587
- mkdir (targetdir , parents = True )
2588
- targetpath = os .path .join (targetdir , filename )
2587
+ mkdir (target_dir , parents = True )
2589
2588
2590
2589
# compose 'git clone' command, and run it
2591
2590
if extra_config_params :
@@ -2668,21 +2667,36 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
2668
2667
for cmd in cmds :
2669
2668
run_shell_cmd (cmd , work_dir = work_dir , hidden = True , verbose_dry_run = True )
2670
2669
2671
- # When CentOS 7 is phased out and tar>1.28 is everywhere, replace find-sort-pipe with tar-flag
2672
- # '--sort=name' and place LC_ALL in front of tar. Also remove flags --null, --no-recursion, and
2673
- # --files-from - from the flags to tar. See https://reproducible-builds.org/docs/archives/
2674
- tar_cmd = ['find' , repo_name , '-print0' , '-path \' */.git\' -prune' if not keep_git_dir else '' , '|' ,
2675
- 'LC_ALL=C' , 'sort' , '--zero-terminated' , '|' ,
2676
- 'GZIP=--no-name' , 'tar' , '--create' , '--file' , targetpath , '--no-recursion' ,
2677
- '--gzip' , '--mtime="1970-01-01 00:00Z"' , '--owner=0' , '--group=0' ,
2678
- '--numeric-owner' , '--format=gnu' , '--null' ,
2679
- '--no-recursion' , '--files-from -' ]
2670
+ # Create archive
2671
+ archive_path = os .path .join (target_dir , filename )
2672
+
2673
+ if keep_git_dir :
2674
+ # create archive of git repo including .git directory
2675
+ tar_cmd = ['tar' , 'cfvz' , archive_path , repo_name ]
2676
+ else :
2677
+ # create reproducible archive
2678
+ # see https://reproducible-builds.org/docs/archives/
2679
+ # TODO: when CentOS 7 is phased out and tar>1.28 is everywhere, replace sort step
2680
+ # in the pipe with tar-flag '--sort=name' and place LC_ALL in front of tar.
2681
+ tar_cmd = [
2682
+ # print names of all files and folders excluding .git directory
2683
+ 'find' , repo_name , '-name ".git"' , '-prune' , '-o' , '-print0' ,
2684
+ # reset access and modification timestamps
2685
+ '-exec' , 'touch' , '-t 197001010100' , '{}' , '\;' , '|' ,
2686
+ # sort file list
2687
+ 'LC_ALL=C' , 'sort' , '--zero-terminated' , '|' ,
2688
+ # create tarball in GNU format with ownership reset
2689
+ 'tar' , '--create' , '--no-recursion' , '--owner=0' , '--group=0' , '--numeric-owner' , '--format=gnu' ,
2690
+ '--null' , '--files-from' , '-' , '|' ,
2691
+ # compress tarball with gzip without original file name and timestamp
2692
+ 'gzip' , '--no-name' , '>' , archive_path
2693
+ ]
2680
2694
run_shell_cmd (' ' .join (tar_cmd ), work_dir = tmpdir , hidden = True , verbose_dry_run = True )
2681
2695
2682
2696
# cleanup (repo_name dir does not exist in dry run mode)
2683
2697
remove (tmpdir )
2684
2698
2685
- return targetpath
2699
+ return archive_path
2686
2700
2687
2701
2688
2702
def move_file (path , target_path , force_in_dry_run = False ):
0 commit comments