Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break sympa_wizard.pl to "sympa config…" commands #1370

Merged
merged 10 commits into from
Apr 13, 2022
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Makefile
/po/sympa/POTFILES
/po/web_help/POTFILES
/sympa.conf
/sympa.conf-dist

# make

Expand All @@ -31,7 +30,6 @@ Makefile
*.o
*.po~
/previous_sympa_version
/mk-sympa-dist.pl
/src/bin/*.pl
/src/cgi/*.fcgi
/src/libexec/*.pl
Expand All @@ -55,7 +53,6 @@ Makefile
# make install

/data_structure.version
/sympa_wizard.pl.inst

# make dist

Expand Down
21 changes: 1 addition & 20 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ EXTRA_DIST = \
$(noinst_SCRIPTS) \
$(nobase_modules_DATA)

CLEANFILES = \
sympa.conf-dist
CLEANFILES =

MSGFMT=@MSGFMT@
.po.mo:
Expand Down Expand Up @@ -158,11 +157,6 @@ installconfig: installdir
chown $(USER) $(DESTDIR)$(confdir)/sympa.conf; \
chgrp $(GROUP) $(DESTDIR)$(confdir)/sympa.conf; \
fi
@echo "Installing configuration template ..."
-@echo "installing sympa.conf-dist"; \
$(INSTALL) -m 644 -T sympa.conf-dist $(DESTDIR)$(confdir)/sympa.conf-dist; \
chown $(USER) $(DESTDIR)$(confdir)/sympa.conf-dist; \
chgrp $(GROUP) $(DESTDIR)$(confdir)/sympa.conf-dist
-@if [ ! -f $(DESTDIR)$(sysconfdir)/data_structure.version ]; then \
cd $(DESTDIR)$(sysconfdir); \
echo "# automatically created file" >> data_structure.version; \
Expand Down Expand Up @@ -204,21 +198,13 @@ nextstep:
@echo "# * Edit this file to define initial configuration:"
@echo "# $(confdir)/sympa.conf"
@echo "#"
@echo "# ADDITIONAL SETTINGS:"
@echo "# * You will find all available configuration settings in:"
@echo "# $(confdir)/sympa.conf-dist"
@echo "#"
@echo "# * Copy the configuration settings you want in:"
@echo "# $(confdir)/sympa.conf"
@echo "#"
@echo "# UPGRADING"
@echo "# * Run this script to upgrade your data structures:"
@echo "# $(sbindir)/sympa upgrade"
@echo "#######################################################"

uninstall-hook:
cd $(DESTDIR)$(confdir) && rm -f sympa.conf
cd $(DESTDIR)$(confdir) && rm -f sympa.conf-dist
cd $(DESTDIR)$(confdir) && rm -f wwsympa.conf
cd $(DESTDIR)$(sysconfdir) && rm -f data_structure.version
cd $(DESTDIR)$(sysconfdir) && rm -f README
Expand All @@ -241,8 +227,3 @@ tidyall:
echo ')->process_paths(qw(src xt t))' \
) | $(PERL) -MCode::TidyAll

all-local: sympa.conf-dist

sympa.conf-dist:
@PERL5LIB=$(srcdir)/src/lib; export PERL5LIB; \
$(PERL) mk-sympa-dist.pl
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,6 @@ AM_CONDITIONAL(SETUID_QUEUE, [test "x$enable_setuid_queue" = "xyes"])
AC_CONFIG_FILES([
Makefile
sympa.conf
mk-sympa-dist.pl
default/Makefile
doc/Makefile
po/Makefile
Expand Down
4 changes: 0 additions & 4 deletions doc/sympa_toc.pod
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ Command line utility to manage Sympa

Alias database maintenance

=item L<sympa_wizard(1)>

Help Performing Sympa Initial Setup

=back

=head3 Maintenance tools
Expand Down
118 changes: 0 additions & 118 deletions mk-sympa-dist.pl.in

This file was deleted.

5 changes: 4 additions & 1 deletion src/lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2017, 2018, 2019, 2021 The Sympa Community. See the
# Copyright 2017, 2018, 2019, 2021, 2022 The Sympa Community. See the
# AUTHORS.md file at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
Expand All @@ -33,6 +33,9 @@ CLI_modules = \
Sympa/CLI/check.pm \
Sympa/CLI/close.pm \
Sympa/CLI/conf_2_db.pm \
Sympa/CLI/config.pm \
Sympa/CLI/config/create.pm \
Sympa/CLI/config/show.pm \
Sympa/CLI/copy.pm \
Sympa/CLI/create.pm \
Sympa/CLI/del.pm \
Expand Down
44 changes: 43 additions & 1 deletion src/lib/Sympa/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use warnings;
use English qw(-no_match_vars);
use Getopt::Long qw(:config no_ignore_case);
use POSIX qw();
BEGIN { eval 'use Encode::Locale'; }

use Conf;
use Sympa::Constants;
Expand All @@ -47,7 +48,31 @@ sub run {
my @argv = @_;

if ($class eq 'Sympa::CLI') {
# Deal with some POSIX locales (LL.encoding)
$class->istty;

# Detect console encoding.
if ($Encode::Locale::VERSION) {
unless ('ascii' eq
Encode::resolve_alias($Encode::Locale::ENCODING_CONSOLE_IN)) {
if ($class->istty(0)) {
binmode(STDIN, ':encoding(console_in):bytes');
foreach my $arg (@argv) {
Encode::from_to($arg,
$Encode::Locale::ENCODING_CONSOLE_IN, 'utf-8');
}
}
}
unless ('ascii' eq
Encode::resolve_alias($Encode::Locale::ENCODING_CONSOLE_OUT))
{
binmode(STDOUT, ':encoding(console_out):bytes')
if $class->istty(1);
binmode(STDERR, ':encoding(console_out):bytes')
if $class->istty(2);
}
}

# Deal with some POSIX locales (LL_cc.encoding)
my @langs =
map {s/[.].*\z//r} grep {defined} @ENV{qw(LANGUAGE LC_ALL LANG)};
$language->set_lang(@langs, 'en-US', 'en');
Expand Down Expand Up @@ -160,6 +185,10 @@ sub run {
if ($arg eq '*') {
$val = $arg;
}
} elsif ($def eq 'keyvalue') {
if ($arg =~ /\A(\w+)=(.*)\z/) {
$val = [$1 => $2];
}
} else {
$val = $arg;
}
Expand Down Expand Up @@ -299,6 +328,18 @@ sub arrange {
$is_arranged = 1;
}

my @istty;

sub istty {
my $class = shift;

unless (@_) { # Get tty-nesses.
@istty = (-t STDIN, -t STDOUT, -t STDERR);
} else {
return $istty[$_[0]];
}
}

# Moved from: _report() in sympa.pl.
sub _report {
my $class = shift;
Expand Down Expand Up @@ -374,6 +415,7 @@ my $arg_labels = {
command => {gettext_id => 'command'},
string => {gettext_id => 'string'},
email => {gettext_id => 'email address'},
keyvalue => {gettext_id => '"key=value"'},
};

sub _arg_expected {
Expand Down
Loading