Author: sparky Date: Thu Mar 16 00:32:40 2006 New Revision: 7178 Modified: ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/xmltar.pl ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/xmluntar.pl Log: - use uuid for file storing, now files containing xmltar tags can ge stored too - use s### when apropiate
Modified: ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/xmltar.pl ============================================================================== --- ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/xmltar.pl (original) +++ ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/xmltar.pl Thu Mar 16 00:32:40 2006 @@ -58,11 +58,19 @@ sub lastname { $_ = $_[0]; - s|.*/||; + s#.*/##; s/&/&/g; s/"/"/g; return $_; -} +} + +sub get_uuid { + my ($F_IN, $uuid); + open $F_IN, "/proc/sys/kernel/random/uuid"; + ($uuid = <$F_IN>) =~ y/ \t\r\n//d; + close $F_IN; + return $uuid; +} sub packfile { my ($file, $step, $localdir, $level) = @_; @@ -86,14 +94,18 @@ return; } print $step."<!--F $localdir".lastname($file)." {{{$level -->\n" if $comment; - print $step.'<xmltar:file mode="'; - #TODO: use /proc/sys/kernel/random/uuid + local $/ = undef; + my $file_content = <F_IN>; + my $uuid = get_uuid(); + while ( $file_content =~ /$uuid/ ) { + $uuid = get_uuid(); + } + print $step.'<xmltar:file:'.$uuid.' mode="'; printf "%04o", ((stat $file)[2]) & 07777; print '" name="'.lastname($file)."\">\n"; - while ( <F_IN> ) { - print $_; - } - print "</xmltar:file>\n"; + print $file_content; + print "</xmltar:file:$uuid>\n"; + close F_IN; } sub packlink { @@ -149,7 +161,7 @@ unless ( $stayinplace ) { foreach my $file (@filelist) { if (-d $file) { - $file =~ s/\/$//; + $file =~ s#/$##; packdir($file, "", "", 1); next; } @@ -168,17 +180,17 @@ my $level=1; my $step=""; foreach my $file (sort @filelist) { - die "only local files, $file\n" if $file =~ /^\// or $file =~ /\.\./; - $file =~ s/\/$//; + die "only local files, $file\n" if $file =~ m#^/# or $file =~ /\.\./; + $file =~ s#/$##; $file = $file; while ( $file !~ /^$dir/ ) { - $dir =~ s/[^\/]*\/$//; + $dir =~ s#[^/]*/$##; $step =~ s/$stepadd$//; $level--; print $step . "</xmltar:dir>\n"; } ( my $filename = $file ) =~ s/^$dir//; - while ( $filename =~ s/^(.*?)\/// ) { + while ( $filename =~ s#^(.*?)/## ) { $dir .= $1."/"; print $step."<!--D $dir {{{$level -->\n" if $comment; print $step . '<xmltar:dir name="'.lastname($1)."\">\n"; @@ -200,7 +212,7 @@ if ( $removed ) { unless (-e $file) { print $step."<!--R $dir".lastname($file)." {{{$level -->\n" if $comment; - print $step.'<xmltar:removed name="'.lastname($file)."\" />\n"; + print $step.'<xmltar:removed name="'.lastname($file).'" />\n'; next; } } @@ -208,7 +220,7 @@ } while ( $dir ) { - $dir =~ s/[^\/]*\/$//; + $dir =~ s#[^/]*/$##; $step =~ s/$stepadd$//; $level--; print $step . "</xmltar:dir>\n"; Modified: ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/xmluntar.pl ============================================================================== --- ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/xmluntar.pl (original) +++ ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/xmluntar.pl Thu Mar 16 00:32:40 2006 @@ -7,6 +7,7 @@ my $verbose = 0; my $comment = 0; +my $warned_nouuid = 0; my @filelist; while ( $ARGV[0] ) { @@ -36,7 +37,7 @@ chomp $L; $L =~ s/^\s*//; next unless $L; - if ( $L =~ s/^<xmltar:hardlink\s+(.*?)>(.*?)<\/xmltar:hardlink>// ) { + if ( $L =~ s#^<xmltar:hardlink\s+(.*?)>(.*?)</xmltar:hardlink>## ) { my $to = $2; my %opts = ( map { /([a-z]+)="(.*?)"/g } $1 ); unless ( $opts{"name"} ) { @@ -51,7 +52,7 @@ chmod oct($opts{"mode"}), $to if $opts{"mode"}; redo; } - if ( $L =~ s/^<xmltar:symlink\s+(.*?)>(.*?)<\/xmltar:symlink>// ) { + if ( $L =~ s#^<xmltar:symlink\s+(.*?)>(.*?)</xmltar:symlink>## ) { my $to = $2; my %opts = ( map { /([a-z]+)="(.*?)"/g } $1 ); unless ( $opts{"name"} ) { @@ -80,23 +81,28 @@ chmod oct($opts{"mode"}), $dir if $opts{"mode"}; redo; } - if ( $L =~ s/^<\/xmltar:dir>// ) { - $dir =~ s|[^/]*/$|| or warn "Error undir!!!$!\n"; + if ( $L =~ s#^</xmltar:dir>## ) { + $dir =~ s#[^/]*/$## or warn "Error undir!!!$!\n"; redo; } - if ( $L =~ s/^<xmltar:file\s+(.*?)>// ) { - my %opts = ( map { /([a-z]+)="(.*?)"/g } $1 ); + if ( $L =~ s/^<xmltar:file(|:[-a-zA-Z0-9]*)\s+(.*?)>// ) { + my $uuid = $1; + my %opts = ( map { /([a-z]+)="(.*?)"/g } $2 ); unless ( $opts{"name"} ) { - warn "file has no name!\n"; + warn "Error: file has no name!\n"; redo; } + unless (length $uuid && ! $warned_nouuid ) { + warn "Warning: file tag has no uuid\n"; + $warned_nouuid = 1; + } my $file = $dir.convname($opts{"name"}); rmtree($file); warn "F $file\n" if $verbose; open F_OUT, "> $file" or die "Can't create file $file: $!\n"; if ( $L ) { warn "Warning: file '$file' should start in next line\n"; - if ( $L =~ s/^(.*?)<\/xmltar:file>// ) { + if ( $L =~ s#^(.*?)</xmltar:file$uuid>## ) { # onle line file print F_OUT $1; close F_OUT; @@ -107,7 +113,7 @@ } } while ( my $Fline = <> ) { - if ( $Fline =~ s/^(.*?)<\/xmltar:file>// ) { + if ( $Fline =~ s#^(.*?)</xmltar:file$uuid>## ) { print F_OUT $1; chomp $Fline; $L = $Fline; @@ -119,7 +125,7 @@ chmod oct($opts{"mode"}), $file if $opts{"mode"}; redo; } - if ( $L =~ s/^<xmltar:removed\s+(.*?)\/>// ) { + if ( $L =~ s#^<xmltar:removed\s+(.*?)/>## ) { my %opts = ( map { /([a-z]+)="(.*?)"/g } $1 ); unless ( $opts{"name"} ) { warn "removed has no name!\n"; _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit