root/honeyclient/branches/exp/xkovah-priority_interrupt/create_pkg_makefile.pl

Revision 783, 1.8 kB (checked in by kindlund, 1 year ago)

Added CVS tags to all scripts. Added initial uninstall script.

  • Property svn:keywords set to Id "$file"
Line 
1 #!/usr/bin/perl
2
3 # $Id$
4
5 # Remember to add $name to this, or else it will not work
6 use warnings;
7 use strict;
8
9 use File::Spec 0.82;
10 use lib File::Spec->catdir('lib');
11 use lib File::Spec->catdir('t','lib');
12 use File::Find;
13
14 my %requires;
15 my $package;
16 my $name = $ARGV[0];
17 open(FILE,'>Makefile.PL');
18
19 sub process{
20     if( /\.pm$/ ){
21         open TEMP, "<", $_;
22         foreach (grep( /^use /, <TEMP> )){
23             my @elements = split;
24             my $name = $elements[1];
25             unless( $name =~ /strict|warnings|\d\.\d+|$package/ ){
26                 $name =~ s/;//;
27                 my $version =
28                     (/(\b[\d\.]+)\b/) &&
29                     (!defined($requires{$name}) ||
30                      $requires{$name} == 0) ?   
31                     "$1":0;   
32                 $requires{$name} = $version;
33             }
34         }
35     }
36 }
37
38 sub get_dependencies{
39     $package = shift;
40     find(\&process,'lib');
41     foreach( sort keys %requires){
42         printf FILE "requires\t'%s' => '%s';\n",$_,$requires{$_};
43     }
44 }
45
46 my @name = split(/-/,$name);
47
48 print   FILE "# Load the Module::Install bundled in ./inc/\n";
49 printf  FILE "%s;\n\n","use inc::Module::Install";
50 print   FILE "# Define metadata\n";
51 printf  FILE "%s\t\t'%s';\n","name",join("-",@name);
52 print   FILE "license\t\t'gpl';\n";
53 print   FILE "perl_version\t'5.006';\n";
54 print   FILE "author\t\t'MITRE Honeyclient Project <honeyclient\@mitre.org>';\n";
55
56
57 my $file = 'lib/'.join("/",@name).'.pm';
58 if( -f $file ){
59     printf  FILE "%s\t\t'%s';\n","all_from",'lib/'.join("/",@name).'.pm';
60 }else{
61     print   FILE "version\t\t'0.01';\n";
62 }
63 print   FILE "clean_files\t't/';\n";
64 print   FILE "\n";
65 get_dependencies(join("::",@name));
66 print   FILE "\n";
67 print   FILE "no_index\t'directory' => 'etc';\n";
68 print   FILE "no_index\t'directory' => 'inc';\n";
69 print   FILE "no_index\t'directory' => 'thirdparty';\n";
70 print   FILE "\n";
71 print   FILE "auto_install;\n";
72 print   FILE "WriteAll;\n";
73
Note: See TracBrowser for help on using the browser.