[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

0.94 - flatten fixed



Here's the fixed version of the flatten perl script that works here - I've
just tested it. The problem was a missing "g" in a couple of regexp
search/replaces...

Looking at the rest of the script(s) I don't see any more really obvious
speed increases just from redoing sections in perl - most of the time now
is spent doing real work, particularly md5 checking. Need more CPU and
disk bandwidth!

As always, suggestions/somments welcome. I'll put up a 0.95 tonight with
the flatten fix in and nothing else, then I'll probably be out of touch
for a couple of days for the holiday.

-- 
Steve McIntyre, Allstor Software         smcintyr@allstor-sw.co.uk
Also available from steve_mcintyre@geocities.com
"Can't keep my eyes from the circling sky,                 
"Tongue-tied & twisted, Just an earth-bound misfit, I..."  
#!/usr/bin/perl -w 

# This is a perl rewrite of the flatten subsection of
# the slink_cd script.  

#flatten: expects a list of files as standard
#     input.  leaves symlinks into the current tree alone, 
#     changes other links. Needs the directories of the mirror 
#     and the non-us mirror.

# syntax: "cat <files > | flatten mirror non-us"

# (c) 1998 Jens Ritter
# Apply the GNU Public License V 2 or later if necessary.
#
# Released with slink_cd v 0.94 22 Dec 1998

# We extensively work on $_!
while (<STDIN>)
{
    chop;          # Chop "\n" from end.
    if ( ! -l )    # If not symlink, next.
    { 
		print $_, ": normal file\n"; 
        next; 
    }  

    /^(.*)\/(.*)$/;    # regexps are greedy (replaces basename and dirname).

    $dirname  = $1;
    $filename = $2;

    # Count the number of slashes in $dirname and in the
    # sym-link. If the sym-link has more then we need to
    # remove the (external) sym-link and make a hard link
    
    $dirslash = $dirname =~ s/\//\//g ; # counts the number of slashes
                                       # (by replacing "/" with "/")

    $linkname = readlink;

    $linkslash = $linkname =~ s/\//\//g ; 

    $i = $linkname;
    $linkname =~ s/\.\.\///g;
    $abslink = $ARGV[0] . "/dists/" . $linkname;

    # Gross hack for non-US. Sort out the tree!!!
    if ( /non-US/ ) 
    {
		$linkslash = $linkslash + 3;
		$abslink = $ARGV[1] . "/" . $linkname;
    }
 
    # And now for the top-level docs packages; why are these sym-links?
    if ( /package-developer/ ) 
    {
		$abslink = $ARGV[0] . "/" . $linkname;
    }

	# print $_, "(", $linkname, ")", ": ", $dirslash, $linkslash, "\n";

    if ($dirslash < $linkslash)
    {
		print $_, " out of tree; replacing\n";

		# Debugging output.
		print "remove: $_\n";
        print "link: $abslink, $_\n";

		# Uncomment next to lines to remove safeguard.
		unlink;
		link $abslink, $_;
    }
    else
    {
		print $_, " inside of tree; leaving alone\n";
    }
    # print $_,",", $i,",", $abslink,".\n";
}

print "end\n";




Reply to: