4 # InspIRCd -- Internet Relay Chat Daemon
6 # Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
7 # Copyright (C) 2019 Anatole Denis <natolumin@rezel.net>
8 # Copyright (C) 2017 emerson <github@emersonveenstra.net>
9 # Copyright (C) 2013-2019 Sadie Powell <sadie@witchery.services>
10 # Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
11 # Copyright (C) 2012 ChrisTX <xpipe@hotmail.de>
12 # Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
13 # Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
14 # Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
15 # Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
16 # Copyright (C) 2006-2008 Craig Edwards <brain@inspircd.org>
18 # This file is part of InspIRCd. InspIRCd is free software: you can
19 # redistribute it and/or modify it under the terms of the GNU General Public
20 # License as published by the Free Software Foundation, version 2.
22 # This program is distributed in the hope that it will be useful, but WITHOUT
23 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
24 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
27 # You should have received a copy of the GNU General Public License
28 # along with this program. If not, see <http://www.gnu.org/licenses/>.
38 use warnings FATAL => qw(all);
40 use File::Basename qw(basename);
42 use File::Spec::Functions qw(rel2abs);
43 use FindBin qw($RealDir);
44 use Getopt::Long qw(GetOptions);
45 use POSIX qw(getgid getuid);
57 $opt_disable_auto_extras,
58 $opt_disable_interactive,
59 $opt_distribution_label,
73 sub enable_extras (@);
75 sub disable_extras (@);
78 my @opt_disableextras;
80 exit 1 unless GetOptions(
81 'clean' => \&cmd_clean,
83 'update' => \&cmd_update,
85 'binary-dir=s' => \$opt_binary_dir,
86 'config-dir=s' => \$opt_config_dir,
87 'data-dir=s' => \$opt_data_dir,
88 'development' => \$opt_development,
89 'disable-auto-extras' => \$opt_disable_auto_extras,
90 'disable-interactive' => \$opt_disable_interactive,
91 'distribution-label=s' => \$opt_distribution_label,
92 'example-dir=s' => \$opt_example_dir,
94 'log-dir=s' => \$opt_log_dir,
95 'manual-dir=s' => \$opt_manual_dir,
96 'module-dir=s' => \$opt_module_dir,
97 'prefix=s' => \$opt_prefix,
98 'script-dir=s' => \$opt_script_dir,
99 'socketengine=s' => \$opt_socketengine,
100 'system' => \$opt_system,
101 'uid=s' => \$opt_uid,
103 # TODO: when the modulemanager rewrite is done these should be removed.
104 'disable-extras=s@' => \@opt_disableextras,
105 'enable-extras=s@' => \@opt_enableextras,
106 'list-extras' => sub { list_extras; exit 0; },
109 if (scalar(@opt_enableextras) + scalar(@opt_disableextras) > 0) {
110 @opt_enableextras = split /,/, join(',', @opt_enableextras);
111 @opt_disableextras = split /,/, join(',', @opt_disableextras);
112 enable_extras(@opt_enableextras);
113 disable_extras(@opt_disableextras);
115 print "Remember: YOU are responsible for making sure any libraries needed have been installed!\n";
119 our $interactive = !(
122 defined $opt_binary_dir ||
123 defined $opt_config_dir ||
124 defined $opt_data_dir ||
125 defined $opt_development ||
126 defined $opt_disable_auto_extras ||
127 defined $opt_disable_interactive ||
128 defined $opt_distribution_label ||
129 defined $opt_example_dir ||
131 defined $opt_log_dir ||
132 defined $opt_manual_dir ||
133 defined $opt_module_dir ||
134 defined $opt_prefix ||
135 defined $opt_script_dir ||
136 defined $opt_socketengine ||
137 defined $opt_system ||
141 my %version = get_version $opt_distribution_label;
142 print_format "<|BOLD Configuring InspIRCd $version{FULL} on $^O.|>\n";
146 %config = read_config_file(CONFIGURE_CACHE_FILE);
147 run_test CONFIGURE_CACHE_FILE, %config;
148 if (!defined $config{VERSION}) {
149 $config{VERSION} = CONFIGURE_CACHE_VERSION;
150 } elsif ($config{VERSION} != CONFIGURE_CACHE_VERSION) {
151 print_warning "ignoring contents of ${\CONFIGURE_CACHE_FILE} as it was generated by an incompatible version of $0!";
152 %config = ('VERSION', CONFIGURE_CACHE_VERSION);
156 $config{CXX} = find_compiler($config{CXX} // $ENV{CXX});
157 unless ($config{CXX}) {
158 say 'A suitable C++ compiler could not be detected on your system!';
159 unless ($interactive) {
160 say 'Set the CXX environment variable to the path to a C++ compiler binary if this is incorrect.';
163 until ($config{CXX}) {
164 my $compiler_path = prompt_string 1, 'Please enter the path to a C++ compiler binary:', 'c++';
165 $config{CXX} = find_compiler $compiler_path;
168 my %compiler = get_compiler_info($config{CXX});
170 $config{HAS_ARC4RANDOM_BUF} = run_test 'arc4random_buf()', test_file($config{CXX}, 'arc4random_buf.cpp');
171 $config{HAS_CLOCK_GETTIME} = run_test 'clock_gettime()', test_file($config{CXX}, 'clock_gettime.cpp', $^O eq 'darwin' ? undef : '-lrt');
172 $config{HAS_EVENTFD} = run_test 'eventfd()', test_file($config{CXX}, 'eventfd.cpp');
175 push @socketengines, 'epoll' if run_test 'epoll', test_header $config{CXX}, 'sys/epoll.h';
176 push @socketengines, 'kqueue' if run_test 'kqueue', test_file $config{CXX}, 'kqueue.cpp';
177 push @socketengines, 'poll' if run_test 'poll', test_header $config{CXX}, 'poll.h';
178 push @socketengines, 'select';
180 if (defined $opt_socketengine) {
181 unless (grep { $_ eq $opt_socketengine } @socketengines) {
182 my $reason = -f "src/socketengines/socketengine_$opt_socketengine.cpp" ? 'is not available on this platform' : 'does not exist';
183 print_error "The socket engine you requested ($opt_socketengine) $reason!",
184 'Available socket engines are:',
185 map { " * $_" } @socketengines;
188 $config{SOCKETENGINE} = $opt_socketengine // $socketengines[0];
190 if (defined $opt_system) {
191 $config{BASE_DIR} = $opt_prefix // '/var/lib/inspircd';
192 $config{BINARY_DIR} = $opt_binary_dir // '/usr/sbin';
193 $config{CONFIG_DIR} = $opt_config_dir // '/etc/inspircd';
194 $config{DATA_DIR} = $opt_data_dir // '/var/inspircd';
195 $config{EXAMPLE_DIR} = $opt_example_dir // '/usr/share/doc/inspircd';
196 $config{LOG_DIR} = $opt_log_dir // '/var/log/inspircd';
197 $config{MANUAL_DIR} = $opt_manual_dir // '/usr/share/man/man1';
198 $config{MODULE_DIR} = $opt_module_dir // '/usr/lib/inspircd';
199 $config{SCRIPT_DIR} = $opt_script_dir // '/usr/share/inspircd'
201 $config{BASE_DIR} = $opt_prefix // $config{BASE_DIR} // rel2abs 'run';
202 $config{BINARY_DIR} = $opt_binary_dir // $config{BINARY_DIR} // rel2abs $config{BASE_DIR} . '/bin';
203 $config{CONFIG_DIR} = $opt_config_dir // $config{CONFIG_DIR} // rel2abs $config{BASE_DIR} . '/conf';
204 $config{DATA_DIR} = $opt_data_dir // $config{DATA_DIR} // rel2abs $config{BASE_DIR} . '/data';
205 $config{EXAMPLE_DIR} = $opt_example_dir // $config{EXAMPLE_DIR} // $config{CONFIG_DIR} . '/examples';
206 $config{LOG_DIR} = $opt_log_dir // $config{LOG_DIR} // rel2abs $config{BASE_DIR} . '/logs';
207 $config{MANUAL_DIR} = $opt_manual_dir // $config{MANUAL_DIR} // rel2abs $config{BASE_DIR} . '/manuals';
208 $config{MODULE_DIR} = $opt_module_dir // $config{MODULE_DIR} // rel2abs $config{BASE_DIR} . '/modules';
209 $config{SCRIPT_DIR} = $opt_script_dir // $config{SCRIPT_DIR} // $config{BASE_DIR};
212 # Parse --gid=123 or --gid=foo and extract the group id.
214 if (defined $opt_gid) {
215 @group = $opt_gid =~ /^\d+$/ ? getgrgid($opt_gid) : getgrnam($opt_gid);
216 print_error "there is no '$opt_gid' group on this system!" unless @group;
218 @group = $opt_system ? getgrnam('irc') : getgrgid($config{GID} // getgid());
219 print_error "you need to specify a group to run as using '--gid [id|name]'!" unless @group;
221 print_warning <<"EOW";
222 You are building as the privileged $group[0] group and have not specified
223 an unprivileged group to run InspIRCd as.
225 This is almost never what you should do. You should probably either create a new
226 unprivileged user/group to build and run as or pass the '--gid [id|name]' flag
227 to specify an unprivileged group to run as.
229 if (!prompt_bool $interactive, "Are you sure you want to build as the $group[0] group?", 0) {
230 say STDERR "If you are sure you want to build as the $group[0] group pass the --gid $group[2] flag." unless $interactive;
235 $config{GROUP} = $group[0];
236 $config{GID} = $group[2];
238 # Parse --uid=123 or --uid=foo and extract the user id.
240 if (defined $opt_uid) {
241 @user = $opt_uid =~ /^\d+$/ ? getpwuid($opt_uid) : getpwnam($opt_uid);
242 print_error "there is no '$opt_uid' user on this system!" unless @user;
244 @user = $opt_system ? getpwnam('irc') : getpwuid($config{UID} // getuid());
245 print_error "you need to specify a user to run as using '--uid [id|name]'!" unless @user;
247 print_warning <<"EOW";
248 You are building as the privileged $user[0] user and have not specified
249 an unprivileged user to run InspIRCd as.
251 This is almost never what you should do. You should probably either create a new
252 unprivileged user/group to build and run as or pass the '--uid [id|name]' flag
253 to specify an unprivileged user to run as.
255 if (!prompt_bool $interactive, "Are you sure you want to build as the $user[0] user?", 0) {
256 say STDERR "If you are sure you want to build as the $user[0] user pass the --uid $user[2] flag." unless $interactive;
261 $config{USER} = $user[0];
262 $config{UID} = $user[2];
264 # Warn the user about clock drifting when running on OpenVZ.
265 if (-e '/proc/user_beancounters' || -e '/proc/vz/vzaquota') {
266 print_warning <<'EOW';
267 You are building InspIRCd inside of an OpenVZ container. If you
268 plan to use InspIRCd in this container then you should make sure that NTP is
269 configured on the Hardware Node. Failure to do so may result in clock drifting!
273 # Warn the user about OpenBSD shipping incredibly broken compilers/linkers.
274 if ($^O eq 'openbsd') {
275 print_warning <<'EOW';
276 You are building InspIRCd on OpenBSD. The C++ compilers and linkers
277 that OpenBSD ship are incredibly broken. You may have strange linker errors
278 and crashes. Please consider using a different OS like FreeBSD/NetBSD instead.
282 # Check that the user actually wants this version.
283 if (defined $version{REAL_LABEL}) {
284 print_warning <<'EOW';
285 You are building a development version. This contains code which has
286 not been tested as heavily and may contain various faults which could seriously
287 affect the running of your server. It is recommended that you use a stable
290 You can obtain the latest stable version from https://www.inspircd.org or by
291 running `<|GREEN git checkout $(git describe --abbrev=0 --tags insp3)|>` if you are
294 if (!prompt_bool $interactive, 'I understand this warning and want to continue anyway.', $opt_development // 0) {
295 say STDERR 'If you understand this warning and still want to continue pass the --development flag.' unless $interactive;
300 # Configure directory settings.
301 my $question = <<"EOQ";
302 Currently, InspIRCd is configured with the following paths:
304 <|BOLD Base:|> $config{BASE_DIR}
305 <|BOLD Binary:|> $config{BINARY_DIR}
306 <|BOLD Config:|> $config{CONFIG_DIR}
307 <|BOLD Data:|> $config{DATA_DIR}
308 <|BOLD Log:|> $config{LOG_DIR}
309 <|BOLD Manual:|> $config{MANUAL_DIR}
310 <|BOLD Module:|> $config{MODULE_DIR}
311 <|BOLD Script:|> $config{SCRIPT_DIR}
313 Do you want to change these settings?
315 if (prompt_bool $interactive, $question, 0) {
316 my $original_base_dir = $config{BASE_DIR};
317 $config{BASE_DIR} = prompt_dir $interactive, 'In what directory do you wish to install the InspIRCd base?', $config{BASE_DIR};
318 foreach my $key (qw(BINARY_DIR CONFIG_DIR DATA_DIR LOG_DIR MANUAL_DIR MODULE_DIR SCRIPT_DIR)) {
319 $config{$key} =~ s/^\Q$original_base_dir\E/$config{BASE_DIR}/;
321 $config{BINARY_DIR} = prompt_dir $interactive, 'In what directory should the InspIRCd binary be placed?', $config{BINARY_DIR};
322 $config{CONFIG_DIR} = prompt_dir $interactive, 'In what directory are configuration files to be stored?', $config{CONFIG_DIR};
323 $config{DATA_DIR} = prompt_dir $interactive, 'In what directory are variable data files to be stored?', $config{DATA_DIR};
324 $config{LOG_DIR} = prompt_dir $interactive, 'In what directory are log files to be stored?', $config{LOG_DIR};
325 $config{MANUAL_DIR} = prompt_dir $interactive, 'In what directory are manual pages to be placed?', $config{MANUAL_DIR};
326 $config{MODULE_DIR} = prompt_dir $interactive, 'In what directory are modules to be placed?', $config{MODULE_DIR};
327 $config{SCRIPT_DIR} = prompt_dir $interactive, 'In what directory are scripts to be placed?', $config{SCRIPT_DIR};
328 $config{EXAMPLE_DIR} = $config{CONFIG_DIR} . '/examples';
331 # Configure module settings.
333 Currently, InspIRCd is configured to automatically enable all available extra modules.
335 Would you like to enable extra modules manually?
337 if (prompt_bool $interactive, $question, 0) {
338 foreach my $extra (<src/modules/extra/m_*.cpp>) {
339 my $module_name = basename $extra, '.cpp';
340 if (prompt_bool $interactive, "Would you like to enable $module_name?", 0) {
341 enable_extras "$module_name.cpp";
344 } elsif (!defined $opt_disable_auto_extras) {
345 # TODO: finish modulemanager rewrite and replace this code with:
346 # system './modulemanager', 'enable', '--auto';
348 # Missing: m_ldap, m_regex_stdlib, m_ssl_mbedtls
349 'm_geo_maxmind.cpp' => 'pkg-config --exists libmaxminddb',
350 'm_mysql.cpp' => 'mysql_config --version',
351 'm_pgsql.cpp' => 'pg_config --version',
352 'm_regex_pcre.cpp' => 'pcre-config --version',
353 'm_regex_posix.cpp' => undef,
354 'm_regex_re2.cpp' => 'pkg-config --exists re2',
355 'm_regex_tre.cpp' => 'pkg-config --exists tre',
356 'm_sqlite3.cpp' => 'pkg-config --exists sqlite3',
357 'm_ssl_gnutls.cpp' => 'pkg-config --exists gnutls',
358 'm_ssl_openssl.cpp' => 'pkg-config --exists openssl',
359 'm_sslrehashsignal.cpp' => undef,
361 while (my ($module, $command) = each %modules) {
362 unless (defined $command && system "$command 1>/dev/null 2>/dev/null") {
363 enable_extras $module;
368 # Generate SSL certificates.
370 Would you like to generate a self-signed SSL certificate now? This certificate
371 can be used for testing but <|BOLD should not|> be used on a production network.
373 Note: you can get a <|BOLD free|> CA-signed certificate from Let's Encrypt. See
374 https://letsencrypt.org/getting-started/ for more details.
377 if (<src/modules/m_ssl_*.cpp>) {
378 if (prompt_bool $interactive, $question, $interactive) {
379 system './tools/genssl', 'auto';
382 print_warning <<"EOM";
383 You are building without enabling any SSL modules. This is not
384 recommended as SSL greatly enhances the security and privacy of your IRC server
385 and in a future version will be <|BOLD required|> for linking servers.
387 Please read the following documentation pages on how to enable SSL support:
389 GnuTLS (recommended): https://docs.inspircd.org/3/modules/ssl_gnutls
390 mbedTLS: https://docs.inspircd.org/3/modules/ssl_mbedtls
391 OpenSSL: https://docs.inspircd.org/3/modules/ssl_openssl
395 # Cache the distribution label so that its not lost when --update is run.
396 $config{DISTRIBUTION} = $opt_distribution_label if $opt_distribution_label;
398 write_configure_cache %config;
399 parse_templates \%config, \%compiler, \%version;
401 print_format <<"EOM";
403 Configuration is complete! You have chosen to build with the following settings:
406 <|GREEN Binary:|> $config{CXX}
407 <|GREEN Name:|> $compiler{NAME}
408 <|GREEN Version:|> $compiler{VERSION}
410 <|GREEN Extra Modules:|>
413 for my $file (<src/modules/m_*>) {
414 my $module = basename $file, '.cpp';
415 say " * $module" if -l $file;
418 print_format <<"EOM";
421 <|GREEN Base:|> $config{BASE_DIR}
422 <|GREEN Binary:|> $config{BINARY_DIR}
423 <|GREEN Config:|> $config{CONFIG_DIR}
424 <|GREEN Data:|> $config{DATA_DIR}
425 <|GREEN Example:|> $config{EXAMPLE_DIR}
426 <|GREEN Log:|> $config{LOG_DIR}
427 <|GREEN Manual:|> $config{MANUAL_DIR}
428 <|GREEN Module:|> $config{MODULE_DIR}
429 <|GREEN Script:|> $config{SCRIPT_DIR}
431 <|GREEN Execution Group:|> $config{GROUP} ($config{GID})
432 <|GREEN Execution User:|> $config{USER} ($config{UID})
433 <|GREEN Socket Engine:|> $config{SOCKETENGINE}
435 To build with these settings run '<|GREEN make -j${\get_cpu_count} install|>' now.
439 # Routine to list out the extra/ modules that have been enabled.
440 # Note: when getting any filenames out and comparing, it's important to lc it if the
441 # file system is not case-sensitive (== Epoc, MacOS, OS/2 (incl DOS/DJGPP), VMS, Win32
442 # (incl NetWare, Symbian)). Cygwin may or may not be case-sensitive, depending on
443 # configuration, however, File::Spec does not currently tell us (it assumes Unix behavior).
447 my $srcdir = File::Spec->catdir("src", "modules");
448 my $abs_srcdir = File::Spec->rel2abs($srcdir);
451 opendir $dd, File::Spec->catdir($abs_srcdir, "extra") or die (File::Spec->catdir($abs_srcdir, "extra") . ": $!\n");
452 my @extras = map { File::Spec->case_tolerant() ? lc($_) : $_ } (readdir($dd));
455 opendir $dd, $abs_srcdir or die "$abs_srcdir: $!\n";
456 my @sources = map { File::Spec->case_tolerant() ? lc($_) : $_ } (readdir($dd));
459 my $maxlen = (sort { $b <=> $a } (map {length($_)} (@extras)))[0];
461 EXTRA: for my $extra (@extras) {
462 next if (File::Spec->curdir() eq $extra || File::Spec->updir() eq $extra);
463 my $abs_extra = File::Spec->catfile($abs_srcdir, "extra", $extra);
464 my $abs_source = File::Spec->catfile($abs_srcdir, $extra);
465 next unless ($extra =~ m/\.(cpp|h)$/ || (-d $abs_extra)); # C++ Source/Header, or directory
466 if (-l $abs_source) {
467 # Symlink, is it in the right place?
468 my $targ = readlink($abs_source);
469 my $abs_targ = File::Spec->rel2abs($targ, $abs_srcdir);
470 if ($abs_targ eq $abs_extra) {
471 $extras{$extra} = "\e[32;1menabled\e[0m";
473 $extras{$extra} = sprintf("\e[31;1mwrong symlink target (%s)\e[0m", $abs_targ);
475 } elsif (-e $abs_source) {
476 my ($devext, $inoext) = stat($abs_extra);
477 my ($devsrc, $inosrc, undef, $lnksrc) = stat($abs_source);
479 if ($devsrc == $devext && $inosrc == $inoext) {
480 $extras{$extra} = "\e[32;1menabled\e[0m";
482 $extras{$extra} = sprintf("\e[31;1mwrong hardlink target (%d:%d)\e[0m", $devsrc, $inosrc);
485 open my $extfd, "<", $abs_extra;
486 open my $srcfd, "<", $abs_source;
488 if (scalar(<$extfd>) eq scalar(<$srcfd>)) {
489 $extras{$extra} = "\e[32;1menabled\e[0m";
491 $extras{$extra} = sprintf("\e[31;1mout of synch (re-copy)\e[0m");
495 $extras{$extra} = "\e[33;1mdisabled\e[0m";
498 # Now let's add dependency info
499 for my $extra (keys(%extras)) {
500 next unless $extras{$extra} =~ m/enabled/; # only process enabled extras.
501 my $abs_extra = File::Spec->catfile($abs_srcdir, "extra", $extra);
502 my @deps = split /\s+/, get_directive($abs_extra, 'ModDep', '');
503 for my $dep (@deps) {
504 if (exists($extras{$dep})) {
505 my $ref = \$extras{$dep}; # Take reference.
506 if ($$ref !~ m/needed by/) {
507 # First dependency found.
508 if ($$ref =~ m/enabled/) {
509 $$ref .= " (needed by \e[32;1m$extra\e[0m";
511 $$ref =~ s/\e\[.*?m//g; # Strip out previous coloring. Will be set in bold+red+blink later.
512 $$ref .= " (needed by \e[0;32;1;5m$extra\e[0;31;1;5m";
515 if ($$ref =~ m/enabled/) {
516 $$ref .= ", \e[32;1m$extra\e[0m";
518 $$ref .= ", \e[0;32;1;5m$extra\e[0;31;1;5m";
524 for my $extra (sort {$a cmp $b} keys(%extras)) {
525 my $text = $extras{$extra};
526 if ($text =~ m/needed by/ && $text !~ m/enabled/) {
527 printf "\e[31;1;5m%-*s = %s%s\e[0m\n", $maxlen, $extra, $text, ($text =~ m/needed by/ ? ")" : "");
529 printf "%-*s = %s%s\n", $maxlen, $extra, $text, ($text =~ m/needed by/ ? "\e[0m)" : "");
532 return keys(%extras) if wantarray; # Can be used by manage_extras.
535 sub enable_extras (@) {
537 for my $extra (@extras) {
538 my $extrapath = "src/modules/extra/$extra";
539 if (!-e $extrapath) {
540 print STDERR "Cannot enable \e[32;1m$extra\e[0m : No such file or directory in src/modules/extra\n";
543 my $source = "src/modules/$extra";
545 print STDERR "Cannot enable \e[32;1m$extra\e[0m : destination in src/modules exists (might already be enabled?)\n";
548 # Get dependencies, and add them to be processed.
549 my @deps = split /\s+/, get_directive($extrapath, 'ModDep', '');
550 for my $dep (@deps) {
551 next if scalar(grep { $_ eq $dep } (@extras)) > 0; # Skip if we're going to be enabling it anyway.
552 if (!-e "src/modules/$dep" && !-e "include/$dep") {
553 if (-e "src/modules/extra/$dep") {
554 print STDERR "Will also enable extra \e[32;1m$dep\e[0m (needed by \e[32;1m$extra\e[0m)\n";
557 print STDERR "\e[33;1mWARNING:\e[0m module \e[32;1m$extra\e[0m might be missing dependency \e[32;1m$dep\e[0m - YOU are responsible for satisfying it!\n";
561 print "Enabling $extra ... \n";
562 symlink "extra/$extra", $source or print STDERR "$source: Cannot link to 'extra/$extra': $!\n";
566 sub disable_extras (@)
568 opendir my $dd, "src/modules/extra/";
569 my @files = readdir($dd);
572 EXTRA: for my $extra (@extras) {
573 my $extrapath = "src/modules/extra/$extra";
574 my $source = "src/modules/$extra";
575 if (!-e $extrapath) {
576 print STDERR "Cannot disable \e[32;1m$extra\e[0m : Is not an extra\n";
579 if ((! -l $source) || readlink($source) ne "extra/$extra") {
580 print STDERR "Cannot disable \e[32;1m$extra\e[0m : Source is not a link or doesn't refer to the right file. Remove manually if this is in error.\n";
583 # Check if anything needs this.
584 for my $file (@files) {
585 my @deps = split /\s+/, get_directive("src/modules/extra/$file", 'ModDep', '');
586 # File depends on this extra...
587 if (scalar(grep { $_ eq $extra } @deps) > 0) {
588 # And is both enabled and not about to be disabled.
589 if (-e "src/modules/$file" && scalar(grep { $_ eq $file } @extras) < 1) {
590 print STDERR "Cannot disable \e[32;1m$extra\e[0m : is needed by \e[32;1m$file\e[0m\n";
596 print "Disabling $extra ... \n";
597 unlink "src/modules/$extra" or print STDERR "Cannot disable \e[32;1m$extra\e[0m : $!\n";