build: add ./configure --enable-pybridge flag

This disables building and installing the C version of the
cockpit-bridge and cockpit-askpass.

Instead, it runs `pip install .` to install the equivalent Python
versions.
This commit is contained in:
Allison Karlitskaya 2023-04-27 17:14:47 +02:00 committed by Martin Pitt
parent 065927169e
commit e2196d828c
5 changed files with 43 additions and 10 deletions

View File

@ -76,6 +76,12 @@ AC_ARG_ENABLE(ssh, AS_HELP_STRING([--disable-ssh], [Disable cockpit-ssh build an
AM_CONDITIONAL(WITH_COCKPIT_SSH, test "$enable_ssh" != "no")
AC_MSG_RESULT(${enable_ssh:=yes})
# --enable-pybridge
AC_MSG_CHECKING([whether to install the python cockpit-bridge])
AC_ARG_ENABLE(bridge, AS_HELP_STRING([--enable-pybridge], [Install python cockpit-bridge]))
AM_CONDITIONAL(WITH_PYBRIDGE, test "$enable_pybridge" = "yes")
AC_MSG_RESULT(${enable_pybridge:=no})
# pkg-config
GLIB_API_VERSION="GLIB_VERSION_2_56"

View File

@ -43,7 +43,10 @@ EXTRA_DIST += build.js files.js package.json package-lock.json
# This is how the qunit tests get included. We need to prevent automake from
# seeing them during ./autogen.sh, but need make to find them at compile time.
# We don't run them in the pybridge case since they're part of `pytest`.
if !WITH_PYBRIDGE
-include $(wildcard pkg/Makefile.qunit*)
endif
install-data-hook::
cd $(srcdir)/dist; find */* -type f -exec install -D -m 644 '{}' '$(abspath $(DESTDIR)$(datadir))/cockpit/{}' \;

View File

@ -20,6 +20,21 @@ pytest-cov: $(BUILT_SOURCES) $(DIST_STAMP) $(MANIFESTS)
$(MAKE) test-server
cd '$(srcdir)' && abs_builddir='$(abs_builddir)' pytest --cov
if WITH_PYBRIDGE
INSTALL_DATA_LOCAL_TARGETS += install-python
install-python:
@# wheel-based installation with .dist-info.
@# This needs to work on RHEL8 up through modern Fedora, offline, with
@# system packages available to the build.
@rm -rf tmp/pybuild
'$(srcdir)'/tools/dist-setuptools '$(srcdir)' tmp/pybuild
cd tmp/pybuild && python3 -c 'from setuptools import setup; setup()' bdist_wheel
python3 -m pip install --no-index --force-reinstall --root='$(DESTDIR)/' --prefix='$(prefix)' tmp/pybuild/dist/*.whl
mkdir -p $(DESTDIR)$(libexecdir)
mv -t $(DESTDIR)$(libexecdir) $(DESTDIR)$(bindir)/cockpit-askpass
endif
# -----------------------------------------------------------------------------
# C

View File

@ -38,6 +38,8 @@ libcockpit_metrics_a_SOURCES = \
src/bridge/cockpitsamples.h \
$(NULL)
if !WITH_PYBRIDGE
# -----------------------------------------------------------------------------
# libcockpit-bridge.a: code used in cockpit-bridge and its tests
@ -227,6 +229,8 @@ dist_check_DATA += \
src/bridge/mock-server.key \
$(NULL)
endif
# -----------------------------------------------------------------------------
# polkit

View File

@ -117,11 +117,6 @@ test_auth_CPPFLAGS = $(libcockpit_ws_a_CPPFLAGS) $(TEST_CPP)
test_auth_LDADD = $(libcockpit_ws_a_LIBS) $(TEST_LIBS)
test_auth_SOURCES = src/ws/test-auth.c
TEST_PROGRAM += test-channelresponse
test_channelresponse_CPPFLAGS = $(libcockpit_ws_a_CPPFLAGS) $(TEST_CPP)
test_channelresponse_LDADD = $(libcockpit_ws_a_LIBS) $(TEST_LIBS)
test_channelresponse_SOURCES = src/ws/test-channelresponse.c
TEST_PROGRAM += test-compat
test_compat_CPPFLAGS = $(libcockpit_ws_a_CPPFLAGS) $(TEST_CPP)
test_compat_LDADD = $(libcockpit_ws_a_LIBS) $(TEST_LIBS)
@ -132,16 +127,25 @@ test_creds_CPPFLAGS = $(libcockpit_ws_a_CPPFLAGS) $(TEST_CPP)
test_creds_LDADD = $(libcockpit_ws_a_LIBS) $(TEST_LIBS)
test_creds_SOURCES = src/ws/test-creds.c
TEST_PROGRAM += test-handlers
test_handlers_CPPFLAGS = $(libcockpit_ws_a_CPPFLAGS) $(TEST_CPP)
test_handlers_LDADD = $(libcockpit_ws_a_LIBS) $(TEST_LIBS)
test_handlers_SOURCES = src/ws/test-handlers.c
TEST_PROGRAM += test-kerberos
test_kerberos_CPPFLAGS = $(libcockpit_ws_a_CPPFLAGS) $(TEST_CPP)
test_kerberos_LDADD = $(libcockpit_ws_a_LIBS) $(TEST_LIBS) $(krb5_LIBS)
test_kerberos_SOURCES = src/ws/test-kerberos.c
if !WITH_PYBRIDGE
# These are -ws tests but they involve invoking ./cockpit-bridge.
TEST_PROGRAM += test-channelresponse
test_channelresponse_CPPFLAGS = $(libcockpit_ws_a_CPPFLAGS) $(TEST_CPP)
test_channelresponse_LDADD = $(libcockpit_ws_a_LIBS) $(TEST_LIBS)
test_channelresponse_SOURCES = src/ws/test-channelresponse.c
TEST_PROGRAM += test-handlers
test_handlers_CPPFLAGS = $(libcockpit_ws_a_CPPFLAGS) $(TEST_CPP)
test_handlers_LDADD = $(libcockpit_ws_a_LIBS) $(TEST_LIBS)
test_handlers_SOURCES = src/ws/test-handlers.c
TEST_PROGRAM += test-webservice
test_webservice_CPPFLAGS = $(libcockpit_ws_a_CPPFLAGS) $(TEST_CPP)
test_webservice_LDADD = $(libcockpit_ws_a_LIBS) $(TEST_LIBS)
@ -154,6 +158,7 @@ test_authssh_CPPFLAGS = $(libcockpit_ws_a_CPPFLAGS) $(TEST_CPP)
test_authssh_LDADD = $(libcockpit_ws_a_LIBS) $(TEST_LIBS)
test_authssh_SOURCES = src/ws/test-authssh.c
endif
endif
noinst_PROGRAMS += mock-pam-conv-mod.so