-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmakeppd.pl
74 lines (57 loc) · 2 KB
/
makeppd.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#makeppd.pl 2.0
use FileHandle;
use File::DosGlob qw(bsd_glob);
#use Win32::FileOp;
use Config;
$make=$Config{make};
my $has_xs = 0;
system('perl Makefile.PL');
system($make) and die "Failed to make!\n";
system($make, 'dist'); # this creates the ordinary distribution
# I need the archive to find the version number!
# If you comment this out, always copy the archive to current directory.
# this part of code finds the latest distribution, I don't have time to
# explore how to find the version number
@archives = grep {!/-PPM\.tar\.gz$/i} bsd_glob('*.tar.gz');
$archive = findNewest (@archives);
($name = $archive) =~ s/\.tar\.gz$//;
($module = $name) =~ s/-[\d.]+$//;
($file = $module) =~ s/^.*-(.*?)$/$1/;
$ppd = $module.".ppd";
$module =~ s/-/\\/g;
print "Module name : $file\n";
print "Newest archive is $archive\n";
system('perl','Makefile.PL', "BINARY_LOCATION=$name-PPM.tar.gz");
#system($make, 'ppd');
# you may do something like
system($make, 'ppd', "BINARY_LOCATION=$name-PPM.tar.gz");
# if you do not apply my patch to ExtUtils\MM_Unix.pm
system("tar cvf $name-PPM.tar blib");
system("gzip --best $name-PPM.tar");
#Delete qw(blib pod2html-dircache pod2html-itemcache pm_to_blib pod2htmd.x~~ pod2htmi.x~~);
if (! $has_xs) {
open $PPD, "<$ppd" or die "Can't open the $ppd file: $!\n";
open $NEWPPD, ">$ppd.tmp" or die "Can't create the $ppd.tmp file: $!\n";
while (<$PPD>) {
next if (/<ARCHITECTURE/);
print $NEWPPD $_;
}
close $PPD; close $NEWPPD;
unlink $ppd;
rename $ppd.'.tmp' => $ppd;
}
exit;
#==================
sub findNewest {
my $maxitem;
my $maxver = pack('C4',0,0,0,0);
foreach my $item (@_) {
$item =~ /-(\d+)\.(\d+)\.(?:(\d+)\.(?:(\d+)\.)?)?tar\.gz/;
my $ver = pack('C4',$1,$2,$3,$4);
if ($ver gt $maxver) {
$maxver = $ver;
$maxitem = $item;
}
}
return $maxitem;
}