* [pve-devel] [PATCH pve-common 0/3] remove dependency on Term::ReadLine
@ 2022-05-09 7:30 Stefan Hrdlicka
2022-05-09 7:30 ` [pve-devel] [PATCH pve-common 1/3] remove dependency on Term::ReadLine (see #2077) Stefan Hrdlicka
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stefan Hrdlicka @ 2022-05-09 7:30 UTC (permalink / raw)
To: pve-devel
This removes the dependency to libterm-readline-gnu-perl for pve-common,
pve-manager and qemu-server. This is achived by adding a read function
to PVE::PTY.
# pve-common
Stefan Hrdlicka (1):
remove dependency on Term::ReadLine (see #2077)
README.dev | 2 +-
src/PVE/PTY.pm | 21 ++++++++++++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)
# pve-manager
Stefan Hrdlicka (1):
remove dependency on Term::ReadLine (see #2077)
PVE/CLI/pvenode.pm | 12 ++++--------
debian/control | 1 -
2 files changed, 4 insertions(+), 9 deletions(-)
# qemu-server
Stefan Hrdlicka (1):
remove dependency on Term::ReadLine (see #2077)
PVE/CLI/qm.pm | 4 ++--
debian/control | 1 -
2 files changed, 2 insertions(+), 3 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH pve-common 1/3] remove dependency on Term::ReadLine (see #2077)
2022-05-09 7:30 [pve-devel] [PATCH pve-common 0/3] remove dependency on Term::ReadLine Stefan Hrdlicka
@ 2022-05-09 7:30 ` Stefan Hrdlicka
2022-05-09 7:30 ` [pve-devel] [PATCH pve-manager 2/3] " Stefan Hrdlicka
2022-05-09 7:30 ` [pve-devel] [PATCH qemu-server 3/3] " Stefan Hrdlicka
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hrdlicka @ 2022-05-09 7:30 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
---
README.dev | 2 +-
src/PVE/PTY.pm | 21 ++++++++++++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/README.dev b/README.dev
index cb6bcf8..af17116 100644
--- a/README.dev
+++ b/README.dev
@@ -62,7 +62,7 @@ libstring-shellquote-perl dh-systemd rpm2cpio libsqlite3-dev sqlite3 \
libglib2.0-dev librrd-dev librrds-perl rrdcached libdigest-hmac-perl \
libxml-parser-perl gdb libcrypt-openssl-random-perl \
libcrypt-openssl-rsa-perl libnet-ldap-perl libauthen-pam-perl \
-libjson-xs-perl libterm-readline-gnu-perl oathtool libmime-base32-perl \
+libjson-xs-perl oathtool libmime-base32-perl \
liboath0 libpci-dev texi2html libsdl1.2-dev libgnutls28-dev \
libspice-protocol-dev xfslibs-dev libnuma-dev libaio-dev \
pve-libspice-server-dev libusbredirparser-dev glusterfs-common \
diff --git a/src/PVE/PTY.pm b/src/PVE/PTY.pm
index e433c4e..7b90150 100644
--- a/src/PVE/PTY.pm
+++ b/src/PVE/PTY.pm
@@ -165,6 +165,23 @@ sub tcsetsize($$$) {
or die "failed to set window size: $!\n";
}
+sub read_input($;$$) {
+ my ($query, $infd, $outfd) = @_;
+ my $input = '';
+ $infd //= \*STDIN;
+
+ if (-t $infd) {
+ $outfd //= \*STDOUT;
+ print $outfd $query;
+ }
+
+ local $/ = "\n";
+ $input = <$infd>;
+ chomp $input;
+
+ return $input;
+}
+
sub read_password($;$$) {
my ($query, $infd, $outfd) = @_;
@@ -173,10 +190,8 @@ sub read_password($;$$) {
$infd //= \*STDIN;
if (!-t $infd) { # Not a terminal? Then just get a line...
- local $/ = "\n";
- $password = <$infd>;
+ $password = read_input("", $infd, $outfd);
die "EOF while reading password\n" if !defined $password;
- chomp $password; # Chop off the newline
return $password;
}
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH pve-manager 2/3] remove dependency on Term::ReadLine (see #2077)
2022-05-09 7:30 [pve-devel] [PATCH pve-common 0/3] remove dependency on Term::ReadLine Stefan Hrdlicka
2022-05-09 7:30 ` [pve-devel] [PATCH pve-common 1/3] remove dependency on Term::ReadLine (see #2077) Stefan Hrdlicka
@ 2022-05-09 7:30 ` Stefan Hrdlicka
2022-05-09 7:30 ` [pve-devel] [PATCH qemu-server 3/3] " Stefan Hrdlicka
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hrdlicka @ 2022-05-09 7:30 UTC (permalink / raw)
To: pve-devel
depends on change in pve-common
Signed-off-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
---
PVE/CLI/pvenode.pm | 12 ++++--------
debian/control | 1 -
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/PVE/CLI/pvenode.pm b/PVE/CLI/pvenode.pm
index acef6c3b..383e1f81 100644
--- a/PVE/CLI/pvenode.pm
+++ b/PVE/CLI/pvenode.pm
@@ -22,8 +22,6 @@ use PVE::CLIFormatter;
use PVE::RESTHandler;
use PVE::CLIHandler;
-use Term::ReadLine;
-
use base qw(PVE::CLIHandler);
my $nodename = PVE::INotify::nodename();
@@ -93,13 +91,12 @@ __PACKAGE__->register_method({
}
print $i, ") Custom\n";
- my $term = Term::ReadLine->new('pvenode');
my $get_dir_selection = sub {
- my $selection = $term->readline("Enter selection: ");
- if ($selection =~ /^(\d+)$/) {
+ my $selection = PVE::PTY::read_input("Enter selection: ");
+ if ($selection =~ /^([0-9]+)$/) {
$selection = $1;
if ($selection == $i) {
- $param->{directory} = $term->readline("Enter custom URL: ");
+ $param->{directory} = PVE::PTY::read_input("Enter custom URL: ");
return;
} elsif ($selection < $i && $selection >= 0) {
$param->{directory} = $directories->[$selection]->{url};
@@ -120,8 +117,7 @@ __PACKAGE__->register_method({
my $tos = PVE::API2::ACMEAccount->get_tos({ directory => $param->{directory} });
if ($tos) {
print "Terms of Service: $tos\n";
- my $term = Term::ReadLine->new('pvenode');
- my $agreed = $term->readline('Do you agree to the above terms? [y|N]: ');
+ my $agreed = PVE::PTY::read_input('Do you agree to the above terms? [y|N]: ');
die "Cannot continue without agreeing to ToS, aborting.\n"
if ($agreed !~ /^y$/i);
diff --git a/debian/control b/debian/control
index f48a38d0..6bb442fd 100644
--- a/debian/control
+++ b/debian/control
@@ -62,7 +62,6 @@ Depends: apt-transport-https | apt (>= 1.5~),
libpve-storage-perl (>= 7.1-2),
librados2-perl,
libtemplate-perl,
- libterm-readline-gnu-perl,
liburi-perl,
libuuid-perl,
libwww-perl (>= 6.04-1),
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH qemu-server 3/3] remove dependency on Term::ReadLine (see #2077)
2022-05-09 7:30 [pve-devel] [PATCH pve-common 0/3] remove dependency on Term::ReadLine Stefan Hrdlicka
2022-05-09 7:30 ` [pve-devel] [PATCH pve-common 1/3] remove dependency on Term::ReadLine (see #2077) Stefan Hrdlicka
2022-05-09 7:30 ` [pve-devel] [PATCH pve-manager 2/3] " Stefan Hrdlicka
@ 2022-05-09 7:30 ` Stefan Hrdlicka
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hrdlicka @ 2022-05-09 7:30 UTC (permalink / raw)
To: pve-devel
depends on change in pve-common
Signed-off-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
---
This wasn't in the ticket but I found the dependency here as well and
removed it.
PVE/CLI/qm.pm | 4 ++--
debian/control | 1 -
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index cf0d6f3..9579967 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -12,7 +12,6 @@ use IO::Select;
use IO::Socket::UNIX;
use JSON;
use POSIX qw(strftime);
-use Term::ReadLine;
use URI::Escape;
use PVE::Cluster;
@@ -24,6 +23,7 @@ use PVE::Network;
use PVE::RPCEnvironment;
use PVE::SafeSyslog;
use PVE::Tools qw(extract_param);
+use PVE::PTY;
use PVE::API2::Qemu::Agent;
use PVE::API2::Qemu;
@@ -392,7 +392,7 @@ __PACKAGE__->register_method ({
my $term = Term::ReadLine->new('qm');
- while (defined(my $input = $term->readline('qm> '))) {
+ while (defined(my $input = PVE::PTY::read_input('qm> '))) {
chomp $input;
next if $input =~ m/^\s*$/;
last if $input =~ m/^\s*q(uit)?\s*$/;
diff --git a/debian/control b/debian/control
index 7de9e84..62869ac 100644
--- a/debian/control
+++ b/debian/control
@@ -38,7 +38,6 @@ Depends: dbus,
libpve-common-perl (>= 7.1-3),
libpve-guest-common-perl (>= 4.1-1),
libpve-storage-perl (>= 6.3-8),
- libterm-readline-gnu-perl,
libuuid-perl,
libxml-libxml-perl,
perl (>= 5.10.0-19),
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-09 7:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 7:30 [pve-devel] [PATCH pve-common 0/3] remove dependency on Term::ReadLine Stefan Hrdlicka
2022-05-09 7:30 ` [pve-devel] [PATCH pve-common 1/3] remove dependency on Term::ReadLine (see #2077) Stefan Hrdlicka
2022-05-09 7:30 ` [pve-devel] [PATCH pve-manager 2/3] " Stefan Hrdlicka
2022-05-09 7:30 ` [pve-devel] [PATCH qemu-server 3/3] " Stefan Hrdlicka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal