public inbox for kdevops@lists.linux.dev
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: kdevops@lists.linux.dev
Cc: Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH 03/18] provision: generalize bridge-ip further
Date: Fri, 29 Mar 2024 19:25:25 -0700	[thread overview]
Message-ID: <20240330022540.612487-4-mcgrof@kernel.org> (raw)
In-Reply-To: <20240330022540.612487-1-mcgrof@kernel.org>

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 <mcgrof@kernel.org>
---
 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


  parent reply	other threads:[~2024-03-30  2:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-30  2:25 [PATCH 00/18] mirrors: enhance and add tons of mirrors Luis Chamberlain
2024-03-30  2:25 ` [PATCH 01/18] linux-mirror: add kdevops mirroring support Luis Chamberlain
2024-03-30  2:25 ` [PATCH 02/18] Makefile.min_deps: add netcat as a min binary dependency Luis Chamberlain
2024-03-30  2:25 ` Luis Chamberlain [this message]
2024-03-30  2:25 ` [PATCH 04/18] mirrors: add guestfs mirror options without 9p Luis Chamberlain
2024-03-30  2:25 ` [PATCH 05/18] mirrors: enable kdevops mirror Luis Chamberlain
2024-03-30  2:25 ` [PATCH 06/18] mirrors: add fstests to mirrors Luis Chamberlain
2024-03-30  2:25 ` [PATCH 07/18] fstests: use local primary fstests mirror if present Luis Chamberlain
2024-03-30  2:25 ` [PATCH 08/18] mirrors: add kdevops git alternative for fstests Luis Chamberlain
2024-03-30  2:25 ` [PATCH 09/18] mirrors: use kdevops fstests mirror when available Luis Chamberlain
2024-03-30  2:25 ` [PATCH 10/18] mirrors: add blktests mirror Luis Chamberlain
2024-03-30  2:25 ` [PATCH 11/18] mirrors: use blktests mirror when its available Luis Chamberlain
2024-03-30  2:25 ` [PATCH 12/18] mirrors: increase scope of mirroring in output Luis Chamberlain
2024-03-30  2:25 ` [PATCH 13/18] mirrors: move status check Luis Chamberlain
2024-03-30  2:25 ` [PATCH 14/18] mirrors: move mirror editing into one file Luis Chamberlain
2024-03-30  2:25 ` [PATCH 15/18] mirrors: add new mirrors.yaml and add xfsprogs Luis Chamberlain
2024-03-30  2:25 ` [PATCH 16/18] mirrors: add xfsdump mirror and use it Luis Chamberlain
2024-03-30  2:25 ` [PATCH 17/18] mirrors: add dbench git Luis Chamberlain
2024-03-30  2:25 ` [PATCH 18/18] mirrors: add blktrace mirror and use it Luis Chamberlain
2024-03-30 16:37 ` [PATCH 00/18] mirrors: enhance and add tons of mirrors Chuck Lever III
2024-04-03  1:01   ` Luis Chamberlain
2024-04-03 18:04     ` Chuck Lever III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240330022540.612487-4-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=kdevops@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox