mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
Merge pull request #33198 from keszybz/update-distro-hash
Add helper script to update distro packaging hashes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -o nounset
|
||||
|
||||
rm -f "$OUTPUTDIR"/*.{rpm,deb,pkg.tar}
|
||||
|
||||
@@ -8,7 +8,7 @@ Distribution=|ubuntu
|
||||
Environment=
|
||||
GIT_URL=https://salsa.debian.org/systemd-team/systemd.git
|
||||
GIT_BRANCH=debian/master
|
||||
GIT_COMMIT=1ac6c92c9633fe6fd47f34119c04cae36da14d6a
|
||||
GIT_COMMIT=5b9607385d49c09440e6e3b35c03ceec73162aec
|
||||
|
||||
VolatilePackages=
|
||||
libnss-myhostname
|
||||
|
||||
@@ -7,7 +7,7 @@ Distribution=fedora
|
||||
Environment=
|
||||
GIT_URL=https://src.fedoraproject.org/rpms/systemd.git
|
||||
GIT_BRANCH=rawhide
|
||||
GIT_COMMIT=74810c5bc4fe7d872e54c253447ffd61bbc8839f
|
||||
GIT_COMMIT=1f94b56cee818068f57debfd78f035edd29f0e61
|
||||
|
||||
Packages=
|
||||
btrfs-progs
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -e
|
||||
set -o nounset
|
||||
|
||||
if command -v authselect >/dev/null; then
|
||||
# authselect 1.5.0 renamed the minimal profile to the local profile without keeping backwards compat so
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -e
|
||||
set -o nounset
|
||||
|
||||
if [[ -z "$SANITIZERS" ]]; then
|
||||
if [[ -z "${SANITIZERS:-}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -18,7 +19,7 @@ EOF
|
||||
# ASAN and syscall filters aren't compatible with each other.
|
||||
find /usr /etc -name '*.service' -type f -exec sed -i 's/^\(MemoryDeny\|SystemCall\)/# \1/' {} +
|
||||
|
||||
# `systemd-hwdb update` takes > 50s when built with sanitizers so let's not run it by default.
|
||||
# 'systemd-hwdb update' takes > 50s when built with sanitizers so let's not run it by default.
|
||||
systemctl mask systemd-hwdb-update.service
|
||||
|
||||
ASAN_RT_PATH="$(grep libasan.so < <(ldd /usr/lib/systemd/systemd) | cut -d ' ' -f 3)"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -e
|
||||
set -o nounset
|
||||
|
||||
if ((NO_SYNC)); then
|
||||
if ((${NO_SYNC:-0})); then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
89
tools/update-distro-hash.py
Executable file
89
tools/update-distro-hash.py
Executable file
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
"""
|
||||
Fetch commits for pkg/{distribution} and, if changed, commit the latest hash.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import shlex
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
def parse_args():
|
||||
p = argparse.ArgumentParser(
|
||||
description=__doc__,
|
||||
)
|
||||
p.add_argument(
|
||||
'distribution',
|
||||
nargs='+',
|
||||
)
|
||||
p.add_argument(
|
||||
'--no-fetch',
|
||||
dest='fetch',
|
||||
action='store_false',
|
||||
default=True,
|
||||
)
|
||||
return p.parse_args()
|
||||
|
||||
def read_config(distro: str):
|
||||
cmd = ['mkosi', '--json', '-d', distro, 'summary']
|
||||
print(f"+ {shlex.join(cmd)}")
|
||||
text = subprocess.check_output(cmd, text=True)
|
||||
|
||||
data = json.loads(text)
|
||||
return data['Images'][-1]
|
||||
|
||||
def commit_file(distro: str, file: Path, commit: str, changes: str):
|
||||
message = '\n'.join((
|
||||
f'mkosi: update {distro} commit reference',
|
||||
'',
|
||||
changes))
|
||||
|
||||
cmd = ['git', 'commit', '-m', message, str(file)]
|
||||
print(f"+ {shlex.join(cmd)}")
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
def update_distro(args, distro: str):
|
||||
cmd = ['git', '-C', f'pkg/{distro}', 'fetch']
|
||||
print(f"+ {shlex.join(cmd)}")
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
config = read_config(distro)
|
||||
|
||||
branch = config['Environment']['GIT_BRANCH']
|
||||
old_commit = config['Environment']['GIT_COMMIT']
|
||||
|
||||
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()
|
||||
|
||||
if old_commit == new_commit:
|
||||
print(f'{distro}: commit {new_commit!s} is still fresh')
|
||||
return
|
||||
|
||||
cmd = ['git', '-C', f'pkg/{distro}', 'log', '--graph',
|
||||
'--pretty=oneline', '--no-decorate', '--abbrev-commit', '--abbrev=10',
|
||||
f'{old_commit}..{new_commit}']
|
||||
print(f"+ {shlex.join(cmd)}")
|
||||
changes = subprocess.check_output(cmd, text=True).strip()
|
||||
|
||||
conf_dir = Path('mkosi.images/system/mkosi.conf.d')
|
||||
files = conf_dir.glob('*/*.conf')
|
||||
for file in files:
|
||||
s = file.read_text()
|
||||
if old_commit in s:
|
||||
print(f'{distro}: {file}: found old hash, updating…')
|
||||
new = s.replace(old_commit, new_commit)
|
||||
assert new != s
|
||||
file.write_text(new)
|
||||
commit_file(distro, file, new_commit, changes)
|
||||
break
|
||||
else:
|
||||
raise ValueError(f'{distro}: hash {new_commit} not found under {conf_dir}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = parse_args()
|
||||
for distro in args.distribution:
|
||||
update_distro(args, distro)
|
||||
Reference in New Issue
Block a user