|
12 | 12 | import os |
13 | 13 | import argparse |
14 | 14 | import logging |
| 15 | +import shutil |
15 | 16 | from hashlib import sha256 |
16 | 17 |
|
17 | 18 | import boto3 |
@@ -100,13 +101,38 @@ def create_distribution_conf(self, |
100 | 101 | """ |
101 | 102 | def create_deb_pkgs(self, release, deb_file): |
102 | 103 | self._clean_build_resources() |
103 | | - subprocess.call(("reprepro", "includedeb", release, deb_file)) |
| 104 | + subprocess.call(("reprepro", "includedeb", release, deb_file), timeout=120) |
104 | 105 |
|
105 | 106 | """ |
106 | 107 | This is mostly useful to clear previously built db, dist and pool resources. |
107 | 108 | """ |
108 | 109 | def _clean_build_resources(self): |
109 | | - subprocess.call(("reprepro", "clearvanished")) |
| 110 | + subprocess.call(("reprepro", "clearvanished"), timeout=120) |
| 111 | + |
| 112 | + # TODO https://jira.cfops.it/browse/TUN-6209 : Sign these packages. |
| 113 | + def create_rpm_pkgs(self, artifacts_path): |
| 114 | + self._setup_rpm_pkg_directories(artifacts_path) |
| 115 | + subprocess.call(("createrepo", "./rpm"), timeout=120) |
| 116 | + |
| 117 | + """ |
| 118 | + sets up the RPM directories in the following format: |
| 119 | + - rpm |
| 120 | + - aarch64 |
| 121 | + - x86_64 |
| 122 | + - 386 |
| 123 | +
|
| 124 | + this assumes the assets are in the format <prefix>-<aarch64/x86_64/386>.rpm |
| 125 | + """ |
| 126 | + def _setup_rpm_pkg_directories(self, artifacts_path, archs=["aarch64", "x86_64", "386"]): |
| 127 | + for arch in archs: |
| 128 | + for root, _ , files in os.walk(artifacts_path): |
| 129 | + for file in files: |
| 130 | + if file.endswith(f"{arch}.rpm"): |
| 131 | + new_dir = f"./rpm/{arch}" |
| 132 | + os.makedirs(new_dir, exist_ok=True) |
| 133 | + old_path = os.path.join(root, file) |
| 134 | + new_path = os.path.join(new_dir, file) |
| 135 | + shutil.copyfile(old_path, new_path) |
110 | 136 |
|
111 | 137 | """ |
112 | 138 | Walks through a directory and uploads it's assets to R2. |
@@ -167,6 +193,17 @@ def create_deb_packaging(pkg_creator, pkg_uploader, releases, gpg_key_id, binary |
167 | 193 | upload_from_directories(pkg_uploader, "dists", release_version, binary_name) |
168 | 194 | upload_from_directories(pkg_uploader, "pool", release_version, binary_name) |
169 | 195 |
|
| 196 | +def create_rpm_packaging(pkg_creator, pkg_uploader, artifacts_path, release_version, binary_name): |
| 197 | + print(f"creating rpm pkgs...") |
| 198 | + pkg_creator.create_rpm_pkgs(artifacts_path) |
| 199 | + |
| 200 | + print("uploading latest to r2...") |
| 201 | + upload_from_directories(pkg_uploader, "rpm", None, binary_name) |
| 202 | + |
| 203 | + print(f"uploading versioned release {release_version} to r2...") |
| 204 | + upload_from_directories(pkg_uploader, "rpm", release_version, binary_name) |
| 205 | + |
| 206 | + |
170 | 207 | def parse_args(): |
171 | 208 | parser = argparse.ArgumentParser( |
172 | 209 | description="Creates linux releases and uploads them in a packaged format" |
@@ -223,3 +260,5 @@ def parse_args(): |
223 | 260 | pkg_uploader = PkgUploader(args.account, args.bucket, args.id, args.secret) |
224 | 261 | create_deb_packaging(pkg_creator, pkg_uploader, args.deb_based_releases, args.gpg_key_id, args.binary, |
225 | 262 | args.archs, "main", args.release_tag) |
| 263 | + |
| 264 | + create_rpm_packaging(pkg_creator, pkg_uploader, "./built_artifacts", args.release_tag, args.binary ) |
0 commit comments