def tar(path, subdir, into=None, ts=None):
"""Pack ``path`` into tarball ``into``."""
# --sort=name requires a recent build of GNU tar
- args = ['tar', '--numeric-owner', '--owner=0', '--group=0', '--sort=name']
+ args = ['tar', '--numeric-owner', '--owner=0', '--group=0', '--sort=name', '--mode=a-s']
args += ['-C', path, '-cf', into, subdir]
envs = os.environ.copy()
if ts is not None:
class DownloadGitHubTarball(object):
- """Download and repack archive tarabll from GitHub.
+ """Download and repack archive tarball from GitHub.
Compared with the method of packing after cloning the whole repo, this
method is more friendly to users with fragile internet connection.
- GitHub archives do not contain source codes for submodules.
- - GitHub archives seem to respect .gitattributes and ignore pathes with
+ - GitHub archives seem to respect .gitattributes and ignore paths with
export-ignore attributes.
For the first two issues, the method will fail loudly to allow fallback to
self.version = args.version
self.subdir = args.subdir
self.source = args.source
+ self.submodules = args.submodules
self.url = args.url
self._init_owner_repo()
self.xhash = args.hash
def download(self):
"""Download and repack GitHub archive tarball."""
+ if self.submodules and self.submodules != ['skip']:
+ raise self._error('Fetching submodules is not yet supported')
self._init_commit_ts()
with Path(TMPDIR_DL, keep=True) as dir_dl:
# fetch tarball from GitHub
dir0 = os.path.join(dir_untar.path, tarball_prefix)
dir1 = os.path.join(dir_untar.path, self.subdir)
# submodules check
- if self._has_submodule(dir0):
+ if self.submodules != ['skip'] and self._has_submodule(dir0):
raise self._error('Fetching submodules is not yet supported')
# rename subdir
os.rename(dir0, dir1)
parser.add_argument('--version', help='Source code version')
parser.add_argument('--source', help='Source tarball filename')
parser.add_argument('--hash', help='Source tarball\'s expected sha256sum')
+ parser.add_argument('--submodules', nargs='*', help='List of submodules, or "skip"')
args = parser.parse_args()
try:
method = DownloadGitHubTarball(args)