Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / script / make_ppm.pl
1 #!/usr/bin/perl -w
2 #############################################################################
3 ## Name:        script/make_ppm.pl
4 ## Purpose:     builds the Wx and Wx-dev PPMs
5 ## Author:      Mattia Barbon
6 ## Modified by:
7 ## Created:     25/08/2003
8 ## RCS-ID:      $Id: make_ppm.pl 2089 2007-07-21 12:10:50Z mbarbon $
9 ## Copyright:   (c) 2003, 2006-2007 Mattia Barbon
10 ## Licence:     This program is free software; you can redistribute it and/or
11 ##              modify it under the same terms as Perl itself
12 #############################################################################
13
14 use strict;
15 use File::Find;
16 use Archive::Tar 0.23;
17 use Module::Info;
18 use Config;
19
20 find( { wanted => \&wanted,
21       },
22       'blib' );
23
24 my @files;
25
26 sub wanted {
27   return unless -f $_;
28   push @files, $File::Find::name;
29 }
30
31 my( @dev, @bin );
32
33 foreach ( @files ) {
34   if( m[\.(?:lib|a|h)$]i
35       ) {
36     push @dev, $_;
37     next;
38   }
39
40   push @bin, $_;
41 }
42
43 my $auth   = 'Mattia Barbon <mbarbon@cpan.org>';
44 my $wx_ver = Module::Info->new_from_file( 'Wx.pm' )->version;
45
46 my @ppms =
47   ( { files    => [ @bin ],
48       package  => 'Wx',
49       version  => $wx_ver,
50       abstract => 'perl interface to the wxWigdets GUI library',
51       author   => $auth,
52     },
53     { files    => [ @dev ],
54       package  => 'Wx-dev',
55       version  => $wx_ver,
56       abstract => 'developement files for wxPerl',
57       author   => $auth,
58     },
59   );
60
61 foreach my $ppm ( @ppms ) {
62   make_ppm( %$ppm );
63 }
64
65 sub make_ppm {
66   my %data = @_;
67   my $tar = Archive::Tar->new;
68   my $pack_ver = join ",", (split (/\./, $data{version}), (0) x 4) [0 .. 3];
69   my $author = $data{author}; $author =~ s/</&lt;/g; $author =~ s/>/&gt;/g;
70   my $arch = $Config{archname} . ( $] >= 5.008 ? '-5.8' : '' );
71   my $base = $data{package} . '-' . $data{version};
72   my $tarfile = "$base-ppm.tar.gz";
73   my $ppdfile = "$base.ppd";
74   my $ppd = <<EOT;
75 <SOFTPKG NAME="$data{package}" VERSION="$pack_ver">
76         <TITLE>$data{package}</TITLE>
77         <ABSTRACT>$data{abstract}</ABSTRACT>
78         <AUTHOR>$author</AUTHOR>
79         <IMPLEMENTATION>
80                 <OS NAME="$^O" />
81                 <ARCHITECTURE NAME="$arch" />
82                 <CODEBASE HREF="$tarfile" />
83         </IMPLEMENTATION>
84 </SOFTPKG>
85 EOT
86
87   $tar->add_files( @{$data{files}} );
88   $tar->write( $tarfile, 9 );
89
90   local *PPD;
91   open PPD, "> $ppdfile" or die "open '$ppdfile': $!";
92   binmode PPD;
93   print PPD $ppd;
94   close PPD;
95 }
96
97 exit 0;