git: Add systemd_ctypes as submodule

Doing it this way instead of ad-hoc allows us to improve the way we run
the unit-tests container: we can now check out the submodule as part of
the preparation step, eliminating the need for network access inside the
container.
This commit is contained in:
Allison Karlitskaya 2022-11-03 14:02:22 +01:00
parent cd3bb9ee49
commit 1ced362e6f
8 changed files with 38 additions and 13 deletions

View File

@ -10,7 +10,7 @@ jobs:
- { make: 'check-memory', cc: 'gcc', tag: 'latest' }
- { make: 'distcheck', cc: 'clang', tag: 'latest' }
- { make: 'distcheck', cc: 'gcc', tag: 'i386' }
- { make: 'pycheck', cc: 'gcc', tag: 'latest', network: '--network' }
- { make: 'pycheck', cc: 'gcc', tag: 'latest' }
- { make: 'check', cc: 'gcc', tag: 'latest' }
fail-fast: false
timeout-minutes: 60
@ -38,7 +38,7 @@ jobs:
run: |
containers/unit-tests/start \
--verbose \
${{ matrix.startarg.network }} \
--submodule=modules/systemd_ctypes \
--env=CC='${{ matrix.startarg.cc }}' \
--env=CFLAGS='-O2 -gdwarf-4' \
--image-tag='${{ matrix.startarg.tag }}' \

1
.gitignore vendored
View File

@ -75,7 +75,6 @@ Makefile.in
/src/systemd/cockpit*.service
/src/systemd/cockpit*.socket
/src/systemd/cockpit-tempfiles.conf
/src/systemd_ctypes/
/src/tls/cockpit-certificate-helper
/src/ws/cockpit-desktop
/src/ws/cockpit.appdata.xml

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "modules/systemd_ctypes"]
path = modules/systemd_ctypes
url = https://github.com//allisonkarlitskaya/systemd_ctypes.git
[submodule "node_modules"]
path = node_modules
url = https://github.com/cockpit-project/node-cache.git

View File

@ -71,6 +71,8 @@ class SourceDirectory(PodmanTemporaryDirectory):
else:
opts = []
opts.extend(f'--recurse-submodule={name}' for name in args.submodule)
git('clone', *opts, '.', self.name)
if not args.head and not args.branch:
@ -122,6 +124,7 @@ def main():
help='Build the HEAD commit, plus changes on the filesystem (default)')
group = parser.add_argument_group(title='Preparation').add_mutually_exclusive_group()
group.add_argument('--submodule', action='append', help='Check out this submodule')
group.add_argument('--no-node-modules', action='store_true',
help='Disable checking out node_modules/ during preparation')
group.add_argument('--no-jumpstart', action='store_true',

@ -0,0 +1 @@
Subproject commit 1833c33b3846c974f0f8146023479f3d69e7746d

View File

@ -75,22 +75,14 @@ PYTHON_BRIDGE_FILES = \
$(NULL)
SYSTEMD_CTYPES_STAMP = src/systemd_ctypes/__init__.py
SYSTEMD_CTYPES_REPO_URL = https://github.com/allisonkarlitskaya/systemd_ctypes
SYSTEMD_CTYPES_REPO_COMMIT = 1833c33b3846c974f0f8146023479f3d69e7746d
SYSTEMD_CTYPES_REPO_TREE = '$(strip $(SYSTEMD_CTYPES_REPO_COMMIT))^{tree}'
$(SYSTEMD_CTYPES_STAMP):
@git -C '$(srcdir)' rev-list --quiet --objects $(SYSTEMD_CTYPES_REPO_TREE) -- 2>/dev/null || \
git -C '$(srcdir)' fetch --no-tags --no-write-fetch-head --depth=1 $(SYSTEMD_CTYPES_REPO_URL) $(SYSTEMD_CTYPES_REPO_COMMIT)
@rm -rf src/systemd_ctypes
@mkdir -p src
$(AM_V_GEN) git -C '$(srcdir)' archive $(SYSTEMD_CTYPES_REPO_TREE) -- systemd_ctypes | tar --extract -C src
$(srcdir)/tools/systemd_ctypes
CLEANFILES += cockpit-bridge.pyz
cockpit-bridge.pyz: $(MANIFESTS) $(PYTHON_BRIDGE_FILES) $(SYSTEMD_CTYPES_STAMP)
@rm -rf tmp/pyz
@mkdir -p tmp/pyz
@cp -r $(srcdir)/dist $(srcdir)/src/cockpit src/systemd_ctypes/ tmp/pyz
@cp -r $(srcdir)/dist $(srcdir)/src/cockpit $(srcdir)/src/systemd_ctypes/ tmp/pyz
$(AM_V_GEN) python3 -m zipapp --python /usr/bin/python3 --output $@ --main cockpit.bridge:main tmp/pyz
@chmod a+x $@

1
src/systemd_ctypes Symbolic link
View File

@ -0,0 +1 @@
../modules/systemd_ctypes/systemd_ctypes

26
tools/systemd_ctypes Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
GITHUB_BASE='allisonkarlitskaya'
GITHUB_REPO='systemd_ctypes'
SUBDIR='modules/systemd_ctypes'
V="${V-0}" # default to friendly messages
set -eu
cd "${0%/*}/.."
. tools/git-utils.sh
# we default to check out the node_modules corresponding to the gitlink in the index
sha="${1-$(get_index_gitlink "${SUBDIR}")}"
# fetch by sha to prevent us from downloading something we don't want
fetch_sha_to_cache "${sha}"
# we're actually going to do this; let's remove the old one
rm -rf "modules/systemd_ctypes"
git submodule deinit "modules/systemd_ctypes"
rm -rf -- "$(git rev-parse --absolute-git-dir)/modules/systemd_ctypes"
# and check out the new one
# we need to use the tag name here, unfortunately
clone_from_cache "${sha}"