linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sai Vishnu M <saivishnu725@gmail.com>
To: corbet@lwn.net, mchehab@kernel.org
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	shuah@kernel.org, Sai Vishnu M <saivishnu725@gmail.com>
Subject: [PATCH 4/4] scripts: sphinx-pre-install: Integrate interactive mode
Date: Wed, 25 Jun 2025 21:52:37 +0530	[thread overview]
Message-ID: <20250625162237.3996-4-saivishnu725@gmail.com> (raw)
In-Reply-To: <20250625162237.3996-1-saivishnu725@gmail.com>

From: Sai Vishnu M <saivishnu725@gmail.com>

Replace direct printf calls with run_if_interactive for installation
commands across all distro-specific hint subroutines, enabling user
prompts in interactive mode.

Signed-off-by: Sai Vishnu M <saivishnu725@gmail.com>
---
Patch series history:
1 -> implement the --interactive flag
2 -> add run_if_interactive subroutine
3 -> add fallback to unrecognized distributions

Testing:
========

Tested: Debian, Ubuntu, Fedora, openSUSE Tumbleweed, Mageia.
Skipped: Gentoo (setup complexity but similarity in modification to others)
Steps taken:
1. Podman to download the containers:
	podman pull docker.io/debian:bookworm
	podman pull docker.io/ubuntu:24.04
	podman pull docker.io/fedora:40
	podman pull docker.io/opensuse/tumbleweed:latest
	podman pull docker.io/mageia:9
	podman pull docker.io/gentoo/stage3:latest

2. Copy the script and related files to a temporary folder
	mkdir -p /tmp/sphinx-test/Documentation/
	cp ./scripts/sphinx-pre-install /tmp/sphinx-test
	cp ./Documentation/conf.py /tmp/sphinx-test/Documentation
	cd /tmp/sphinx-test

3. Connect to the containers
	podman run -it --rm -v $(pwd):/work:z CONTAINER:VERSION bash
	Ex: podman run -it --rm -v $(pwd):/work:z debian:bookworm bash
	
4. Install perl and dependencies
	# Debian/Ubuntu
	apt-get update && apt-get install -y perl sudo
	# Fedora
	dnf install -y perl sudo
	# OpenSUSE
	zypper install -y perl sudo
	# Mageia
	dnf install -y perl sudo
	# Gentoo (requires more setup)
	emerge-webrsync && emerge dev-lang/perl

5. Run the script
	a. Interactive
		cd /work; perl sphinx-pre-install --interactive
	b. Non Interactive
		cd /work; perl sphinx-pre-install

 scripts/sphinx-pre-install | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install
index 87eef15650f2..c2e10170e6c1 100755
--- a/scripts/sphinx-pre-install
+++ b/scripts/sphinx-pre-install
@@ -436,7 +436,8 @@ sub give_debian_hints()
 
 	return if (!$need && !$optional);
 	printf("You should run:\n") if ($verbose_warn_install);
-	printf("\n\tsudo apt-get install $install\n");
+	my $command = "sudo apt-get install $install";
+	run_if_interactive($command);
 }
 
 sub give_redhat_hints()
@@ -514,11 +515,13 @@ sub give_redhat_hints()
 	if (!$old) {
 		# dnf, for Fedora 18+
 		printf("You should run:\n") if ($verbose_warn_install);
-		printf("\n\tsudo dnf install -y $install\n");
+		my $command = "sudo dnf install -y $install";
+		run_if_interactive($command);
 	} else {
 		# yum, for RHEL (and clones) or Fedora version < 18
 		printf("You should run:\n") if ($verbose_warn_install);
-		printf("\n\tsudo yum install -y $install\n");
+		my $command = "sudo yum install -y $install";
+		run_if_interactive($command);
 	}
 }
 
@@ -567,7 +570,8 @@ sub give_opensuse_hints()
 
 	return if (!$need && !$optional);
 	printf("You should run:\n") if ($verbose_warn_install);
-	printf("\n\tsudo zypper install --no-recommends $install\n");
+	my $command = "sudo zypper install --no-recommends $install";
+	run_if_interactive($command);
 }
 
 sub give_mageia_hints()
@@ -612,7 +616,8 @@ sub give_mageia_hints()
 
 	return if (!$need && !$optional);
 	printf("You should run:\n") if ($verbose_warn_install);
-	printf("\n\tsudo $packager_cmd $install\n");
+	my $command = "sudo $packager_cmd $install";
+	run_if_interactive($command);
 }
 
 sub give_arch_linux_hints()
@@ -643,7 +648,8 @@ sub give_arch_linux_hints()
 
 	return if (!$need && !$optional);
 	printf("You should run:\n") if ($verbose_warn_install);
-	printf("\n\tsudo pacman -S $install\n");
+	my $command = "sudo pacman -S $install";
+	run_if_interactive($command);
 }
 
 sub give_gentoo_hints()
@@ -679,13 +685,16 @@ sub give_gentoo_hints()
 	my $portage_cairo = "/etc/portage/package.use/graphviz";
 
 	if (qx(grep imagemagick $portage_imagemagick 2>/dev/null) eq "") {
-		printf("\tsudo su -c 'echo \"$imagemagick\" > $portage_imagemagick'\n")
+		my $imagemagick_command = "sudo su -c 'echo \"$imagemagick\" > $portage_imagemagick'";
+		run_if_interactive($imagemagick_command);
 	}
 	if (qx(grep graphviz $portage_cairo 2>/dev/null) eq  "") {
-		printf("\tsudo su -c 'echo \"$cairo\" > $portage_cairo'\n");
+		my $portage_command = "sudo su -c 'echo \"$cairo\" > $portage_cairo'";
+		run_if_interactive($portage_command);
 	}
 
-	printf("\tsudo emerge --ask $install\n");
+	my $command = "sudo emerge --ask $install";
+	run_if_interactive($command);
 
 }
 
-- 
2.49.0


  parent reply	other threads:[~2025-06-25 16:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 16:22 [PATCH 1/4] scripts: sphinx-pre-install: Add --interactive flag Sai Vishnu M
2025-06-25 16:22 ` [PATCH 2/4] scripts: sphinx-pre-install: add a helper subroutine Sai Vishnu M
2025-06-25 16:22 ` [PATCH 3/4] scripts: sphinx-pre-install: add fallback to distro detection Sai Vishnu M
2025-06-25 16:22 ` Sai Vishnu M [this message]
2025-06-25 20:32 ` [PATCH 1/4] scripts: sphinx-pre-install: Add --interactive flag Mauro Carvalho Chehab

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=20250625162237.3996-4-saivishnu725@gmail.com \
    --to=saivishnu725@gmail.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=shuah@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).