/[pxelator]/lib/PXElator/upstream.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/upstream.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 138 by dpavlin, Tue Aug 4 15:25:09 2009 UTC revision 147 by dpavlin, Wed Aug 5 13:08:28 2009 UTC
# Line 7  use autodie; Line 7  use autodie;
7  use LWP::Simple qw/mirror RC_NOT_MODIFIED/;  use LWP::Simple qw/mirror RC_NOT_MODIFIED/;
8  use server;  use server;
9    
10    sub mirror_file {
11            my ( $url, $file ) = @_;
12            print STDERR "mirror $url";
13            mirror( $url, $file )
14                    == RC_NOT_MODIFIED
15                    && warn(" not modified\n")
16                    || warn(" done ", -s $file, " bytes\n")
17                    ;
18    }
19    
20  our $just_once;  our $just_once;
21    
22  sub iso {  sub iso {
# Line 27  sub iso { Line 37  sub iso {
37    
38          my $iso = "$dir/$file";          my $iso = "$dir/$file";
39    
40          print STDERR "$name mirror $url";          mirror_file( $url, $iso );
         mirror( $url, $iso )  
                 == RC_NOT_MODIFIED  
                 && warn(" not modified\n")  
                 || warn(" done ", -s $iso, " bytes\n")  
                 ;  
41    
42          $file =~ s{\.iso$}{}i;          $file =~ s{\.iso$}{}i;
43          my $mnt = "$server::base_dir/tftp/$name";          my $mnt = "$server::base_dir/tftp/$name";
# Line 40  sub iso { Line 45  sub iso {
45          $mnt .= '/iso';          $mnt .= '/iso';
46          mkdir $mnt unless -d $mnt;          mkdir $mnt unless -d $mnt;
47    
48          system("mount -t iso9660 | grep $mnt || sudo mount $iso $mnt -o loop -t iso9660 -v") == 0;          system("mount -t iso9660 | grep $name/iso || sudo mount $iso $mnt -o loop -t iso9660 -v") == 0;
49    }
50    
51    sub file {
52            my ( $url, $file ) = @_;
53            my $path = "$server::base_dir/$file";
54            my @file_parts = split m{/}, $file;
55            foreach ( 1 .. $#file_parts - 1 ) {
56                    my $path = splice @file_parts, 0, $_;
57                    warn "? $path\n";
58                    mkdir $path unless -e $path;
59            }
60            mirror_file( $url, "$server::base_dir/$file" );
61  }  }
62    
63  1;  1;

Legend:
Removed from v.138  
changed lines
  Added in v.147

  ViewVC Help
Powered by ViewVC 1.1.26