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