line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ############################################################################## |
2
|
|
|
|
|
|
|
# # Script : Tkx::TclTk::Bind.pm # |
3
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- # |
4
|
|
|
|
|
|
|
# # Copyright : Frei unter GNU General Public License bzw. Artistic License # |
5
|
|
|
|
|
|
|
# # Authors : JVBSOFT - Jürgen von Brietzke 0.001 - 1.300 # |
6
|
|
|
|
|
|
|
# # Version : 1.300 19.Dez.2015 # |
7
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- # |
8
|
|
|
|
|
|
|
# # Function : Bindet TclTk-Bibliotheken an Perl::Tkx # |
9
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- # |
10
|
|
|
|
|
|
|
# # Language : PERL 5 (V) 5.12.xx - 5.22.xx # |
11
|
|
|
|
|
|
|
# # Coding : ISO 8859-15 / Latin-9 UNIX-Zeilenende # |
12
|
|
|
|
|
|
|
# # Standards : Perl-Best-Practices severity 1 (brutal) # |
13
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- # |
14
|
|
|
|
|
|
|
# # Module : Archive::Tar ActivePerl-CORE-Module # |
15
|
|
|
|
|
|
|
# # Config # |
16
|
|
|
|
|
|
|
# # English # |
17
|
|
|
|
|
|
|
# # Exporter # |
18
|
|
|
|
|
|
|
# # File::Spec # |
19
|
|
|
|
|
|
|
# # Tkx # |
20
|
|
|
|
|
|
|
# # ------------------------------------------------------------- # |
21
|
|
|
|
|
|
|
# # Const::Fast ActivePerl-REPO-Module # |
22
|
|
|
|
|
|
|
# # File::Remove # |
23
|
|
|
|
|
|
|
# # Perl::Modern::Perl # |
24
|
|
|
|
|
|
|
# ############################################################################## |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package Tkx::TclTk::Bind 1.300; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# ############################################################################## |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
|
32812
|
use Archive::Tar; |
|
2
|
|
|
|
|
274809
|
|
|
2
|
|
|
|
|
134
|
|
31
|
2
|
|
|
2
|
|
18
|
use Config; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
32
|
2
|
|
|
2
|
|
1510
|
use Const::Fast; |
|
2
|
|
|
|
|
5473
|
|
|
2
|
|
|
|
|
14
|
|
33
|
2
|
|
|
2
|
|
1738
|
use English qw{-no_match_vars}; |
|
2
|
|
|
|
|
6312
|
|
|
2
|
|
|
|
|
10
|
|
34
|
2
|
|
|
2
|
|
2351
|
use File::Remove qw{remove}; |
|
2
|
|
|
|
|
3901
|
|
|
2
|
|
|
|
|
114
|
|
35
|
2
|
|
|
2
|
|
12
|
use File::Spec; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
48
|
|
36
|
2
|
|
|
2
|
|
1656
|
use Perl::Modern::Perl qw{5.12}; |
|
2
|
|
|
|
|
21839
|
|
|
2
|
|
|
|
|
15
|
|
37
|
2
|
|
|
2
|
|
2728
|
use Tkx; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# ############################################################################## |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use base qw{ Exporter }; |
42
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ &load_library }; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# ############################################################################## |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our $TEMP_DIR; |
47
|
|
|
|
|
|
|
our @PACKAGES; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# ############################################################################## |
50
|
|
|
|
|
|
|
# # D E S T R U K T O R # |
51
|
|
|
|
|
|
|
# ############################################################################## |
52
|
|
|
|
|
|
|
# # Aufgabe | Löscht die temporären Dateien # |
53
|
|
|
|
|
|
|
# ############################################################################## |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub END { |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
foreach my $package (@PACKAGES) { |
58
|
|
|
|
|
|
|
my $dir = File::Spec->catfile( $TEMP_DIR, $package ); |
59
|
|
|
|
|
|
|
remove( \1, $dir ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} # end of sub END |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# ############################################################################## |
65
|
|
|
|
|
|
|
# # Name | load_library # |
66
|
|
|
|
|
|
|
# # ----------+--------------------------------------------------------------- # |
67
|
|
|
|
|
|
|
# # Aufgabe | Lädt ein Bibliotheks-Archiv in das System-Temp-Verzeichnis # |
68
|
|
|
|
|
|
|
# # ----------+------------+-------------------------------------------------- # |
69
|
|
|
|
|
|
|
# # Parameter | scalar | Name des Bibliothek-Archivs ohne '.xx.tar' # |
70
|
|
|
|
|
|
|
# # | array | Zu installierender Tcl/Tk-Package-Name # |
71
|
|
|
|
|
|
|
# # ----------+------------+-------------------------------------------------- # |
72
|
|
|
|
|
|
|
# # Rückgabe | scalar | Pfad zum entpackten Archiv # |
73
|
|
|
|
|
|
|
# ############################################################################## |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub load_library { |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my ( $library, @package ) = @ARG; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
const my $CONST_UMASK => oct 777; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# --- TEMP-Verzeichnis bestimmen -------------------------------------------- |
82
|
|
|
|
|
|
|
$TEMP_DIR |
83
|
|
|
|
|
|
|
= defined $ENV{TMP} ? $ENV{TMP} |
84
|
|
|
|
|
|
|
: defined $ENV{TEMP} ? $ENV{TEMP} |
85
|
|
|
|
|
|
|
: defined $ENV{TMPDIR} ? $ENV{TMPDIR} |
86
|
|
|
|
|
|
|
: defined $ENV{HOME} ? $ENV{HOME} |
87
|
|
|
|
|
|
|
: undef; |
88
|
|
|
|
|
|
|
if ( not defined $TEMP_DIR ) { |
89
|
|
|
|
|
|
|
_error( 'No environment value "ENV{TMP & TEMP & TMPDIR & HOME}" found', |
90
|
|
|
|
|
|
|
$library ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# --- TEMP-Verzeichnis erzeugen wenn nötig ---------------------------------- |
94
|
|
|
|
|
|
|
$TEMP_DIR = File::Spec->catfile( $TEMP_DIR, 'TclTk' ); |
95
|
|
|
|
|
|
|
if ( not -e $TEMP_DIR ) { |
96
|
|
|
|
|
|
|
mkdir $TEMP_DIR, $CONST_UMASK |
97
|
|
|
|
|
|
|
or _error( "Can't create directory\n$TEMP_DIR", $library ); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# --- Archiv-Name und -Typ bestimmen ---------------------------------------- |
101
|
|
|
|
|
|
|
my $archname |
102
|
|
|
|
|
|
|
= $OSNAME =~ /MSWin32/ismx ? 'mswin' |
103
|
|
|
|
|
|
|
: $OSNAME =~ /linux/ismx ? 'linux' |
104
|
|
|
|
|
|
|
: $OSNAME =~ /darwin/ismx ? 'darwin' |
105
|
|
|
|
|
|
|
: undef; |
106
|
|
|
|
|
|
|
if ( not defined $archname ) { |
107
|
|
|
|
|
|
|
_error( "System $OSNAME is not supported", $library ); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
my $archtype |
110
|
|
|
|
|
|
|
= $Config{archname} =~ /i686-linux/smx ? '32' |
111
|
|
|
|
|
|
|
: $Config{archname} =~ /x86_64-linux/smx ? '64' |
112
|
|
|
|
|
|
|
: $Config{archname} =~ /MSWin32-x86/smx ? '32' |
113
|
|
|
|
|
|
|
: $Config{archname} =~ /MSWin32-x64/smx ? '64' |
114
|
|
|
|
|
|
|
: $Config{archname} =~ /darwin/smx ? 'xx' |
115
|
|
|
|
|
|
|
: undef; |
116
|
|
|
|
|
|
|
if ( not defined $archtype ) { |
117
|
|
|
|
|
|
|
_error( 'System type unknown - must be 32- or 64-bit', $library ); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
my $tar_name = "$library.$archname.$archtype.tar"; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my $archiv; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# --- Archiv-Datei aus 'PerlApp' laden -------------------------------------- |
124
|
|
|
|
|
|
|
no warnings; |
125
|
|
|
|
|
|
|
if ( defined $PerlApp::BUILD ) { |
126
|
|
|
|
|
|
|
$archiv = PerlApp::extract_bound_file($tar_name); |
127
|
|
|
|
|
|
|
if ( not defined $archiv ) { |
128
|
|
|
|
|
|
|
_error( "Library '$archiv' not boundet", $library ); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# --- Archiv-Datei im Installations-Pfad suchen ----------------------------- |
133
|
|
|
|
|
|
|
else { |
134
|
|
|
|
|
|
|
foreach my $lib (@INC) { |
135
|
|
|
|
|
|
|
$archiv |
136
|
|
|
|
|
|
|
= File::Spec->catfile( $lib, qw(Tkx TclTk Bind TAR), $tar_name ); |
137
|
|
|
|
|
|
|
last if ( -e $archiv ); |
138
|
|
|
|
|
|
|
$archiv = undef; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
if ( not defined $archiv ) { |
141
|
|
|
|
|
|
|
_error( "Library '$tar_name' not found", $library ); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
use warnings; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# --- Archiv-Datei in TEMP-Verzeichnis entpacken ---------------------------- |
147
|
|
|
|
|
|
|
my $tar = Archive::Tar->new(); |
148
|
|
|
|
|
|
|
$tar->read($archiv); |
149
|
|
|
|
|
|
|
my @entries = $tar->list_files; |
150
|
|
|
|
|
|
|
foreach my $entry (@entries) { |
151
|
|
|
|
|
|
|
my $target = File::Spec->catfile( $TEMP_DIR, $entry ); |
152
|
|
|
|
|
|
|
if ( $entry =~ /[\/]$/ismx ) { |
153
|
|
|
|
|
|
|
if ( not -e $target ) { |
154
|
|
|
|
|
|
|
mkdir $target, $CONST_UMASK |
155
|
|
|
|
|
|
|
or _error( "Can't create directory\n$target", $library ); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
else { |
159
|
|
|
|
|
|
|
my $file = $tar->get_content($entry); |
160
|
|
|
|
|
|
|
open my $FH, '>', $target or _error( "Can't open\n$target", $library ); |
161
|
|
|
|
|
|
|
binmode $FH; |
162
|
|
|
|
|
|
|
print {$FH} $file or _error( "Can't print\n$target", $library ); |
163
|
|
|
|
|
|
|
close $FH or _error( "Can't close\n$target", $library ); |
164
|
|
|
|
|
|
|
chmod $CONST_UMASK, $target; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
push @PACKAGES, @package; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
return $TEMP_DIR; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
} # end of sub load_library |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# ############################################################################## |
175
|
|
|
|
|
|
|
# # P R I V A T E -- S U B S # |
176
|
|
|
|
|
|
|
# ############################################################################## |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub _error { |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
my ( $error_text, $library ) = @ARG; |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Tkx::package_require('BWidget'); |
183
|
|
|
|
|
|
|
my $error_window = Tkx::widget->new(q{.}); |
184
|
|
|
|
|
|
|
my $return = $error_window->new_MessageDlg( |
185
|
|
|
|
|
|
|
-title => "Tkx::TclTk::Bind::$library", |
186
|
|
|
|
|
|
|
-message => $error_text, |
187
|
|
|
|
|
|
|
-icon => 'error', |
188
|
|
|
|
|
|
|
-buttons => ['Cancel'], |
189
|
|
|
|
|
|
|
-font => 'TkCaptionFont', |
190
|
|
|
|
|
|
|
-width => 500, |
191
|
|
|
|
|
|
|
); |
192
|
|
|
|
|
|
|
Tkx::destroy($error_window); |
193
|
|
|
|
|
|
|
exit; |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
} # end of sub _error |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# ############################################################################## |
198
|
|
|
|
|
|
|
# # E N D E # |
199
|
|
|
|
|
|
|
# ############################################################################## |
200
|
|
|
|
|
|
|
1; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
__END__ |