Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-KartikSharma authored and kelson42 committed Jan 7, 2025
1 parent baed570 commit d563acb
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions kiwixbuild/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
target_steps,
)
from . import _global

import subprocess
import tarfile

class Builder:
def __init__(self):
Expand All @@ -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}")

# 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:
Expand Down Expand Up @@ -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 = []
Expand Down

0 comments on commit d563acb

Please sign in to comment.