diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-16 18:20:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-16 18:20:20 +0000 |
commit | 8612d3d858fa108e5732a586d4e2d0227ae34422 (patch) | |
tree | 33e7f8b3d5caa6c44b4d6759cb25d3eff4b2d975 /tools | |
parent | Adding debian version 256.2-1. (diff) | |
download | systemd-8612d3d858fa108e5732a586d4e2d0227ae34422.tar.xz systemd-8612d3d858fa108e5732a586d4e2d0227ae34422.zip |
Merging upstream version 256.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/fetch-distro.py (renamed from tools/update-distro-hash.py) | 51 | ||||
-rwxr-xr-x | tools/vcs-tag.sh | 17 |
2 files changed, 61 insertions, 7 deletions
diff --git a/tools/update-distro-hash.py b/tools/fetch-distro.py index 16ed2e7..9fc5b1b 100755 --- a/tools/update-distro-hash.py +++ b/tools/fetch-distro.py @@ -2,7 +2,8 @@ # SPDX-License-Identifier: LGPL-2.1-or-later """ -Fetch commits for pkg/{distribution} and, if changed, commit the latest hash. +Check out pkg/{distribution}. +With -u, fetch commits, and if changed, commit the latest hash. """ import argparse @@ -25,6 +26,11 @@ def parse_args(): action='store_false', default=True, ) + p.add_argument( + '--update', '-u', + action='store_true', + default=False, + ) return p.parse_args() def read_config(distro: str): @@ -33,7 +39,8 @@ def read_config(distro: str): text = subprocess.check_output(cmd, text=True) data = json.loads(text) - return data['Images'][-1] + images = {image["Image"]: image for image in data["Images"]} + return images["build"] def commit_file(distro: str, file: Path, commit: str, changes: str): message = '\n'.join(( @@ -45,16 +52,42 @@ def commit_file(distro: str, file: Path, commit: str, changes: str): print(f"+ {shlex.join(cmd)}") subprocess.check_call(cmd) -def update_distro(args, distro: str): - cmd = ['git', '-C', f'pkg/{distro}', 'fetch'] +def checkout_distro(args, distro: str, config: dict): + dest = Path(f'pkg/{distro}') + if dest.exists(): + print(f'{dest} already exists.') + return + + url = config['Environment']['GIT_URL'] + branch = config['Environment']['GIT_BRANCH'] + + # Only debian uses source-git for now… + reference = [f'--reference-if-able=.'] if distro == 'debian' else [] + + cmd = [ + 'git', 'clone', url, + f'--branch={branch}', + dest.as_posix(), + *reference, + ] print(f"+ {shlex.join(cmd)}") subprocess.check_call(cmd) - config = read_config(distro) + args.fetch = False # no need to fetch if we just cloned +def update_distro(args, distro: str, config: dict): branch = config['Environment']['GIT_BRANCH'] old_commit = config['Environment']['GIT_COMMIT'] + cmd = ['git', '-C', f'pkg/{distro}', 'switch', branch] + print(f"+ {shlex.join(cmd)}") + subprocess.check_call(cmd) + + cmd = ['git', '-C', f'pkg/{distro}', 'fetch', 'origin', '-v', + f'{branch}:remotes/origin/{branch}'] + print(f"+ {shlex.join(cmd)}") + subprocess.check_call(cmd) + cmd = ['git', '-C', f'pkg/{distro}', 'rev-parse', f'refs/remotes/origin/{branch}'] print(f"+ {shlex.join(cmd)}") new_commit = subprocess.check_output(cmd, text=True).strip() @@ -69,7 +102,7 @@ def update_distro(args, distro: str): print(f"+ {shlex.join(cmd)}") changes = subprocess.check_output(cmd, text=True).strip() - conf_dir = Path('mkosi.images/system/mkosi.conf.d') + conf_dir = Path('mkosi.images/build/mkosi.conf.d') files = conf_dir.glob('*/*.conf') for file in files: s = file.read_text() @@ -85,5 +118,9 @@ def update_distro(args, distro: str): if __name__ == '__main__': args = parse_args() + for distro in args.distribution: - update_distro(args, distro) + config = read_config(distro) + checkout_distro(args, distro, config) + if args.update: + update_distro(args, distro, config) diff --git a/tools/vcs-tag.sh b/tools/vcs-tag.sh new file mode 100755 index 0000000..5da39cc --- /dev/null +++ b/tools/vcs-tag.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -e + +MODE="$1" + +if ! [[ -d .git ]] || git describe --tags --exact-match &>/dev/null; then + exit 0 +fi + +if [[ "$MODE" == "developer" ]]; then + DIRTY="--dirty=^" +else + DIRTY="" +fi + +echo "-g$(git describe --abbrev=7 --match="" --always $DIRTY)" |