-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Update builder.py for Secure Package Verification #802
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 |
---|---|---|
|
@@ -14,7 +14,8 @@ | |
target_steps, | ||
) | ||
from . import _global | ||
|
||
import subprocess | ||
import tarfile | ||
|
||
class Builder: | ||
def __init__(self): | ||
|
@@ -32,6 +33,24 @@ def __init__(self): | |
) | ||
self.targetDefs = config.add_targets(option("target"), self._targets) | ||
|
||
def make_dist(self): | ||
build_output_dir = "/path/to/build/output" # Replace with your actual output directory | ||
tarball_path = "/path/to/output/kiwix.tar.gz" # Desired tarball location | ||
# Create the tarball | ||
print(f"Creating tarball at {tarball_path}") | ||
with tarfile.open(tarball_path, "w:gz") as tar: | ||
tar.add(build_output_dir, arcname=os.path.basename(build_output_dir)) | ||
print(f"Tarball created successfully: {tarball_path}") | ||
Comment on lines
+39
to
+43
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 think that this should be delegated to the subclasses of 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 didn't look at the base.py file this being my first draft i was focusing on signing the tarballs that were being released, i'll move on focusing the verification of the tarballs |
||
|
||
# Sign the tarball with GPG | ||
print(f"Signing tarball {tarball_path}") | ||
sig_command = ["gpg", "--detach-sign", tarball_path] | ||
try: | ||
subprocess.run(sig_command, check=True) | ||
print(f"Signature created: {tarball_path}.sig") | ||
except subprocess.CalledProcessError as e: | ||
print(f"Error signing tarball: {e}") | ||
|
||
def finalize_target_steps(self): | ||
steps = [] | ||
for targetDef in self.targetDefs: | ||
|
@@ -116,11 +135,20 @@ def build(self): | |
builder = get_target_step(builderDef) | ||
if option("make_dist") and builderDef[1] == option("target"): | ||
print("make dist {} ({}):".format(builder.name, builderDef[0])) | ||
builder.make_dist() | ||
try: | ||
builder.make_dist() | ||
print("Distribution tarball and signature created successfully.") | ||
except AttributeError: | ||
print(f"ERROR: The target {builder.name} does not implement make_dist().") | ||
except Exception as e: | ||
print(f"ERROR while creating tarball or signature: {e}") | ||
continue | ||
print("build {} ({}):".format(builder.name, builderDef[0])) | ||
print(f"build {builder.name} ({builderDef[0]}):") | ||
add_target_step(builderDef, builder) | ||
builder.build() | ||
try: | ||
builder.build() | ||
except Exception as e: | ||
print(f"ERROR during build of {builder.name}: {e}") | ||
|
||
def _get_packages(self): | ||
packages_list = [] | ||
|
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.
Hardcoded paths shouldn't be present in the final version of a PR
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.
i'll fix that