| 1 | package Glade::PerlSource; | ||
| 2 | 1 | ▶ | require 5.000; use strict 'vars', 'refs', 'subs'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | # Copyright (c) 1999 Dermot Musgrove <dermot.musgrove@virgin.net> | ||
| 5 | # | ||
| 6 | # This library is released under the same conditions as Perl, that | ||
| 7 | # is, either of the following: | ||
| 8 | # | ||
| 9 | # a) the GNU General Public License as published by the Free | ||
| 10 | # Software Foundation; either version 1, or (at your option) any | ||
| 11 | # later version. | ||
| 12 | # | ||
| 13 | # b) the Artistic License. | ||
| 14 | # | ||
| 15 | # If you use this library in a commercial enterprise, you are invited, | ||
| 16 | # but not required, to pay what you feel is a reasonable fee to perl.org | ||
| 17 | # to ensure that useful software is available now and in the future. | ||
| 18 | # | ||
| 19 | # (visit http://www.perl.org/ or email donors@perlmongers.org for details) | ||
| 20 | |||
| 21 | BEGIN { | ||
| 22 | 1 | ▶ | use Data::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | 1 | ▶ | use File::Copy; # for copying generated files |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | 0 | ▶ | use Glade::PerlRun qw( :METHODS :VARS !&_); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 25 | # Our run-time methods and vars | ||
| 26 | # but not &_ since we do that ourselves. | ||
| 27 | use File::Basename qw( basename ); # in check_gettext_strings | ||
| 28 | use Text::Wrap qw( wrap $columns ); # in write_gettext_strings | ||
| 29 | use File::Path qw( mkpath ); # in use_Glade_Project | ||
| 30 | use subs qw( | ||
| 31 | _ | ||
| 32 | start_checking_gettext_strings | ||
| 33 | ); | ||
| 34 | use vars qw( | ||
| 35 | @ISA | ||
| 36 | $PACKAGE $VERSION $AUTHOR $DATE | ||
| 37 | %fields %stubs | ||
| 38 | @EXPORT @EXPORT_OK %EXPORT_TAGS | ||
| 39 | @VARS @METHODS | ||
| 40 | $PARTYPE $LOOKUP $BOOL $DEFAULT $KEYSYM $LOOKUP_ARRAY | ||
| 41 | |||
| 42 | $widgets | ||
| 43 | $data | ||
| 44 | $forms | ||
| 45 | $work | ||
| 46 | |||
| 47 | $handlers | ||
| 48 | $need_handlers | ||
| 49 | $autosubs | ||
| 50 | $subs | ||
| 51 | |||
| 52 | $radiobuttons | ||
| 53 | $radiomenuitems | ||
| 54 | $current_data | ||
| 55 | $current_name | ||
| 56 | $current_form | ||
| 57 | $current_form_name | ||
| 58 | $current_window | ||
| 59 | $first_form | ||
| 60 | $init_string | ||
| 61 | ); | ||
| 62 | $PACKAGE = __PACKAGE__; | ||
| 63 | $VERSION = q(0.61); | ||
| 64 | $AUTHOR = q(Dermot Musgrove <dermot.musgrove@virgin.net>); | ||
| 65 | $DATE = q(Sun Nov 17 03:21:11 GMT 2002); | ||
| 66 | @VARS = qw( | ||
| 67 | $PARTYPE $LOOKUP $BOOL $DEFAULT $KEYSYM $LOOKUP_ARRAY | ||
| 68 | |||
| 69 | $Glade_Perl | ||
| 70 | $widgets | ||
| 71 | $data | ||
| 72 | $forms | ||
| 73 | $work | ||
| 74 | |||
| 75 | $handlers | ||
| 76 | $need_handlers | ||
| 77 | $autosubs | ||
| 78 | $subs | ||
| 79 | $convert | ||
| 80 | @use_modules | ||
| 81 | $NOFILE | ||
| 82 | $indent | ||
| 83 | $tab | ||
| 84 | |||
| 85 | $radiobuttons | ||
| 86 | $radiomenuitems | ||
| 87 | $current_data | ||
| 88 | $current_name | ||
| 89 | $current_form | ||
| 90 | $current_form_name | ||
| 91 | $current_window | ||
| 92 | $first_form | ||
| 93 | $init_string | ||
| 94 | ); | ||
| 95 | @METHODS = qw( | ||
| 96 | _ | ||
| 97 | S_ | ||
| 98 | D_ | ||
| 99 | missing_handler | ||
| 100 | ); | ||
| 101 | $subs = ''; | ||
| 102 | $autosubs = ' destroy_Form about_Form '. | ||
| 103 | ' toplevel_hide toplevel_close toplevel_destroy '; | ||
| 104 | $LOOKUP = 2; | ||
| 105 | $BOOL = 4; | ||
| 106 | $DEFAULT = 8; | ||
| 107 | $KEYSYM = 16; | ||
| 108 | $LOOKUP_ARRAY = 32; | ||
| 109 | # Tell interpreter who we are inheriting from | ||
| 110 | @ISA = qw( Exporter Glade::PerlRun ); | ||
| 111 | # These symbols (globals and functions) are always exported | ||
| 112 | @EXPORT = qw( ); | ||
| 113 | # Optionally exported package symbols (globals and functions) | ||
| 114 | @EXPORT_OK = ( @VARS, @METHODS ); | ||
| 115 | # Tags (groups of symbols) to export | ||
| 116 | %EXPORT_TAGS = ( 'METHODS' => [@METHODS], | ||
| 117 | 'VARS' => [@VARS] ); | ||
| 118 | } | ||
| 119 | |||
| 120 | %fields = ( | ||
| 121 | # Insert any extra data access methods that you want to add to | ||
| 122 | # our inherited super-constructor (or overload) | ||
| 123 | USERDATA => undef, | ||
| 124 | ); | ||
| 125 | |||
| 126 | sub DESTROY { | ||
| 127 | # This sub will be called on object destruction | ||
| 128 | } # End of sub DESTROY | ||
| 129 | |||
| 130 | #=============================================================================== | ||
| 131 | #=========== Utilities to write output file ============ | ||
| 132 | #=============================================================================== | ||
| 133 | sub Stop_Writing_to_File { shift->Write_to_File('-1') } | ||
| 134 | |||
| 135 | sub Write_to_File { | ||
| 136 | my ($class) = @_; | ||
| 137 | my $me = __PACKAGE__."::Write_to_File"; | ||
| 138 | my $filename = $class->source->write; | ||
| 139 | if (fileno UI or fileno SIGS or fileno SUBCLASS or | ||
| 140 | $class->Building_UI_only) { | ||
| 141 | # Files are already open or we are not writing source | ||
| 142 | if ($class->Writing_to_File) { | ||
| 143 | if ($filename eq '-1') { | ||
| 144 | close UI; | ||
| 145 | close SUBCLASS; | ||
| 146 | close SIGS; | ||
| 147 | $class->diag_print (2, "%s- Closing output file in %s", | ||
| 148 | $indent, $me); | ||
| 149 | $class->source->write(undef); | ||
| 150 | } else { | ||
| 151 | $class->diag_print (2, "%s- Already writing to %s in %s", | ||
| 152 | $indent, $class->Writing_to_File, $me); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | } elsif ($filename && ($filename eq '1')) { | ||
| 157 | $class->diag_print (3, "%s- Using default output files ". | ||
| 158 | "in Glade <project><source_directory> in %s", | ||
| 159 | $indent, $me); | ||
| 160 | |||
| 161 | } elsif ($filename && ($filename ne '-1') ) { | ||
| 162 | # We want to write source | ||
| 163 | if ($filename eq 'STDOUT') { | ||
| 164 | $class->source->write('>&STDOUT'); | ||
| 165 | } | ||
| 166 | $class->diag_print (2, "%s- Writing %s source to %s - in %s", | ||
| 167 | $indent, 'UI ', $filename, $me); | ||
| 168 | open UI, ">$filename" or | ||
| 169 | die sprintf(( | ||
| 170 | "error %s - can't open file '%s' for output"), | ||
| 171 | $me, $filename); | ||
| 172 | $class->diag_print (2, "%s- Writing %s source to %s - in %s", | ||
| 173 | $indent, 'SUBS', $filename, $me); | ||
| 174 | open SIGS, ">$filename" or | ||
| 175 | die sprintf(( | ||
| 176 | "error %s - can't open file '%s' for output"), | ||
| 177 | $me, $filename); | ||
| 178 | $class->diag_print (2, "%s- Writing %s source to %s - in %s", | ||
| 179 | $indent, 'SUBCLASS', $filename, $me); | ||
| 180 | open SUBCLASS, ">$filename" or | ||
| 181 | die sprintf(( | ||
| 182 | "error %s - can't open file '%s' for output"), | ||
| 183 | $me, $filename); | ||
| 184 | UI->autoflush(1); | ||
| 185 | SIGS->autoflush(1); | ||
| 186 | SUBCLASS->autoflush(1); | ||
| 187 | } else { | ||
| 188 | # Nothing to do | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | sub add_to_UI { | ||
| 193 | my ($class, $depth, $expr, $tofileonly, $notabs) = @_; | ||
| 194 | my $me = "$class->add_to_UI"; | ||
| 195 | my $mydebug = ($Glade_Perl->verbosity >= 6); | ||
| 196 | if ($depth < 0) { | ||
| 197 | $mydebug = 1; | ||
| 198 | $depth = -$depth; | ||
| 199 | } | ||
| 200 | if ($Glade_Perl->Writing_to_File) { | ||
| 201 | my $UI_String = ($indent x ($depth)).$expr; | ||
| 202 | if (!$notabs && $tab) { | ||
| 203 | # replace multiple spaces with tabs | ||
| 204 | $UI_String =~ s/$tab/\t/g; | ||
| 205 | } | ||
| 206 | eval "push \@{${current_form}\{'UI_Strings'}}, \$UI_String"; | ||
| 207 | } | ||
| 208 | unless ($Glade_Perl->source->quick_gen or $tofileonly) { | ||
| 209 | eval $expr or | ||
| 210 | ($@ && die "\n\nin $me\n\twhile trying to eval". | ||
| 211 | "'$expr'\n\tFAILED with Eval error '$@'\n"); | ||
| 212 | } | ||
| 213 | if ($mydebug) { | ||
| 214 | $expr =~ s/\%/\%\%/g; | ||
| 215 | $Glade_Perl->diag_print (2, "UI%s'%s'", $indent, $expr); | ||
| 216 | } | ||
| 217 | } | ||
| 218 | |||
| 219 | #=============================================================================== | ||
| 220 | #=========== Documentation files | ||
| 221 | #=============================================================================== | ||
| 222 | sub write_documentation { | ||
| 223 | my ($class, $force) = @_; | ||
| 224 | return unless $class->doc->write; | ||
| 225 | my $me = __PACKAGE__."::write_documentation"; | ||
| 226 | my ($string, $file); | ||
| 227 | my $count = 0; | ||
| 228 | |||
| 229 | $class->doc->directory($class->full_Path( | ||
| 230 | $class->doc->directory, $class->glade->directory)); | ||
| 231 | |||
| 232 | if ($class->doc->directory ne $class->glade->directory) { | ||
| 233 | unless (-d $class->doc->directory) { | ||
| 234 | # Source directory does not exist yet so create it | ||
| 235 | $Glade_Perl->diag_print (2, "%s- Creating documentation directory '%s' in %s", | ||
| 236 | $indent, $class->doc->directory, $me); | ||
| 237 | mkpath($class->doc->directory ); | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | for $file (sort keys %{$class->doc}) { | ||
| 242 | next unless $force || $class->doc->{$file}; | ||
| 243 | unless ("*$permitted_fields*directory*write*" =~ /\*$file\*/) { | ||
| 244 | $class->doc->{$file} = $class->full_Path( | ||
| 245 | $class->doc->{$file}, | ||
| 246 | $class->doc->directory); | ||
| 247 | if ($force || !-f $class->doc->{$file}) { | ||
| 248 | $class->diag_print(2, "%s- Generating documentation file '%s'", | ||
| 249 | $class->source->indent, $class->doc->{$file}); | ||
| 250 | eval "\$string = \$class->dist_$file"; | ||
| 251 | $class->save_file_from_string($class->doc->{$file}, $string); | ||
| 252 | $count++; | ||
| 253 | if ($class->verbosity >= 4) { | ||
| 254 | print "-----------------------------\n". | ||
| 255 | "$string\n-----------------------------\n"; | ||
| 256 | } | ||
| 257 | } | ||
| 258 | } | ||
| 259 | } | ||
| 260 | return $count; | ||
| 261 | } | ||
| 262 | |||
| 263 | sub dist_COPYING { | ||
| 264 | my ($class) = @_; | ||
| 265 | return $Glade_Perl->app->copying; | ||
| 266 | } | ||
| 267 | |||
| 268 | sub dist_Changelog { | ||
| 269 | my ($class) = @_; | ||
| 270 | return "Revision history for Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 271 | -------------------------------------------------------------------- | ||
| 272 | |||
| 273 | ".$class->glade2perl->start_time." - ".$class->app->author." | ||
| 274 | ".$class->source->indent."- version ".$class->app->version. | ||
| 275 | " - This file was created by ".__PACKAGE__."\n"; | ||
| 276 | } | ||
| 277 | |||
| 278 | sub dist_FAQ { | ||
| 279 | my ($class) = @_; | ||
| 280 | return "Frequently Asked Questions about Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 281 | -------------------------------------------------------------------- | ||
| 282 | |||
| 283 | |||
| 284 | ".$class->glade2perl->start_time." - ".$class->app->author." | ||
| 285 | ".$class->source->indent."- version ".$class->app->version. | ||
| 286 | " - This file was created by ".__PACKAGE__."\n"; | ||
| 287 | } | ||
| 288 | |||
| 289 | sub dist_INSTALL { | ||
| 290 | my ($class) = @_; | ||
| 291 | return "How to install Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 292 | -------------------------------------------------------------------- | ||
| 293 | |||
| 294 | TO INSTALL | ||
| 295 | ---------- | ||
| 296 | There is a standard Makefile.PL to handle some checks and install the package | ||
| 297 | |||
| 298 | To install | ||
| 299 | perl Makefile.PL | ||
| 300 | make | ||
| 301 | make test | ||
| 302 | su | ||
| 303 | make install (if test was OK) | ||
| 304 | |||
| 305 | TO BUILD RPMS | ||
| 306 | ------------- | ||
| 307 | Build the RPMs by calling eg. | ||
| 308 | rpm -ta ".$class->app->name."-".$class->app->version.".tar.gz | ||
| 309 | |||
| 310 | |||
| 311 | ".$class->glade2perl->start_time." - ".$class->app->author." | ||
| 312 | ".$class->source->indent."- version ".$class->app->version. | ||
| 313 | " - This file was created by ".__PACKAGE__." | ||
| 314 | "; | ||
| 315 | } | ||
| 316 | |||
| 317 | sub dist_NEWS { | ||
| 318 | my ($class) = @_; | ||
| 319 | return "NEWS about Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 320 | -------------------------------------------------------------------- | ||
| 321 | |||
| 322 | |||
| 323 | ".$class->glade2perl->start_time." - ".$class->app->author." | ||
| 324 | ".$class->source->indent."- version ".$class->app->version. | ||
| 325 | " - This file was created by ".__PACKAGE__."\n"; | ||
| 326 | } | ||
| 327 | |||
| 328 | sub dist_README { | ||
| 329 | my ($class) = @_; | ||
| 330 | return "Introduction to Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 331 | -------------------------------------------------------------------- | ||
| 332 | |||
| 333 | ".$class->app->description." | ||
| 334 | |||
| 335 | |||
| 336 | ".$class->glade2perl->start_time." - ".$class->app->author." | ||
| 337 | ".$class->source->indent."- version ".$class->app->version. | ||
| 338 | " - This file was created by ".__PACKAGE__." | ||
| 339 | "; | ||
| 340 | } | ||
| 341 | |||
| 342 | sub dist_ROADMAP { | ||
| 343 | my ($class) = @_; | ||
| 344 | return "ROADMAP for Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 345 | -------------------------------------------------------------------- | ||
| 346 | |||
| 347 | |||
| 348 | ".$class->glade2perl->start_time." - ".$class->app->author." | ||
| 349 | ".$class->source->indent."- version ".$class->app->version. | ||
| 350 | " - This file was created by ".__PACKAGE__."\n"; | ||
| 351 | } | ||
| 352 | |||
| 353 | sub dist_TODO { | ||
| 354 | my ($class) = @_; | ||
| 355 | return "Things to do for Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 356 | -------------------------------------------------------------------- | ||
| 357 | |||
| 358 | |||
| 359 | ".$class->glade2perl->start_time." - ".$class->app->author." | ||
| 360 | ".$class->source->indent."- version ".$class->app->version. | ||
| 361 | " - This file was created by ".__PACKAGE__."\n"; | ||
| 362 | } | ||
| 363 | |||
| 364 | #=============================================================================== | ||
| 365 | #=========== Distribution files | ||
| 366 | #=============================================================================== | ||
| 367 | sub write_distribution { | ||
| 368 | my ($class, $force) = @_; | ||
| 369 | return unless $class->dist->write; | ||
| 370 | my $me = __PACKAGE__."::write_distribution"; | ||
| 371 | my ($string, $file); | ||
| 372 | my $exec_mode = 0755; | ||
| 373 | my $count = 0; | ||
| 374 | |||
| 375 | $class->dist->spec($class->full_Path( | ||
| 376 | ($class->dist->spec || $class->app->name.".spec"), | ||
| 377 | $class->glade->directory)); | ||
| 378 | |||
| 379 | for $file (sort keys %{$class->dist}) { | ||
| 380 | next unless $force || $class->dist->{$file}; | ||
| 381 | unless ("*$permitted_fields*directory*write*type*compress*scripts*docs*bin_directory*test_directory*" =~ /\*$file\*/) { | ||
| 382 | if ($force || !-f $class->dist->{$file}) { | ||
| 383 | $class->diag_print(2, "%s- Generating distribution file '%s'", | ||
| 384 | $class->source->indent, $class->dist->{$file}); | ||
| 385 | eval "\$string = \$class->dist_$file"; | ||
| 386 | if ($class->verbosity >= 4) { | ||
| 387 | print "----------------------------- $file\n". | ||
| 388 | "$string\n". | ||
| 389 | "-----------------------------\n"; | ||
| 390 | } | ||
| 391 | $class->save_file_from_string($class->dist->{$file}, $string); | ||
| 392 | $count++; | ||
| 393 | if ('*test_pl*bin*' =~ /\*$file\*/) { | ||
| 394 | chmod $exec_mode, $class->dist->{$file}; | ||
| 395 | } | ||
| 396 | } | ||
| 397 | } | ||
| 398 | } | ||
| 399 | return $count; | ||
| 400 | } | ||
| 401 | |||
| 402 | sub dist_MANIFEST_SKIP { | ||
| 403 | my ($class) = @_; | ||
| 404 | |||
| 405 | my $string = "\\bRCS\\b | ||
| 406 | ^MANIFEST\\. | ||
| 407 | ^Makefile\$ | ||
| 408 | \~\$ | ||
| 409 | \.html\$ | ||
| 410 | \.old\$ | ||
| 411 | ^blib/ | ||
| 412 | ^MakeMaker-\\d | ||
| 413 | pod2html | ||
| 414 | .bak\$ | ||
| 415 | SIGS.pm | ||
| 416 | "; | ||
| 417 | $string .= "\^".(basename $class->glade->file)."\n"; | ||
| 418 | if ($class->glade->proto->{project}{output_translatable_strings}) { | ||
| 419 | $string .= "\^".$class->glade->proto->{project}{translatable_strings_file}; | ||
| 420 | }; | ||
| 421 | return $string; | ||
| 422 | } | ||
| 423 | |||
| 424 | sub dist_Makefile_PL { | ||
| 425 | my ($class) = @_; | ||
| 426 | |||
| 427 | my $name = $class->module->directory; | ||
| 428 | $name =~ s|^$class->{dist}{directory}||; | ||
| 429 | $name =~ s|^/||; | ||
| 430 | |||
| 431 | my $ui_file = $class->module->ui->file; | ||
| 432 | $ui_file =~ s|^$class->{dist}{directory}||; | ||
| 433 | $ui_file =~ s|^/||; | ||
| 434 | |||
| 435 | return "# | ||
| 436 | # Makefile.PL for ".$class->app->name." | ||
| 437 | #".$class->source->indent."- version ".$class->app->version. | ||
| 438 | " - This file was created by ".__PACKAGE__." | ||
| 439 | # | ||
| 440 | require 5.000; | ||
| 441 | use ExtUtils::MakeMaker; | ||
| 442 | use strict; | ||
| 443 | |||
| 444 | #--- Configuration section --- | ||
| 445 | |||
| 446 | my \@programs_to_install = qw(".$class->dist->scripts."); | ||
| 447 | |||
| 448 | my \@need_perl_modules = ( | ||
| 449 | # Check for Gtk::Types rather than the Gtk supermodule | ||
| 450 | # this avoids dumping MakeMaker | ||
| 451 | {'name' => 'Gtk', | ||
| 452 | 'test' => 'Gtk::Types', | ||
| 453 | 'version' => '".$Glade::PerlUI::gtk_perl_depends->{'MINIMUM REQUIREMENTS'}."', | ||
| 454 | 'reason' => \"implements the perl bindings to Gtk+.\\n\". | ||
| 455 | \"The module is called Gtk-Perl on CPAN or \". | ||
| 456 | \"module gnome-perl in the Gnome CVS\"}, | ||
| 457 | |||
| 458 | # Check for Gnome::Types rather than the Gnome supermodule | ||
| 459 | # this avoids dumping MakeMaker | ||
| 460 | {'name' => 'Gnome', | ||
| 461 | 'test' => 'Gnome::Types', | ||
| 462 | 'version' => '".$Glade::PerlUI::gnome_libs_depends->{'MINIMUM REQUIREMENTS'}."', | ||
| 463 | 'reason' => \"implements the perl bindings to Gnome.\\n\". | ||
| 464 | \"It is a submodule of the Gtk-Perl package and needs to be built separately.\\n\". | ||
| 465 | \"Read the Gtk-Perl INSTALL file for details of how to do this.\\n\". | ||
| 466 | \"Glade-Perl will still work but you will not be able to \\n\". | ||
| 467 | \"use any Gnome widgets in your Glade projects\"}, | ||
| 468 | ); | ||
| 469 | #--- End Configuration - You should not have to change anything below this line | ||
| 470 | |||
| 471 | # Allow us to suppress all program installation with the -n (library only) | ||
| 472 | # option. This is for those that don't want to mess with the configuration | ||
| 473 | # section of this file. | ||
| 474 | use Getopt::Std; | ||
| 475 | use vars qw(\$opt_n); | ||
| 476 | unless (getopts(\"n\")) { | ||
| 477 | die \"Usage: \$0 [-n]\\n\"; | ||
| 478 | } | ||
| 479 | \@programs_to_install = () if \$opt_n; | ||
| 480 | |||
| 481 | # Check for non-standard modules that are used by this library. | ||
| 482 | \$| = 1; # autoflush on | ||
| 483 | my \$missing_modules = 0; | ||
| 484 | |||
| 485 | foreach my \$mod (\@need_perl_modules) { | ||
| 486 | print \"Checking for \$mod->{'name'}..\"; | ||
| 487 | eval \"require \$mod->{'test'}\"; | ||
| 488 | if (\$@) { | ||
| 489 | \$missing_modules++; | ||
| 490 | print \" failed\\n\"; | ||
| 491 | print \"-------------------------------------------------------\". | ||
| 492 | \"\\n\$\@\\n\", | ||
| 493 | \"\$mod->{'name'} is needed, it \$mod->{'reason'}\\n\", | ||
| 494 | \"We need at least version \$mod->{'version'}\\n\". | ||
| 495 | \"-------------------------------------------------------\\n\"; | ||
| 496 | sleep(2); # Don't hurry too much | ||
| 497 | } else { | ||
| 498 | print \" ok\\n\"; | ||
| 499 | } | ||
| 500 | } | ||
| 501 | |||
| 502 | #-------------------------------------- | ||
| 503 | print \"------------------------------------------------------- | ||
| 504 | The missing modules can be obtained from CPAN. Visit | ||
| 505 | <URL:http://www.perl.com/CPAN/> to find a CPAN site near you. | ||
| 506 | -------------------------------------------------------\\n\\n\" | ||
| 507 | if \$missing_modules; | ||
| 508 | |||
| 509 | #-------------------------------------- | ||
| 510 | # Last of all generate the Makefile | ||
| 511 | WriteMakefile( | ||
| 512 | 'DISTNAME' => '".$class->app->name."', | ||
| 513 | 'NAME' => '$name', | ||
| 514 | 'VERSION_FROM' => '$ui_file', | ||
| 515 | 'EXE_FILES' => [ \@programs_to_install ], | ||
| 516 | 'clean' => { FILES => '\$(EXE_FILES)' }, | ||
| 517 | 'dist' => { COMPRESS => 'gzip', SUFFIX => 'gz' } | ||
| 518 | ); | ||
| 519 | |||
| 520 | package MY; | ||
| 521 | |||
| 522 | # Pass Glade-Perl version number to pod2man | ||
| 523 | sub manifypods | ||
| 524 | { | ||
| 525 | my \$self = shift; | ||
| 526 | my \$ver = \$self->{'VERSION'} || \"\"; | ||
| 527 | local(\$_) = \$self->SUPER::manifypods(\@_); | ||
| 528 | s/pod2man\\s*\$/pod2man --release ".$class->app->name."-\$ver/m; | ||
| 529 | \$_; | ||
| 530 | } | ||
| 531 | |||
| 532 | exit(0); | ||
| 533 | |||
| 534 | # End of Makefile.PL | ||
| 535 | "; | ||
| 536 | } | ||
| 537 | |||
| 538 | sub dist_spec { | ||
| 539 | my ($class) = @_; | ||
| 540 | my $docs; | ||
| 541 | if ($class->dist->docs) { | ||
| 542 | $docs = $class->dist->docs; | ||
| 543 | } else { | ||
| 544 | $docs = $class->doc->directory; | ||
| 545 | $docs =~ s/^$class->{glade}{directory}//; | ||
| 546 | $docs =~ s/^\///; | ||
| 547 | $docs .= "/*"; | ||
| 548 | } | ||
| 549 | my $rpm_date = `date "+%a %b %d %Y"`; | ||
| 550 | chomp $rpm_date; | ||
| 551 | return "\%define ver ".$class->app->version." | ||
| 552 | \%define rel 1 | ||
| 553 | \%define name ".$class->app->name." | ||
| 554 | \%define rlname \%{name} | ||
| 555 | \%define source0 http://\%{name}-\%{ver}.tar.gz | ||
| 556 | \%define url http:// | ||
| 557 | \%define group Application | ||
| 558 | \%define copy GPL or Artistic | ||
| 559 | \%define filelst \%{name}-\%{ver}-files | ||
| 560 | \%define confdir /etc | ||
| 561 | \%define prefix /usr | ||
| 562 | \%define arch noarch | ||
| 563 | |||
| 564 | Summary: ".$class->app->description." | ||
| 565 | |||
| 566 | Name: \%name | ||
| 567 | Version: \%ver | ||
| 568 | Release: \%rel | ||
| 569 | Copyright: \%{copy} | ||
| 570 | Packager: ".$class->app->author." | ||
| 571 | Source: \%{source0} | ||
| 572 | URL: %{url} | ||
| 573 | Group: \%{group} | ||
| 574 | BuildArch: \%{arch} | ||
| 575 | BuildRoot: /var/tmp/\%{name}-\%{ver} | ||
| 576 | |||
| 577 | \%description | ||
| 578 | ".$class->app->description." | ||
| 579 | |||
| 580 | \%prep | ||
| 581 | \%setup -n \%{rlname}-\%{ver} | ||
| 582 | |||
| 583 | \%build | ||
| 584 | if [ \$(perl -e 'print index(\$INC[0],\"\%{prefix}/lib/perl\");') -eq 0 ];then | ||
| 585 | # package is to be installed in perl root | ||
| 586 | inst_method=\"makemaker-root\" | ||
| 587 | CFLAGS=\$RPM_OPT_FLAGS perl Makefile.PL PREFIX=\%{prefix} | ||
| 588 | else | ||
| 589 | # package must go somewhere else (eg. /opt), so leave off the perl | ||
| 590 | # versioning to ease integration with automatic profile generation scripts | ||
| 591 | # if this is really a perl-version dependant package you should not omiss | ||
| 592 | # the version info... | ||
| 593 | inst_method=\"makemaker-site\" | ||
| 594 | CFLAGS=\$RPM_OPT_FLAGS perl Makefile.PL PREFIX=\%{prefix} LIB=\%{prefix}/lib/perl5 | ||
| 595 | fi | ||
| 596 | |||
| 597 | echo \$inst_method > inst_method | ||
| 598 | |||
| 599 | # get number of processors for parallel builds on SMP systems | ||
| 600 | numprocs=`cat /proc/cpuinfo | grep processor | wc | cut -c7` | ||
| 601 | if [ \"x\$numprocs\" = \"x\" -o \"x\$numprocs\" = \"x0\" ]; then | ||
| 602 | numprocs=1 | ||
| 603 | fi | ||
| 604 | |||
| 605 | make \"MAKE=make -j\$numprocs\" | ||
| 606 | |||
| 607 | \%install | ||
| 608 | rm -rf \$RPM_BUILD_ROOT | ||
| 609 | |||
| 610 | if [ \"\$(cat inst_method)\" = \"makemaker-root\" ];then | ||
| 611 | make UNINST=1 PREFIX=\$RPM_BUILD_ROOT\%{prefix} install | ||
| 612 | elif [ \"\$(cat inst_method)\" = \"makemaker-site\" ];then | ||
| 613 | make UNINST=1 PREFIX=\$RPM_BUILD_ROOT\%{prefix} LIB=\$RPM_BUILD_ROOT\%{prefix}/lib/perl5 install | ||
| 614 | fi | ||
| 615 | |||
| 616 | \%__os_install_post | ||
| 617 | find \$RPM_BUILD_ROOT -type f -print|sed -e \"s\@^\$RPM_BUILD_ROOT\@\@g\" > \%{filelst} | ||
| 618 | |||
| 619 | \%files -f \%{filelst} | ||
| 620 | \%defattr(-, root, root) | ||
| 621 | \%doc $docs | ||
| 622 | |||
| 623 | \%clean | ||
| 624 | rm -rf \$RPM_BUILD_ROOT | ||
| 625 | |||
| 626 | \%changelog | ||
| 627 | * $rpm_date - ".$class->app->author." | ||
| 628 | ".$class->source->indent."This file was created by ".__PACKAGE__."\n"; | ||
| 629 | } | ||
| 630 | |||
| 631 | sub dist_test_pl { | ||
| 632 | my ($class) = @_; | ||
| 633 | my $init_string; | ||
| 634 | if ($class->app->allow_gnome) { | ||
| 635 | $init_string .= "Gnome->init(\"\$PACKAGE\", \"\$VER"."SION\");"; | ||
| 636 | } else { | ||
| 637 | $init_string .= "Gtk->init;"; | ||
| 638 | } | ||
| 639 | |||
| 640 | return "#!/usr/bin/perl | ||
| 641 | #============================================================================== | ||
| 642 | #=== This is a test script | ||
| 643 | #============================================================================== | ||
| 644 | require 5.000; use strict 'vars', 'refs', 'subs'; | ||
| 645 | |||
| 646 | use Test; | ||
| 647 | BEGIN { plan tests => 2 }; | ||
| 648 | |||
| 649 | use ".$class->test->use_module."; | ||
| 650 | ok(1); | ||
| 651 | |||
| 652 | $init_string | ||
| 653 | my \$window = ".$class->test->first_form."->new; | ||
| 654 | ok(\$window->INSTANCE); | ||
| 655 | |||
| 656 | "; | ||
| 657 | } | ||
| 658 | |||
| 659 | sub dist_bin { | ||
| 660 | my ($class) = @_; | ||
| 661 | return "#!/usr/bin/perl | ||
| 662 | #============================================================================== | ||
| 663 | #=== This is a toplevel script | ||
| 664 | #============================================================================== | ||
| 665 | require 5.000; use strict 'vars', 'refs', 'subs'; | ||
| 666 | |||
| 667 | package ".$class->test->first_form."; | ||
| 668 | |||
| 669 | BEGIN { | ||
| 670 | use lib \"./\"; | ||
| 671 | use ".$class->test->use_module."; | ||
| 672 | use vars qw(\@ISA); | ||
| 673 | # use Carp qw(cluck); | ||
| 674 | # \$SIG{__DIE__} = \&Carp::confess; | ||
| 675 | # \$SIG{__WARN__} = \&Carp::cluck; | ||
| 676 | } | ||
| 677 | |||
| 678 | \$Glade::PerlRun::pixmaps_directory = \"".$class->glade->pixmaps_directory."\"; | ||
| 679 | |||
| 680 | select STDOUT; \$| = 1; | ||
| 681 | |||
| 682 | my \%params = ( | ||
| 683 | ); | ||
| 684 | |||
| 685 | __PACKAGE__->app_run(\%params) && exit 0; | ||
| 686 | |||
| 687 | exit 1; | ||
| 688 | |||
| 689 | 1; | ||
| 690 | |||
| 691 | __END__ | ||