From: saivishnu725@gmail.com
To: mchehab@kernel.org
Cc: corbet@lwn.net, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
saivishnu725 <saivishnu725@gmail.com>
Subject: [PATCH] Add --interactive option to prompt for dependency installation if missing
Date: Thu, 10 Apr 2025 21:24:15 +0530 [thread overview]
Message-ID: <20250410155414.47114-1-saivishnu725@gmail.com> (raw)
From: saivishnu725 <saivishnu725@gmail.com>
Introduce the --interactive flag to enable user prompts before running commands to install missing dependencies.
Asks if the user would like to run the distro appropriate commands if any dependency is not available.
Signed-off-by: saivishnu725 <saivishnu725@gmail.com>
---
scripts/sphinx-pre-install | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install
index ad9945ccb0cf..581d694eb0fd 100755
--- a/scripts/sphinx-pre-install
+++ b/scripts/sphinx-pre-install
@@ -42,6 +42,7 @@ my $latest_avail_ver;
my $pdf = 1;
my $virtualenv = 1;
my $version_check = 0;
+my $interactive = 0;
#
# List of required texlive packages on Fedora and OpenSuse
@@ -338,6 +339,21 @@ sub which($)
return undef;
}
+sub run_if_interactive($)
+{
+ my $command = shift;
+
+ if ($interactive) {
+ printf("Do you want to run the command now [Y/n]: ");
+ my $user_input = <STDIN>;
+ chomp $user_input;
+ if ($user_input =~ /Y|y/) {
+ printf("\$ $command\n");
+ system($command);
+ }
+ }
+}
+
#
# Subroutines that check distro-specific hints
#
@@ -374,7 +390,9 @@ 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";
+ printf("\n\t$command\n");
+ run_if_interactive($command);
}
sub give_redhat_hints()
@@ -1002,12 +1020,15 @@ while (@ARGV) {
$pdf = 0;
} elsif ($arg eq "--version-check"){
$version_check = 1;
+ } elsif ($arg eq "--interactive") {
+ $interactive = 1;
} else {
- print "Usage:\n\t$0 <--no-virtualenv> <--no-pdf> <--version-check>\n\n";
+ print "Usage:\n\t$0 <--no-virtualenv> <--no-pdf> <--version-check> <--interactive>\n\n";
print "Where:\n";
print "\t--no-virtualenv\t- Recommend installing Sphinx instead of using a virtualenv\n";
print "\t--version-check\t- if version is compatible, don't check for missing dependencies\n";
- print "\t--no-pdf\t- don't check for dependencies required to build PDF docs\n\n";
+ print "\t--no-pdf\t- don't check for dependencies required to build PDF docs\n";
+ print "\t--interactive\t- Ask to install missing dependencies\n\n";
exit -1;
}
}
--
This is not the complete patch - I'm sending this to get early feedback before I go further. If this looks good, I plan to follow up with additional patches that will:
1. use the run_if_interactive on the hints for every distro
2. add more quality-to-life features to make the script more useful
Any form of feedback would be helpful! If there is a reason why none of the scripts are interactable, please let me know why.
Sai Vishnu
2.34.1
next reply other threads:[~2025-04-10 16:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 15:54 saivishnu725 [this message]
2025-04-14 15:29 ` [PATCH] Add --interactive option to prompt for dependency installation if missing Jonathan Corbet
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=20250410155414.47114-1-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 \
/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