Changeset 12
Legend:
- Unmodified
- Added
- Removed
-
shepherd
r11 r12 23 23 # 24 24 # ToDo: 25 # * --mirror <url> option, to let you get software from somewhere other26 # than whuffy. Store this in shepherd.conf. Whuffy is merely the first27 # mirror.28 25 # * Make it check compilation after installing by calling --version or 29 26 # --desc or --ready … … 50 47 51 48 my $HOME = 'http://www.whuffy.com'; 52 my $STATUS = "$HOME/status";53 49 54 50 my $invoked = Cwd::realpath($0); … … 71 67 my $opt; 72 68 my $pref_order; 69 my $mirror_site; 73 70 my $made_changes = 0; 74 71 my $debug = 1; … … 138 135 &check() if ($opt->{check}); 139 136 140 if ($opt->{enable} or $opt->{disable} or $opt->{setorder} or $opt->{check} )137 if ($opt->{enable} or $opt->{disable} or $opt->{setorder} or $opt->{check} or $opt->{mirror}) 141 138 { 142 139 set_order(1) if $made_changes; … … 539 536 printf "\nChecking for updates:\n\n"; 540 537 541 print "Fetching status file: $STATUS."; 542 my $data = LWP::Simple::get($STATUS); 543 unless ($data) 544 { 545 print "Failed to retrieve status file.\n"; 546 return; 547 } 538 my $data; 539 my $sites = ""; 540 $sites = "$mirror_site," if ($mirror_site); 541 $sites .= $HOME; 542 543 foreach my $site (split(/,/,$sites)) { 544 my $url = $site . "/status"; 545 print "Fetching status file: $url.\n"; 546 $data = LWP::Simple::get($url); 547 last if $data; 548 549 print "Failed to retrieve status file from $url.\n"; 550 } 551 return if (!$data); 548 552 549 553 my %glist = %$grabbers; … … 635 639 print "Downloading $proggy v$latestversion.\n"; 636 640 637 my $rdir = $HOME; 641 my $sites = ""; 642 $sites = "$mirror_site," if ($mirror_site); 643 $sites .= $HOME; 644 645 my $rdir = ""; 638 646 my $ldir = $CWD; 639 my $ver = "unk own";647 my $ver = "unknown"; 640 648 641 649 if (($proggy eq $progname) && ($progtype eq "shepherd")) { 642 $rdir = $HOME;643 $ldir = $CWD;644 650 $ver = $version; 645 651 } elsif ($progtype eq "grabber") { 646 $rdir = $HOME . "/grabbers";652 $rdir = "grabbers"; 647 653 $ldir = "$GRABBER_DIR/$proggy"; 648 654 $ver = $grabbers->{$proggy}->{ver} if ((defined $grabbers->{$proggy}) && $grabbers->{$proggy}->{ver}); 649 655 -d $GRABBER_DIR or mkdir $GRABBER_DIR or die "Cannot create directory $GRABBER_DIR: $!"; 650 656 } elsif ($progtype eq "postprocessor") { 651 $rdir = $HOME . "/postprocessors";657 $rdir = "postprocessors"; 652 658 $ldir = "$POSTPROCESSOR_DIR/$proggy"; 653 659 $ver = $postprocessors->{$proggy}->{ver} if ((defined $postprocessors->{$proggy}) && $postprocessors->{$proggy}->{ver}); … … 660 666 661 667 my $newfile = "$ldir/$proggy-$latestversion"; 662 my $rc = LWP::Simple::getstore("$rdir/$proggy-$latestversion", $newfile); 663 664 unless (is_success($rc)) 665 { 666 print "Failed to retrieve $rdir/$proggy-$latestversion.\n"; 667 return; 668 } 668 my $rc; 669 670 foreach my $site (split(/,/,$sites)) { 671 printf "Fetching $site/$rdir/$proggy-$latestversion.\n"; 672 $rc = LWP::Simple::getstore("$site/$rdir/$proggy-$latestversion", $newfile); 673 last if (is_success($rc)); 674 675 print "Failed to retrieve $site/$rdir/$proggy-$latestversion.\n"; 676 } 677 return if (!is_success($rc)); 669 678 670 679 # Make it executable … … 835 844 &set_order(1); 836 845 } 846 847 # if a mirror has been specified, add it into our config 848 if ($opt->{mirror}) { 849 $mirror_site = $opt->{mirror}; 850 $made_changes = 1; 851 print "Adding mirror: $mirror_site\n"; 852 } 837 853 } 838 854 … … 872 888 open(CONF, ">$config_file") or die "cannot write to $config_file: $!"; 873 889 print CONF Data::Dumper->Dump( 874 [$region, $pref_order, $grabbers, $postprocessors ],875 ["region", "pref_order", " grabbers", "postprocessors" ]);890 [$region, $pref_order, $mirror_site, $grabbers, $postprocessors ], 891 ["region", "pref_order", "mirror_site", "grabbers", "postprocessors" ]); 876 892 close CONF; 877 893 print "\nUpdated configuration file $config_file.\n" if ($debug); … … 892 908 'configure' => \$opt->{configure}, 893 909 'output' => \$opt->{output}, 910 'mirror=s' => \$opt->{mirror}, 894 911 'debug' => \$debug); 895 912 } … … 1101 1118 --status Print a list of grabbers maintained 1102 1119 --list Print a detailed list of grabbers 1120 --mirror <s> Set URL <s> as primary location to check for updates 1103 1121 1104 1122 --configure Setup
