From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F36317D2 for ; Sat, 30 Mar 2024 02:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711765544; cv=none; b=lGnBajkca3qd8cfvNx2KKqIc9i8Gk2q6OhzjT5U2ZEXWVl/NLOa/j+3HTx+932IAIzrfUEC18QWTH/cq5RJOVi0IaTYx7bYPfBqHapd7OeEshx19HhntAVbv88/Q8/NBPxShUMjVL5vYisTP1UkO11MVyc1VpBVtIJHvtJYiXaU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711765544; c=relaxed/simple; bh=mzL8vSUqx1zajzdPcEuJWtN0HSl5cjMOs87wdq1zMDU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o6blq8vKUTbjKTOsuiWXWfsJY8j9g43W6H4679q08GhweF2Vpr19oQLCaLv80g6RdXb/BHEboQvGo/GvuodTGLuQet3K6buzymYrtfrA8FLuhEdznL3N6bX5zj0b3Iwy3APbgVxaWxXKOgc9zQmaw/p6Vs+MOt1i9Jyq4cR9ngA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=2xnxtkqx; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="2xnxtkqx" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=STSdRAY7jhxwvO/P8gdCeQWfAVF6lt/3wwekLJZFdeI=; b=2xnxtkqxsdOqAdYDASvcDwF8Ea NNTxxpC5knB9EPhmDbVQ+1Km6Jsc1rWTUgNVlY23eL/0bTEKhNEYkaOSgNhvt8sW9YekT2Ix6gdmU 1pqIPQX7l52FJl+IULk/9QudsIA2tIUoQaos+CNeWv/3/XxZHwDYjI34K6zUANadWFL5tKnoj6FsR SBh6/JjHTjZRW/gmFXwdgs03JD+UB5pUIs6RBjnNgkaP7rtwgqhl1TJgplpMCcaE81oIGq/PaUsDx m0jbKf9r0HZq9E1amEvQbiOT2ctox1HyG6EbfFsfrJtalqM/nI3+tuGDs4Fzzv0vXK3gJb69s8+Ro AjpU4DFA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rqOPd-00000002ZL7-3Ei2; Sat, 30 Mar 2024 02:25:41 +0000 From: Luis Chamberlain To: kdevops@lists.linux.dev Cc: Luis Chamberlain Subject: [PATCH 03/18] provision: generalize bridge-ip further Date: Fri, 29 Mar 2024 19:25:25 -0700 Message-ID: <20240330022540.612487-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240330022540.612487-1-mcgrof@kernel.org> References: <20240330022540.612487-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain We only provide the bridge IP on Kconfig if we're using vagrant or guestfs, and we wrap some kconfig logic around this. We want to expand on this and use the default bridge IP for mirroring as well, so that we don't phone home to the internet when we have a git tree for local trees. Today we only use git trees for the large trees for the Linux kernel and qemu but we want to expand on that, and add all of the mirrors a node fetches to a locall mirror. To enable more wide spread use of the bridge IP we need to just make it available on Makefiles, so we can take advantage of the fact that although kconfig does not let us append variables for example we can't use "default $(foo)/$(bar)" we *can* as the shell to append scripts for us, we just need to promote the variables we need to shell. We provide a simple scripts/append-makefile-vars.sh to make emphasis that you need these variables on Makefiles so you can use them on Kconfig. With the bridge IP for all worlds defined we can now grow its use later for allowing us to extend how we use bridging using the git protocol on the local network. We'll address this next. This makes no functional changes, it just let's us later use the bridge IP variables on shell Kconfig magic. Signed-off-by: Luis Chamberlain --- kconfigs/Kconfig.ansible_provisioning | 4 ++-- kconfigs/Kconfig.guestfs | 6 ------ scripts/append-makefile-vars.sh | 10 ++++++++++ scripts/get-distro-default-bridge.sh | 15 +++++++++++++++ scripts/get-distro-prefix.sh | 18 ++++++++++++++++++ scripts/provision.Makefile | 12 ++++++++++++ 6 files changed, 57 insertions(+), 8 deletions(-) create mode 100755 scripts/append-makefile-vars.sh create mode 100755 scripts/get-distro-default-bridge.sh create mode 100755 scripts/get-distro-prefix.sh diff --git a/kconfigs/Kconfig.ansible_provisioning b/kconfigs/Kconfig.ansible_provisioning index e56f869c16cd..82a6f822c3f5 100644 --- a/kconfigs/Kconfig.ansible_provisioning +++ b/kconfigs/Kconfig.ansible_provisioning @@ -194,8 +194,8 @@ config DEVCONFIG_SYSTEMD_JOURNAL_USE_HTTP config DEVCONFIG_SYSTEMD_JOURNAL_REMOTE_URL string "systemd-remote URL" - default "http://192.168.124.1" if VAGRANT - default GUESTFS_DEFAULT_BRIDGE_IP if GUESTFS + default $(shell, scripts/append-makefile-vars.sh http:// $(KDEVOPS_DEFAULT_BRIDGE_IP_VAGRANT)) if VAGRANT + default $(shell, scripts/append-makefile-vars.sh http:// $(KDEVOPS_DEFAULT_BRIDGE_IP_GUESTFS)) if GUESTFS help This is used for the client /etc/systemd/journal-upload.conf URL line. By default we won't use SSL for now. If you should make sure the diff --git a/kconfigs/Kconfig.guestfs b/kconfigs/Kconfig.guestfs index 377f3434a892..03e0fb865a66 100644 --- a/kconfigs/Kconfig.guestfs +++ b/kconfigs/Kconfig.guestfs @@ -1,11 +1,5 @@ if GUESTFS -config GUESTFS_DEFAULT_BRIDGE_IP - string - default "http://192.168.122.1" if DISTRO_FEDORA || DISTRO_REDHAT - default "http://192.168.122.1" if DISTRO_OPENSUSE || DISTRO_SUSE - default "http://192.168.122.1" if DISTRO_DEBIAN || DISTRO_UBUNTU - choice prompt "Guestfs Linux distribution to use" default GUESTFS_FEDORA if DISTRO_FEDORA || DISTRO_REDHAT diff --git a/scripts/append-makefile-vars.sh b/scripts/append-makefile-vars.sh new file mode 100755 index 000000000000..2148399ae31f --- /dev/null +++ b/scripts/append-makefile-vars.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +STR="" + +while [[ ${#1} -gt 0 ]]; do + STR="${STR}${1}" + shift +done + +echo $STR diff --git a/scripts/get-distro-default-bridge.sh b/scripts/get-distro-default-bridge.sh new file mode 100755 index 000000000000..09d09ff04ee1 --- /dev/null +++ b/scripts/get-distro-default-bridge.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +DISTRO=$1 +VIRT_TYPE=$2 + +# We currently ignore the distro because as far as we're concerned +# they all use the default IP, the only thing that differiantes it +# is if you are using vagrant or guestfs. If your distribution needs +# a different deafult it should be easy for you to extend it here. + +if [[ "$VIRT_TYPE" == "vagrant" ]]; then + echo "http://192.168.124.1" +else + echo "192.168.122.1" +fi diff --git a/scripts/get-distro-prefix.sh b/scripts/get-distro-prefix.sh new file mode 100755 index 000000000000..519be5a5a97c --- /dev/null +++ b/scripts/get-distro-prefix.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +DEFAULT_DISTRO="debian" +DISTROS="debian" +DISTROS="$DISTROS fedora" +DISTROS="$DISTROS opensuse" +DISTROS="$DISTROS redhat" +DISTROS="$DISTROS suse" +DISTROS="$DISTROS ubuntu" + +for i in $DISTROS; do + if [[ "./scripts/os-release-check.sh $i" == "y" ]]; then + echo $i + exit + fi +done + +echo $DEFAULT_DISTRO diff --git a/scripts/provision.Makefile b/scripts/provision.Makefile index 7bd4115bdb7a..26657c0974f2 100644 --- a/scripts/provision.Makefile +++ b/scripts/provision.Makefile @@ -31,6 +31,18 @@ KDEVOPS_PROVISIONED_DEVCONFIG := .provisioned_once_devconfig KDEVOPS_BRING_UP_DEPS := KDEVOPS_DESTROY_DEPS := +# This is currently used when vitualization is enabled so to allow us to +# allow guests to use the bridge ip for mirroring git trees but the general idea +# could be extended to support cloud later. For example perhaps this could be +# a third guest which we can instantiate later. This would be useful for things +# like systemd-remote as well. +# +# We export this into Makefiles so that we can use them both on Makefiles and +# on Kconfig files with environment variables such as $(FOO) +export KDEVOPS_DEFAULT_DISTRO := $(shell $(TOPDIR)/scripts/get-distro-prefix.sh) +export KDEVOPS_DEFAULT_BRIDGE_IP_VAGRANT := $(shell $(TOPDIR)/scripts/get-distro-default-bridge.sh $(KDEVOPS_DEFAULT_DISTRO) vagrant) +export KDEVOPS_DEFAULT_BRIDGE_IP_GUESTFS := $(shell $(TOPDIR)/scripts/get-distro-default-bridge.sh $(KDEVOPS_DEFAULT_DISTRO) guestfs) + # These go last KDEVOPS_BRING_UP_LATE_DEPS := -- 2.43.0