Skip to content
This repository
tree: 82d208b768
Fetching contributors…

Cannot retrieve contributors at this time

file 106 lines (84 sloc) 2.612 kb
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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
#!/usr/bin/perl

use File::Path;

my $PREFIX = '@BASEPATH@';


if (0) {

my %ps = map { /^\s*(\d+)\s+(.*)/ } `ps -a -opid,ppid,command -ww`;
my($ppid) = $ps{$$} =~ /^(\d+)/;
my($pcmd) = $ps{$ppid} =~ /^\d+\s+(.*)/;
my @dpkg_args = split /\s+/, $pcmd;

print "$pcmd\n", map "\t'$_'\n", @dpkg_args;

my($package, $dpkg_script, $dpkg_mode);
while (defined ($package = shift @dpkg_args)) {
    print "trying $package...\n";
    if ($package =~ s,$PREFIX/var/lib/dpkg/info/(\S+)\.((?:pre|post)(?:inst|rm)),$1,) {
$dpkg_script = $2;
$dpkg_mode = shift @dpkg_args;
last;
    }
}
if (not defined $dpkg_mode) {
die "Could not parse \"$pcmd\"\n";
}

my $fink_type = shift;

print "dpkg script: $dpkg_script\n";
print "dpkg mode : $dpkg_mode\n";
print "dpkg args : @dpkg_args\n";

print "fink script: $fink_type\n";
print "fink args : @ARGV\n";

}

die "usage: $0 <command> <target> [command options]\n" unless (@ARGV >= 2);

my $COMMAND = lc(shift);
my $TARGET = lc(shift);
my $DEBUG = 0;

my $handled = 0;

$DEBUG && debug("command = $COMMAND, target = $TARGET, arguments = '@ARGV'");

if ($TARGET eq "updatepod") {
my $perldirectory = shift;
my $perlarchdir = shift;

my $perllocaldir = $PREFIX . '/lib/perl5' . $perldirectory . '/' . $perlarchdir;
debug("making $perllocaldir directory");
mkpath($perllocaldir);

if ($COMMAND eq "postinst") {
my $podfiledir = $PREFIX . '/share/podfiles' . $perldirectory;

debug("opening $perllocaldir/perllocal.pod for writing");
if (open(FILEOUT, '>' . $perllocaldir . '/perllocal.pod')) {
for my $file (<$podfiledir/*.pod>) {
debug("writing $file to $perllocaldir/perllocal.pod");
if (open (FILEIN, $file)) {
local $/ = undef;
print FILEOUT <FILEIN>;
close(FILEIN);
} else {
warn "unable to add $file to perllocal.pod: $!\n";
}
}
close(FILEOUT);
} else {
warn "unable to write to $perllocaldir/perllocal.pod: $!\n";
}
$handled++;
} elsif ($COMMAND eq "postrm") {
if (-e $PREFIX . '/share/podfiles' . $perldirectory) {
debug("opening $perllocaldir/perllocal.pod for writing");
if (open(FILEOUT, '>' . $perllocaldir . '/perllocal.pod')) {
for my $file (<$PREFIX . '/share/podfiles' . $perldirectory . '/*.pod'>) {
debug("writing $file to $perllocaldir/perllocal.pod");
if (open (FILEIN, $file)) {
local $/ = undef;
print FILEOUT <FILEIN>;
close (FILEIN);
}
}
close (FILEOUT);
}
}
$handled++;
}
}

if (not $handled) {
die "ERROR: unhandled command: $COMMAND $TARGET @ARGV\n";
}

sub debug {
return unless ($DEBUG);

print STDERR @_, "\n";
}
Something went wrong with that request. Please try again.