mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
mkosi: Rework how the pkgenv environment variables are set
Instead of including distribution specific files in the subimages, let's have one common mkosi.pkgenv/ directory that handles all the matching which is then included in the subimages. This gives us more control on exactly how we do the matching.
This commit is contained in:
@@ -19,7 +19,7 @@ actions:
|
|||||||
post-upstream-clone:
|
post-upstream-clone:
|
||||||
# Use the Fedora Rawhide specfile
|
# Use the Fedora Rawhide specfile
|
||||||
- git clone https://src.fedoraproject.org/rpms/systemd .packit_rpm
|
- git clone https://src.fedoraproject.org/rpms/systemd .packit_rpm
|
||||||
- bash -c 'git -C .packit_rpm checkout "$(grep GIT_COMMIT= mkosi/mkosi.conf.d/centos-fedora/mkosi.conf.d/pkgenv.conf | cut -d= -f2)"'
|
- bash -c 'git -C .packit_rpm checkout "$(grep GIT_COMMIT= mkosi/mkosi.pkgenv/mkosi.conf.d/centos-fedora.conf | cut -d= -f2)"'
|
||||||
- bash -c 'echo "%bcond upstream 1" > .packit_rpm/systemd.spec.new'
|
- bash -c 'echo "%bcond upstream 1" > .packit_rpm/systemd.spec.new'
|
||||||
- bash -c 'echo "%define meson_extra_configure_options --werror" >> .packit_rpm/systemd.spec.new'
|
- bash -c 'echo "%define meson_extra_configure_options --werror" >> .packit_rpm/systemd.spec.new'
|
||||||
- bash -c 'cat .packit_rpm/systemd.spec >> .packit_rpm/systemd.spec.new'
|
- bash -c 'cat .packit_rpm/systemd.spec >> .packit_rpm/systemd.spec.new'
|
||||||
|
|||||||
@@ -156,3 +156,4 @@ KVM=yes
|
|||||||
[Include]
|
[Include]
|
||||||
Include=%D/mkosi/mkosi.sanitizers
|
Include=%D/mkosi/mkosi.sanitizers
|
||||||
%D/mkosi/mkosi.coverage
|
%D/mkosi/mkosi.coverage
|
||||||
|
%D/mkosi/mkosi.pkgenv
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
|
[Include]
|
||||||
|
Include=%D/mkosi/mkosi.pkgenv
|
||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
Packages=
|
Packages=
|
||||||
clang
|
clang
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
[Match]
|
[Match]
|
||||||
Distribution=arch
|
Distribution=arch
|
||||||
|
|
||||||
[Include]
|
|
||||||
Include=%D/mkosi/mkosi.conf.d/arch/mkosi.conf.d/pkgenv.conf
|
|
||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
Packages=
|
Packages=
|
||||||
base
|
base
|
||||||
|
|||||||
@@ -4,9 +4,6 @@
|
|||||||
Distribution=|centos
|
Distribution=|centos
|
||||||
Distribution=|fedora
|
Distribution=|fedora
|
||||||
|
|
||||||
[Include]
|
|
||||||
Include=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.conf.d/pkgenv.conf
|
|
||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
Packages=
|
Packages=
|
||||||
clang-devel
|
clang-devel
|
||||||
|
|||||||
@@ -4,9 +4,6 @@
|
|||||||
Distribution=|debian
|
Distribution=|debian
|
||||||
Distribution=|ubuntu
|
Distribution=|ubuntu
|
||||||
|
|
||||||
[Include]
|
|
||||||
Include=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.conf.d/pkgenv.conf
|
|
||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
Packages=
|
Packages=
|
||||||
apt
|
apt
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
[Match]
|
[Match]
|
||||||
Distribution=opensuse
|
Distribution=opensuse
|
||||||
|
|
||||||
[Include]
|
|
||||||
Include=%D/mkosi/mkosi.conf.d/opensuse/mkosi.conf.d/pkgenv.conf
|
|
||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
Packages=
|
Packages=
|
||||||
clang
|
clang
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
|
[Match]
|
||||||
|
Distribution=arch
|
||||||
|
|
||||||
[Build]
|
[Build]
|
||||||
Environment=
|
Environment=
|
||||||
GIT_URL=https://gitlab.archlinux.org/archlinux/packaging/packages/systemd.git
|
GIT_URL=https://gitlab.archlinux.org/archlinux/packaging/packages/systemd.git
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
|
[Match]
|
||||||
|
Distribution=|fedora
|
||||||
|
Distribution=|centos
|
||||||
|
|
||||||
[Build]
|
[Build]
|
||||||
Environment=
|
Environment=
|
||||||
GIT_URL=https://src.fedoraproject.org/rpms/systemd.git
|
GIT_URL=https://src.fedoraproject.org/rpms/systemd.git
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
|
[Match]
|
||||||
|
Distribution=|debian
|
||||||
|
Distribution=|ubuntu
|
||||||
|
|
||||||
[Build]
|
[Build]
|
||||||
Environment=
|
Environment=
|
||||||
GIT_URL=https://salsa.debian.org/systemd-team/systemd.git
|
GIT_URL=https://salsa.debian.org/systemd-team/systemd.git
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
|
[Match]
|
||||||
|
Distribution=opensuse
|
||||||
|
|
||||||
[Build]
|
[Build]
|
||||||
Environment=
|
Environment=
|
||||||
GIT_URL=https://github.com/bmwiedemann/openSUSE
|
GIT_URL=https://github.com/bmwiedemann/openSUSE
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
|
[Include]
|
||||||
|
Include=%D/mkosi/mkosi.pkgenv
|
||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
SyncScripts=%D/mkosi/mkosi.sync
|
SyncScripts=%D/mkosi/mkosi.sync
|
||||||
Packages=
|
Packages=
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
[Match]
|
[Match]
|
||||||
Distribution=arch
|
Distribution=arch
|
||||||
|
|
||||||
[Include]
|
|
||||||
Include=%D/mkosi/mkosi.conf.d/arch/mkosi.conf.d/pkgenv.conf
|
|
||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
PrepareScripts=%D/mkosi/mkosi.images/build/mkosi.conf.d/arch/mkosi.prepare
|
PrepareScripts=%D/mkosi/mkosi.images/build/mkosi.conf.d/arch/mkosi.prepare
|
||||||
Packages=
|
Packages=
|
||||||
|
|||||||
@@ -4,9 +4,6 @@
|
|||||||
Distribution=|fedora
|
Distribution=|fedora
|
||||||
Distribution=|centos
|
Distribution=|centos
|
||||||
|
|
||||||
[Include]
|
|
||||||
Include=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.conf.d/pkgenv.conf
|
|
||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
PrepareScripts=%D/mkosi/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.prepare
|
PrepareScripts=%D/mkosi/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.prepare
|
||||||
Packages=
|
Packages=
|
||||||
|
|||||||
@@ -4,9 +4,6 @@
|
|||||||
Distribution=|debian
|
Distribution=|debian
|
||||||
Distribution=|ubuntu
|
Distribution=|ubuntu
|
||||||
|
|
||||||
[Include]
|
|
||||||
Include=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.conf.d/pkgenv.conf
|
|
||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
PrepareScripts=%D/mkosi/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.prepare
|
PrepareScripts=%D/mkosi/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.prepare
|
||||||
Packages=
|
Packages=
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
[Match]
|
[Match]
|
||||||
Distribution=opensuse
|
Distribution=opensuse
|
||||||
|
|
||||||
[Include]
|
|
||||||
Include=%D/mkosi/mkosi.conf.d/opensuse/mkosi.conf.d/pkgenv.conf
|
|
||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
PrepareScripts=%D/mkosi/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.prepare
|
PrepareScripts=%D/mkosi/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.prepare
|
||||||
Packages=
|
Packages=
|
||||||
|
|||||||
@@ -31,10 +31,13 @@ def parse_args():
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
p.add_argument('--profile')
|
||||||
return p.parse_args()
|
return p.parse_args()
|
||||||
|
|
||||||
def read_config(distro: str):
|
def read_config(distro: str):
|
||||||
cmd = ['mkosi', '--json', '-d', distro, 'summary']
|
cmd = ['mkosi', '--json', '-d', distro, 'summary']
|
||||||
|
if args.profile:
|
||||||
|
cmd += ['--profile', args.profile]
|
||||||
print(f"+ {shlex.join(cmd)}")
|
print(f"+ {shlex.join(cmd)}")
|
||||||
text = subprocess.check_output(cmd, text=True)
|
text = subprocess.check_output(cmd, text=True)
|
||||||
|
|
||||||
@@ -53,14 +56,15 @@ def commit_file(distro: str, files: list[Path], commit: str, changes: str):
|
|||||||
subprocess.check_call(cmd)
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
def checkout_distro(args, distro: str, config: dict):
|
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']
|
url = config['Environment']['GIT_URL']
|
||||||
branch = config['Environment']['GIT_BRANCH']
|
branch = config['Environment']['GIT_BRANCH']
|
||||||
subdir = config['Environment'].get('GIT_SUBDIR')
|
subdir = config['Environment'].get('GIT_SUBDIR')
|
||||||
|
pkg_subdir = config['Environment']['PKG_SUBDIR']
|
||||||
|
|
||||||
|
dest = Path(f'pkg/{pkg_subdir}')
|
||||||
|
if dest.exists():
|
||||||
|
print(f'{dest} already exists.')
|
||||||
|
return
|
||||||
|
|
||||||
# Do not checkout the full sources if the package is in a subdirectory,
|
# Do not checkout the full sources if the package is in a subdirectory,
|
||||||
# a sparse checkout will be done after
|
# a sparse checkout will be done after
|
||||||
@@ -81,12 +85,12 @@ def checkout_distro(args, distro: str, config: dict):
|
|||||||
|
|
||||||
# Sparse checkout if the package is in a subdirectory
|
# Sparse checkout if the package is in a subdirectory
|
||||||
if subdir is not None:
|
if subdir is not None:
|
||||||
cmd = ['git', '-C', f'pkg/{distro}', 'sparse-checkout', 'set',
|
cmd = ['git', '-C', f'pkg/{pkg_subdir}', 'sparse-checkout', 'set',
|
||||||
'--no-cone', f'{subdir}']
|
'--no-cone', f'{subdir}']
|
||||||
print(f"+ {shlex.join(cmd)}")
|
print(f"+ {shlex.join(cmd)}")
|
||||||
subprocess.check_call(cmd)
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
cmd = ['git', '-C', f'pkg/{distro}', 'checkout', 'HEAD']
|
cmd = ['git', '-C', f'pkg/{pkg_subdir}', 'checkout', 'HEAD']
|
||||||
print(f"+ {shlex.join(cmd)}")
|
print(f"+ {shlex.join(cmd)}")
|
||||||
subprocess.check_call(cmd)
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
@@ -96,18 +100,19 @@ def update_distro(args, distro: str, config: dict):
|
|||||||
branch = config['Environment']['GIT_BRANCH']
|
branch = config['Environment']['GIT_BRANCH']
|
||||||
subdir = config['Environment'].get('GIT_SUBDIR')
|
subdir = config['Environment'].get('GIT_SUBDIR')
|
||||||
old_commit = config['Environment']['GIT_COMMIT']
|
old_commit = config['Environment']['GIT_COMMIT']
|
||||||
|
pkg_subdir = config['Environment']['PKG_SUBDIR']
|
||||||
|
|
||||||
if args.fetch:
|
if args.fetch:
|
||||||
cmd = ['git', '-C', f'pkg/{distro}', 'fetch', 'origin', '-v',
|
cmd = ['git', '-C', f'pkg/{pkg_subdir}', 'fetch', 'origin', '-v',
|
||||||
f'{branch}:remotes/origin/{branch}']
|
f'{branch}:remotes/origin/{branch}']
|
||||||
print(f"+ {shlex.join(cmd)}")
|
print(f"+ {shlex.join(cmd)}")
|
||||||
subprocess.check_call(cmd)
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
cmd = ['git', '-C', f'pkg/{distro}', 'switch', branch]
|
cmd = ['git', '-C', f'pkg/{pkg_subdir}', 'switch', branch]
|
||||||
print(f"+ {shlex.join(cmd)}")
|
print(f"+ {shlex.join(cmd)}")
|
||||||
subprocess.check_call(cmd)
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
cmd = ['git', '-C', f'pkg/{distro}', 'log', '-n1', '--format=%H',
|
cmd = ['git', '-C', f'pkg/{pkg_subdir}', 'log', '-n1', '--format=%H',
|
||||||
f'refs/remotes/origin/{branch}']
|
f'refs/remotes/origin/{branch}']
|
||||||
if subdir is not None:
|
if subdir is not None:
|
||||||
cmd += [f'{subdir}']
|
cmd += [f'{subdir}']
|
||||||
@@ -115,10 +120,10 @@ def update_distro(args, distro: str, config: dict):
|
|||||||
new_commit = subprocess.check_output(cmd, text=True).strip()
|
new_commit = subprocess.check_output(cmd, text=True).strip()
|
||||||
|
|
||||||
if old_commit == new_commit:
|
if old_commit == new_commit:
|
||||||
print(f'{distro}: commit {new_commit!s} is still fresh')
|
print(f'{pkg_subdir}: commit {new_commit!s} is still fresh')
|
||||||
return
|
return
|
||||||
|
|
||||||
cmd = ['git', '-C', f'pkg/{distro}', 'log', '--graph', '--first-parent',
|
cmd = ['git', '-C', f'pkg/{pkg_subdir}', 'log', '--graph', '--first-parent',
|
||||||
'--pretty=oneline', '--no-decorate', '--abbrev-commit', '--abbrev=10',
|
'--pretty=oneline', '--no-decorate', '--abbrev-commit', '--abbrev=10',
|
||||||
f'{old_commit}..{new_commit}']
|
f'{old_commit}..{new_commit}']
|
||||||
if subdir is not None:
|
if subdir is not None:
|
||||||
@@ -126,8 +131,8 @@ def update_distro(args, distro: str, config: dict):
|
|||||||
print(f"+ {shlex.join(cmd)}")
|
print(f"+ {shlex.join(cmd)}")
|
||||||
changes = subprocess.check_output(cmd, text=True).strip()
|
changes = subprocess.check_output(cmd, text=True).strip()
|
||||||
|
|
||||||
conf_dir = Path('mkosi/mkosi.conf.d')
|
conf_dir = Path('mkosi/mkosi.pkgenv/mkosi.conf.d')
|
||||||
files = conf_dir.glob('**/pkgenv.conf')
|
files = conf_dir.glob('*.conf')
|
||||||
for file in files:
|
for file in files:
|
||||||
s = file.read_text()
|
s = file.read_text()
|
||||||
if old_commit in s:
|
if old_commit in s:
|
||||||
|
|||||||
Reference in New Issue
Block a user