]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
Allow converting a Cap::Reference to a Cap::Capability*.
[user/henk/code/inspircd.git] / configure
index 5c99c2b457c9e7dcce1d53172f745a84bb235bdb..724970cade2a85f124398a8eabc90b2b897ac0f7 100755 (executable)
--- a/configure
+++ b/configure
@@ -2,6 +2,8 @@
 #
 # InspIRCd -- Internet Relay Chat Daemon
 #
+#   Copyright (C) 2020 Nicole Kleinhoff <ilbelkyr@shalture.org>
+#   Copyright (C) 2020 Daniel Vassdal <shutter@canternet.org>
 #   Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
 #   Copyright (C) 2019 Anatole Denis <natolumin@rezel.net>
 #   Copyright (C) 2017 emerson <github@emersonveenstra.net>
@@ -64,6 +66,7 @@ my ($opt_binary_dir,
     $opt_module_dir,
     $opt_portable,
     $opt_prefix,
+    $opt_runtime_dir,
     $opt_script_dir,
     $opt_socketengine,
     $opt_system,
@@ -97,6 +100,7 @@ exit 1 unless GetOptions(
        'module-dir=s'         => \$opt_module_dir,
        'portable'             => \$opt_portable,
        'prefix=s'             => \$opt_prefix,
+       'runtime-dir=s'        => \$opt_runtime_dir,
        'script-dir=s'         => \$opt_script_dir,
        'socketengine=s'       => \$opt_socketengine,
        'system'               => \$opt_system,
@@ -109,8 +113,8 @@ exit 1 unless GetOptions(
 );
 
 if (scalar(@opt_enableextras) + scalar(@opt_disableextras) > 0) {
-       @opt_enableextras = split /[, ]+/, join(',', @opt_enableextras);
-       @opt_disableextras = split /[, ]+/, join(',', @opt_disableextras);
+       @opt_enableextras = grep { /\S/ } split /[, ]+/, join(',', @opt_enableextras);
+       @opt_disableextras = grep { /\S/ } split /[, ]+/, join(',', @opt_disableextras);
        enable_extras(@opt_enableextras);
        disable_extras(@opt_disableextras);
        list_extras;
@@ -135,6 +139,7 @@ our $interactive = !(
        defined $opt_module_dir ||
        defined $opt_portable ||
        defined $opt_prefix ||
+       defined $opt_runtime_dir ||
        defined $opt_script_dir ||
        defined $opt_socketengine ||
        defined $opt_system ||
@@ -201,6 +206,7 @@ if (defined $opt_portable) {
        $config{LOG_DIR}     = $opt_log_dir     // 'logs';
        $config{MANUAL_DIR}  = $opt_manual_dir  // 'manuals';
        $config{MODULE_DIR}  = $opt_module_dir  // 'modules';
+       $config{RUNTIME_DIR} = $opt_runtime_dir // $config{DATA_DIR};
        $config{SCRIPT_DIR}  = $opt_script_dir  // $config{BASE_DIR};
 } elsif (defined $opt_system) {
        $config{BASE_DIR}    = $opt_prefix      // '/var/lib/inspircd';
@@ -211,7 +217,8 @@ if (defined $opt_portable) {
        $config{LOG_DIR}     = $opt_log_dir     // '/var/log/inspircd';
        $config{MANUAL_DIR}  = $opt_manual_dir  // '/usr/share/man/man1';
        $config{MODULE_DIR}  = $opt_module_dir  // '/usr/lib/inspircd';
-       $config{SCRIPT_DIR}  = $opt_script_dir  // '/usr/share/inspircd'
+       $config{RUNTIME_DIR} = $opt_runtime_dir // '/var/run';
+       $config{SCRIPT_DIR}  = $opt_script_dir  // '/usr/share/inspircd';
 } else {
        $config{BASE_DIR}    = rel2abs $opt_prefix // $config{BASE_DIR}    // catdir $RealDir,            'run';
        $config{BINARY_DIR}  = $opt_binary_dir     // $config{BINARY_DIR}  // catdir $config{BASE_DIR},   'bin';
@@ -221,6 +228,7 @@ if (defined $opt_portable) {
        $config{LOG_DIR}     = $opt_log_dir        // $config{LOG_DIR}     // catdir $config{BASE_DIR},   'logs';
        $config{MANUAL_DIR}  = $opt_manual_dir     // $config{MANUAL_DIR}  // catdir $config{BASE_DIR},   'manuals';
        $config{MODULE_DIR}  = $opt_module_dir     // $config{MODULE_DIR}  // catdir $config{BASE_DIR},   'modules';
+       $config{RUNTIME_DIR} = $opt_runtime_dir    // $config{RUNTIME_DIR} // $config{DATA_DIR};
        $config{SCRIPT_DIR}  = $opt_script_dir     // $config{SCRIPT_DIR}  // $config{BASE_DIR};
 }
 
@@ -343,6 +351,7 @@ if (prompt_bool $interactive, $question, 0) {
        $config{MODULE_DIR} = prompt_dir $interactive, 'In what directory are modules to be placed?',             $config{MODULE_DIR};
        $config{SCRIPT_DIR} = prompt_dir $interactive, 'In what directory are scripts to be placed?',             $config{SCRIPT_DIR};
        $config{EXAMPLE_DIR} = $config{CONFIG_DIR} . '/examples';
+       $config{RUNTIME_DIR} = $config{DATA_DIR};
 }
 
 # Configure module settings.
@@ -353,8 +362,8 @@ Would you like to enable extra modules manually?
 EOQ
 if (prompt_bool $interactive, $question, 0) {
        foreach my $extra (<$RealDir/src/modules/extra/m_*.cpp>) {
-               my $module_name = basename $extra, '.cpp';
-               if (prompt_bool $interactive, "Would you like to enable $module_name?", 0) {
+               my $module_name = module_shrink $extra;
+               if (prompt_bool $interactive, "Would you like to enable the <|BOLD $module_name|> module?", 0) {
                        enable_extras $module_name;
                }
        }
@@ -363,6 +372,7 @@ if (prompt_bool $interactive, $question, 0) {
        # system './modulemanager', 'enable', '--auto';
        my %modules = (
                # Missing: m_ldap, m_regex_stdlib, m_ssl_mbedtls
+               'm_argon2.cpp'          => 'pkg-config --exists libargon2',
                'm_geo_maxmind.cpp'     => 'pkg-config --exists libmaxminddb',
                'm_mysql.cpp'           => 'mysql_config --version',
                'm_pgsql.cpp'           => 'pg_config --version',
@@ -393,9 +403,10 @@ EOQ
 
 if (<$RealDir/src/modules/m_ssl_*.cpp>) {
        if (prompt_bool $interactive, $question, $interactive) {
-               system './tools/genssl', 'auto';
+               create_directory CONFIGURE_DIRECTORY, 0750 or print_error "unable to create ${\CONFIGURE_DIRECTORY}: $!";
+               system './tools/genssl', 'auto', CONFIGURE_DIRECTORY;
        } else {
-               my @pems = <$RealDir/{cert,csr,dhparams,key}.pem>;
+               my @pems = <${\CONFIGURE_DIRECTORY}/{cert,csr,dhparams,key}.pem>;
                $question = <<EOQ;
 The following self-signed files were previously generated and will be installed
 when you run Make. Do you want to delete them?
@@ -439,8 +450,7 @@ Configuration is complete! You have chosen to build with the following settings:
 EOM
 
 for my $file (<$RealDir/src/modules/m_*>) {
-       my $module = basename $file, '.cpp';
-       say "  * $module" if -l $file;
+       say "  * ${\module_shrink $file}" if -l $file;
 }
 
 my @makeargs;
@@ -458,6 +468,7 @@ print_format <<"EOM";
   <|GREEN Log:|>     $config{LOG_DIR}
   <|GREEN Manual:|>  $config{MANUAL_DIR}
   <|GREEN Module:|>  $config{MODULE_DIR}
+  <|GREEN Runtime:|> $config{RUNTIME_DIR}
   <|GREEN Script:|>  $config{SCRIPT_DIR}
 
 <|GREEN Execution Group:|> $config{GROUP} ($config{GID})
@@ -488,7 +499,7 @@ sub list_extras () {
        my @sources = map { File::Spec->case_tolerant() ? lc($_) : $_ } (readdir($dd));
        closedir $dd;
        undef $dd;
-       my $maxlen = (sort { $b <=> $a } (map {length($_)} (@extras)))[0];
+       my $maxlen = (sort { $b <=> $a } (map { length module_shrink $_ } (@extras)))[0];
        my %extras = ();
 EXTRA: for my $extra (@extras) {
                next if (File::Spec->curdir() eq $extra || File::Spec->updir() eq $extra);
@@ -556,9 +567,9 @@ EXTRA:      for my $extra (@extras) {
        for my $extra (sort {$a cmp $b} keys(%extras)) {
                my $text = $extras{$extra};
                if ($text =~ m/needed by/ && $text !~ m/enabled/) {
-                       printf "\e[31;1;5m%-*s = %s%s\e[0m\n", $maxlen, $extra, $text, ($text =~ m/needed by/ ? ")" : "");
+                       printf "\e[31;1;5m%-*s = %s%s\e[0m\n", $maxlen, module_shrink($extra), $text, ($text =~ m/needed by/ ? ")" : "");
                } else {
-                       printf "%-*s = %s%s\n", $maxlen, $extra, $text, ($text =~ m/needed by/ ? "\e[0m)" : "");
+                       printf "%-*s = %s%s\n", $maxlen, module_shrink($extra), $text, ($text =~ m/needed by/ ? "\e[0m)" : "");
                }
        }
        return keys(%extras) if wantarray; # Can be used by manage_extras.
@@ -569,8 +580,8 @@ sub enable_extras(@) {
        my $extradir = catdir $moduledir, 'extra';
 
        for my $extra (@_) {
-               my $shortname = $extra =~ s/(?:^m_|\.cpp$)//gr;
-               my $extrafile = "m_$shortname.cpp";
+               my $shortname = module_shrink $extra;
+               my $extrafile = module_expand $extra;
 
                my $extrapath = catfile $extradir, $extrafile;
                if (!-f $extrapath) {
@@ -600,8 +611,8 @@ sub disable_extras(@) {
        my $extradir = catdir $moduledir, 'extra';
 
        for my $extra (@_) {
-               my $shortname = $extra =~ s/(?:^m_|\.cpp$)//gr;
-               my $extrafile = "m_$shortname.cpp";
+               my $shortname = module_shrink $extra;
+               my $extrafile = module_expand $extra;
 
                my $modulepath = catfile $moduledir, $extrafile;
                my $extrapath = catfile $extradir, $extrafile;