-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to include whole repository #443
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,6 +427,10 @@ def __init__(self, name=None, tag=None, build_dir=None, | |
self.tgz_dir = tgz_base | ||
self.artifacts = [] | ||
|
||
# Details of how to make the tar repo | ||
self.tgz_method = self.config.get('archiver', 'method', fallback='git') | ||
self.tgz_include_git = self.config.getboolean('archiver', 'include_git', fallback=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand the situations when
but I can't imagine a situation when using a tarball from the last commit but also containing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, this was my problems when building Of course these would be discouraged for production releases. |
||
|
||
# A copy of the git code from commit we're building: | ||
self.rpmbuild_gitcopy = os.path.join(self.rpmbuild_sourcedir, | ||
self.tgz_dir) | ||
|
@@ -605,7 +609,8 @@ def _setup_sources(self): | |
self.git_commit_id)) | ||
create_tgz(self.git_root, self.tgz_dir, self.git_commit_id, | ||
self.relative_project_dir, | ||
os.path.join(self.rpmbuild_sourcedir, self.tgz_filename)) | ||
os.path.join(self.rpmbuild_sourcedir, self.tgz_filename), | ||
self.tgz_method, self.tgz_include_git) | ||
|
||
# Extract the source so we can get at the spec file, etc. | ||
debug("Copying git source to: %s" % self.rpmbuild_gitcopy) | ||
|
@@ -746,7 +751,8 @@ def _setup_sources(self): | |
self.git_commit_id)) | ||
create_tgz(self.git_root, self.tgz_dir, self.git_commit_id, | ||
self.relative_project_dir, | ||
os.path.join(self.rpmbuild_sourcedir, self.tgz_filename)) | ||
os.path.join(self.rpmbuild_sourcedir, self.tgz_filename), | ||
self.tgz_method, self.tgz_include_git) | ||
|
||
# Extract the source so we can get at the spec file, etc. | ||
debug("Copying git source to: %s" % self.rpmbuild_gitcopy) | ||
|
@@ -844,7 +850,8 @@ def tgz(self): | |
tgz_fullpath = os.path.join(self.rpmbuild_sourcedir, tgz_filename) | ||
print("Creating %s from git tag: %s..." % (tgz_filename, commit)) | ||
create_tgz(self.git_root, prefix, commit, relative_dir, | ||
tgz_fullpath) | ||
tgz_fullpath, | ||
self.tgz_method, self.tgz_include_git) | ||
self.ran_tgz = True | ||
self.sources.append(tgz_fullpath) | ||
|
||
|
@@ -1077,7 +1084,8 @@ def tgz(self): | |
"No Maven generated tarball found.", | ||
"Please set up the assembly plugin in your pom.xml to generate a .tar.gz"]) | ||
full_path = os.path.join(self.rpmbuild_sourcedir, self.tgz_filename) | ||
create_tgz(self.git_root, self.tgz_dir, self.git_commit_id, self.relative_project_dir, full_path) | ||
create_tgz(self.git_root, self.tgz_dir, self.git_commit_id, self.relative_project_dir, full_path, | ||
self.tgz_method, self.tgz_include_git) | ||
print("Creating %s from git tag: %s..." % (self.tgz_filename, self.build_tag)) | ||
shutil.copy(full_path, destination_file) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -852,25 +852,35 @@ def get_commit_timestamp(sha1_or_tag): | |
|
||
|
||
def create_tgz(git_root, prefix, commit, relative_dir, | ||
dest_tgz): | ||
dest_tgz, method='git', add_git_folder=False): | ||
""" | ||
Create a .tar.gz from a projects source in git. | ||
""" | ||
os.chdir(os.path.abspath(git_root)) | ||
timestamp = get_commit_timestamp(commit) | ||
|
||
# Accomodate standalone projects with specfile i root of git repo: | ||
# Accommodate standalone projects with specfile in root of git repo: | ||
relative_git_dir = "%s" % relative_dir | ||
if relative_git_dir in ['/', './']: | ||
relative_git_dir = "" | ||
if relative_git_dir in ['/', '']: | ||
relative_git_dir = "./" | ||
|
||
basename = os.path.splitext(dest_tgz)[0] | ||
initial_tar = "%s.initial" % basename | ||
|
||
# command to generate a git-archive | ||
git_archive_cmd = 'git archive --format=tar --prefix=%s/ %s:%s --output=%s' % ( | ||
prefix, commit, relative_git_dir, initial_tar) | ||
run_command(git_archive_cmd) | ||
if method == 'git': | ||
git_archive_cmd = 'git archive --format=tar --prefix=%s/ %s:%s --output=%s' % ( | ||
prefix, commit, relative_git_dir, initial_tar) | ||
run_command(git_archive_cmd) | ||
if add_git_folder: | ||
tar_append_cmd = f"tar --append -f {initial_tar} --transform 's|^{relative_git_dir}|{prefix}/|' {relative_git_dir}/.git" | ||
run_command(tar_append_cmd) | ||
elif method == 'tar': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have some issues when using
Traceback:
Reproducible when you run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, that's where I wanted some help because I don't understand what the tarfixer does and why it fails like that. |
||
# Assuming no folder paths contain '|' so we don't need to create escaped versions | ||
git_archive_cmd = f"tar --create -f {initial_tar} --transform 's|^{relative_git_dir}|{prefix}/|' {relative_git_dir}" | ||
run_command(git_archive_cmd) | ||
else: | ||
raise Exception(f"Unknown tar create method passed: {method}") | ||
|
||
# Run git-archive separately if --debug was specified. | ||
# This allows us to detect failure early. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain these options in man
tito.props
?