| 1 | package Acrux::Const; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use feature ':5.16'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | Acrux::Const - The Acrux constants | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | use Acrux::Const; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | This module contains constants definitions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =head2 TAGS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | =item B<:dir> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | Exports FHS DIR constants | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | See L<See https://www.pathname.com/fhs/pub/fhs-2.3.html>, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | L<http://www.gnu.org/software/autoconf/manual/html_node/Installation-Directory-Variables.html>, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | L<Sys::Path> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | =item B<:general> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | Exports common constants | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | =head1 HISTORY | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | See C<Changes> file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | =head1 TO DO | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | See C<TODO> file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | L<Acrux> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | Serż Minus (Sergey Lepenkov) L<https://www.serzik.com> E<lt>abalama@cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | Copyright (C) 1998-2026 D&D Corporation | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | This program is distributed under the terms of the Artistic License Version 2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | See the C<LICENSE> file or L<https://opensource.org/license/artistic-2-0> for details | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 5 | ▶ | use base qw/Exporter/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 5 | ▶ | use Config qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 5 | ▶ | use File::Spec qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=21.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # System constants | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 5 | ▶ | IS_TTY => !!(-t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT))), # See Prompt::Timeout | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition11%1/9
-t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT))
-t STDOUT or not -f STDOUT || -c STDOUT
-f STDOUT || -c STDOUT
MC/DC0%0/4
-t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT))
-t STDIN
-t STDOUT
-f STDOUT
-c STDOUT
Truth table20%1/5
A && B or not(C || D)
A= -t STDINB= -t STDOUTC= -f STDOUTD= -c STDOUT
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | IS_ROOT => !!($> == 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # Date and time formats (see strftime(3)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | DATE_FORMAT => '%Y-%m-%d', # POSIX::strftime(DATE_FORMAT, localtime($t)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | TIME_FORMAT => '%H:%M:%S', # POSIX::strftime(TIME_FORMAT, localtime($t)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | DATETIME_FORMAT => '%Y-%m-%dT%H:%M:%S', # POSIX::strftime(DATETIME_FORMAT, localtime($t)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | DATE_TIME_FORMAT => '%Y-%m-%d %H:%M:%S', # POSIX::strftime(DATE_TIME_FORMAT, localtime($t)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # Named groups of exports | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 'GENERAL' => [qw/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | IS_TTY IS_ROOT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | DATE_FORMAT TIME_FORMAT DATETIME_FORMAT DATE_TIME_FORMAT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | /], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 'DIR' => [qw/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | PREFIX LOCALSTATEDIR SYSCONFDIR SRVDIR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | BINDIR SBINDIR DATADIR DOCDIR LOCALEDIR MANDIR LOCALBINDIR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | CACHEDIR LOGDIR SPOOLDIR RUNDIR LOCKDIR SHAREDSTATEDIR WEBDIR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | /], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # Items to export into callers namespace by default | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # (move infrequently used names to @EXPORT_OK below) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | our @EXPORT = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 5 | @{$EXPORT_TAGS{GENERAL}}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # Other items we are prepared to export if requested | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | our @EXPORT_OK = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | map {@{$_}} values %EXPORT_TAGS | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # Correct tags: makes lowercase tags as aliases of original uppercase tags | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 5 | foreach my $k (keys %EXPORT_TAGS) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 10 | ▶ | next if exists $EXPORT_TAGS{(lc($k))}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 10 | ▶ | $EXPORT_TAGS{(lc($k))} = $EXPORT_TAGS{$k} if $k =~ /^[A-Z_]+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # Filesystem Hierarchy Standard | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # See http://www.gnu.org/software/autoconf/manual/html_node/Installation-Directory-Variables.html | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # See https://www.pathname.com/fhs/pub/fhs-2.3.html | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 5 | ▶ | my $prefix = $Config::Config{'prefix'} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$Config::Config{"prefix"} // ""
MC/DC0%0/1
$Config::Config{"prefix"} // ""
$Config::Config{"prefix"}
Truth table50%1/2
A
A= $Config::Config{"prefix"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 5 | ▶ | my $bindir = $Config::Config{'bin'} // File::Spec->catdir($prefix, 'bin'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$Config::Config{"bin"} // "File::Spec"->catdir($prefix, "bin")
MC/DC0%0/2
$Config::Config{"bin"} // "File::Spec"->catdir($prefix, "bin")
$Config::Config{"bin"}
"File::Spec"->catdir($prefix, "bin")
Truth table33%1/3
A // B
A= $Config::Config{"bin"}B= "File::Spec"->catdir($prefix, "bin")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | ▶ | my $localstatedir = $prefix eq '/usr' ? '/var' : File::Spec->catdir($prefix, 'var'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 5 | ▶ | my $sysconfdir = $prefix eq '/usr' ? '/etc' : File::Spec->catdir($prefix, 'etc'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 5 | ▶ | my $srvdir = $prefix eq '/usr' ? '/srv' : File::Spec->catdir($prefix, 'srv'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # Root dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | *PREFIX = sub { $prefix }; # prefix /usr | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | *LOCALSTATEDIR = sub { $localstatedir }; # localstatedir /var | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | ▶ | *SYSCONFDIR = sub { $sysconfdir }; # sysconfdir /etc | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | *SRVDIR = sub { $srvdir }; # srvdir /srv | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # Prefix related dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | *BINDIR = sub { $bindir }; # bindir /usr/bin | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | *SBINDIR = sub { state $sbindir = File::Spec->catdir($prefix, 'sbin') }; # sbindir /usr/sbin | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | *DATADIR = sub { state $datadir = File::Spec->catdir($prefix, 'share') }; # datadir /usr/share | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | ▶ | *DOCDIR = sub { state $docdir = File::Spec->catdir($prefix, 'share', 'doc') }; # docdir /usr/share/doc | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | *LOCALEDIR = sub { state $localedir = File::Spec->catdir($prefix, 'share', 'locale') }; # localedir /usr/share/locale | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | *MANDIR = sub { state $mandir = File::Spec->catdir($prefix, 'share', 'man') }; # mandir /usr/share/man | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | *LOCALBINDIR = sub { state $localbindir = File::Spec->catdir($prefix, 'local', 'bin') };# localbindir /usr/local/bin | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # Local State related Dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | ▶ | *CACHEDIR = sub { state $cachedir = File::Spec->catdir($localstatedir, 'cache') }; # cachedir /var/cache | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | ▶ | *LOGDIR = sub { state $logdir = File::Spec->catdir($localstatedir, 'log') }; # logdir /var/log | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | ▶ | *SPOOLDIR = sub { state $spooldir = File::Spec->catdir($localstatedir, 'spool') }; # spooldir /var/spool | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | *RUNDIR = sub { state $rundir = File::Spec->catdir($localstatedir, 'run') }; # rundir /var/run | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | ▶ | *LOCKDIR = sub { state $lockdir = File::Spec->catdir($localstatedir, 'lock') }; # lockdir /var/lock | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | ▶ | *SHAREDSTATEDIR = sub { state $sharedstatedir = File::Spec->catdir($localstatedir, 'lib') }; # sharedstatedir /var/lib | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | ▶ | *WEBDIR = sub { state $webdir = File::Spec->catdir($localstatedir, 'www') }; # webdir /var/www | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||