Improve the parsing of the script location to determine the location of .txt files using File::Basename.
Should be platform safe as $program_path will include trailing path separator.
--- a/clone_packages/clone_all_packages.pl Wed Feb 10 13:22:03 2010 +0000
+++ b/clone_packages/clone_all_packages.pl Wed Feb 10 13:30:10 2010 +0000
@@ -16,6 +16,7 @@
use strict;
use Getopt::Long;
+use File::Basename;
sub Usage($)
{
@@ -93,8 +94,6 @@
my $filter = "";
my @packagelist_files = ();
-my $program_path = $0;
-
# Analyse the rest of command-line parameters
if (!GetOptions(
"u|username=s" => \$username,
@@ -274,10 +273,15 @@
# Read the package list files alongside the script itself
# Extract the path location of the program and locate package list files
- $program_path =~ s/\\/\//g;
- $program_path =~ s/(^.*\/)[^\/]+$/$1/;
+ my ($program_name,$program_path) = &File::Basename::fileparse($0);
+
foreach my $file ("sf_mcl_packages.txt", "sftools_mcl_packages.txt", "other_packages.txt")
{
+ if (! -e $program_path.$file)
+ {
+ print "Cannot find implied packagelist $program_path$file\n";
+ next;
+ }
push @packagelist_files, $program_path.$file;
}
$add_implied_FCL_repos = 1; # lists only contain the MCL repo locations