Skip to content

Commit

Permalink
[28] Add repos in file SHA256SUM to lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-sbarra-apexai committed Oct 21, 2024
1 parent e23532a commit c84fe16
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 11 additions & 3 deletions repos/config/detail/generate_ros2_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@
# limitations under the License.

import yaml
import hashlib

def get_sha256sum(file):
sha256_hash = hashlib.sha256()
with open(file, "rb") as f:
for byte_block in iter(lambda: f.read(4096), b""):
sha256_hash.update(byte_block)
return sha256_hash.hexdigest()

def print_setup(repos, output_file, use_tar = False):
def print_setup(repos, output_file, repos_file, use_tar = False):
BZL_CMD = "bazel run @rules_ros//repos/config:repos_lock.update"
if use_tar:
BZL_CMD += " -- --tar"
Expand All @@ -24,6 +31,7 @@ def print_setup(repos, output_file, use_tar = False):
#
# To update, call `{BZL_CMD}` with the right distro set in the WORKSPACE
#
# SHA OF {repos_file}: {get_sha256sum(repos_file)}
load("@bazel_tools//tools/build_defs/repo:utils.bzl", _maybe = "maybe")
load("@rules_ros//repos/config/detail:git_repository.bzl", "git_repository")
Expand Down Expand Up @@ -111,9 +119,9 @@ def merge_dict(origin, to_add):
origin[key]=value


def print_setup_file(repos, yaml_files, output_file, use_tar = False):
def print_setup_file(repos, yaml_files, output_file, repos_file, use_tar = False):
for input_path in yaml_files:
with (open(input_path,"r")) as repo_file:
merge_dict(repos, yaml.safe_load(repo_file)["repositories"])

print_setup(repos, output_file, use_tar)
print_setup(repos, output_file, repos_file, use_tar)
6 changes: 5 additions & 1 deletion repos/config/detail/lock_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ def main():
print("{}: {}".format(repo, [*additional_attributes.values()]))

with open(args.setup_bzl, mode='w', encoding='utf8') as setup_bzl:
print_setup_file(repos = repos["repositories"], yaml_files=args.overlays, output_file=setup_bzl, use_tar=args.tar)
print_setup_file(repos = repos["repositories"],
yaml_files=args.overlays,
output_file=setup_bzl,
repos_file = args.repos,
use_tar=args.tar)


def fetch_dependency_details(*, use_tar, type, **kwargs):
Expand Down

0 comments on commit c84fe16

Please sign in to comment.