* extfs/patchfs.in: "copyin" method added (with compressed files
support). Files inside archive now have '.diff' extension. Temporary file not needed any more. Proper handling of "/dev/null" filenames, filename heuristics based on diff info page. Set files owner and group as the archive. * extfs/audio.in: CDDB_TIMEOUT variable added.
Этот коммит содержится в:
родитель
63faf36f15
Коммит
84f178c86f
@ -1,3 +1,12 @@
|
|||||||
|
2002-12-13 Adam Byrtek <alpha@debian.org>
|
||||||
|
|
||||||
|
* extfs/patchfs.in: "copyin" method added (with compressed files
|
||||||
|
support). Files inside archive now have '.diff' extension.
|
||||||
|
Temporary file not needed any more. Proper handling of
|
||||||
|
"/dev/null" filenames, filename heuristics based on diff info
|
||||||
|
page. Set files owner and group as the archive.
|
||||||
|
* extfs/audio.in: CDDB_TIMEOUT variable added.
|
||||||
|
|
||||||
2002-12-12 Pavel Roskin <proski@gnu.org>
|
2002-12-12 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* vfs.c (is_dos_date): Allow 4-digit years.
|
* vfs.c (is_dos_date): Allow 4-digit years.
|
||||||
|
@ -10,7 +10,7 @@ set -e
|
|||||||
|
|
||||||
CDDB_SERVER="http://freedb.freedb.org"
|
CDDB_SERVER="http://freedb.freedb.org"
|
||||||
CDDB_HANDSHAKE="hello=user+localhost+mc+1.0&proto=1"
|
CDDB_HANDSHAKE="hello=user+localhost+mc+1.0&proto=1"
|
||||||
|
CDDB_TIMEOUT=20 # in seconds
|
||||||
|
|
||||||
audiofs_list ()
|
audiofs_list ()
|
||||||
{
|
{
|
||||||
@ -32,8 +32,8 @@ audiofs_copyout ()
|
|||||||
if [ -z "$DISCID" ]; then
|
if [ -z "$DISCID" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
RESPONSE=`wget -q -T 60 -O - "$CDDB_SERVER/~cddb/cddb.cgi?cmd=cddb+query+$DISCID&$CDDB_HANDSHAKE" | @AWK@ '/^200/ { print $2,$3; }'`
|
RESPONSE=`wget -q -T $CDDB_TIMEOUT -O - "$CDDB_SERVER/~cddb/cddb.cgi?cmd=cddb+query+$DISCID&$CDDB_HANDSHAKE" | tee $3 | @AWK@ '/^200/ { print $2,$3; }'`
|
||||||
wget -q -T 60 -O - "$CDDB_SERVER/~cddb/cddb.cgi?cmd=cddb+read+$RESPONSE&$CDDB_HANDSHAKE" | grep -v "^#" > $3
|
wget -q -T $CDDB_TIMEOUT -O - "$CDDB_SERVER/~cddb/cddb.cgi?cmd=cddb+read+$RESPONSE&$CDDB_HANDSHAKE" | grep -v "^#" >> $3
|
||||||
else
|
else
|
||||||
TRACK=`echo $2 | sed 's/track-0*//' | sed 's/\.wav//'`
|
TRACK=`echo $2 | sed 's/track-0*//' | sed 's/\.wav//'`
|
||||||
cdparanoia -q -d $1 $TRACK $3 >/dev/null
|
cdparanoia -q -d $1 $TRACK $3 >/dev/null
|
||||||
|
@ -9,145 +9,208 @@ use strict;
|
|||||||
use POSIX;
|
use POSIX;
|
||||||
|
|
||||||
# standard binaries
|
# standard binaries
|
||||||
my $bzcat = "bzip2 -dc";
|
my $bzip = "bzip2";
|
||||||
my $gzcat = "zcat";
|
my $gzip = "gzip";
|
||||||
my $file = "file";
|
my $file = "file";
|
||||||
|
|
||||||
# date parsing requires Date::Parse from TimeDate module
|
# date parsing requires Date::Parse from TimeDate module
|
||||||
my $parsedates = eval "require Date::Parse";
|
my $parsedates = eval "require Date::Parse";
|
||||||
|
|
||||||
|
|
||||||
|
# output unix date in a mc-readable format
|
||||||
sub timef
|
sub timef
|
||||||
{
|
{
|
||||||
# format unix time
|
|
||||||
my @time=localtime($_[0]);
|
my @time=localtime($_[0]);
|
||||||
return sprintf "%02d-%02d-%d %02d:%02d", $time[4]+1, $time[3],
|
return sprintf "%02d-%02d-%02d %02d:%02d", $time[4]+1, $time[3], $time[5]%100, $time[2], $time[1];
|
||||||
$time[5] + 1900, $time[2], $time[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# parse given string as a date and return unix time
|
||||||
sub datetime
|
sub datetime
|
||||||
{
|
{
|
||||||
# in case of problems fall back to 0 in unix time
|
# in case of problems fall back to 0 in unix time
|
||||||
# note: str2time interprets some wrong values (eg. " ") as 'today'
|
# note: str2time interprets some wrong values (eg. " ") as 'today'
|
||||||
if ($parsedates && defined (my $t=str2time($_[0]))) {
|
if ($parsedates && defined (my $t=str2time($_[0]))) {
|
||||||
return timef($t);
|
return timef($t)
|
||||||
}
|
}
|
||||||
return timef(time);
|
return timef(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# print message on stderr and exit
|
||||||
|
sub error
|
||||||
|
{
|
||||||
|
print STDERR $_[0];
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# list files affected by patch
|
||||||
sub list
|
sub list
|
||||||
{
|
{
|
||||||
my ($f,$d,$state,$pos,$npos);
|
my ($archive)=@_;
|
||||||
my ($uid,$gid)=(`id -nu` || "0",`id -ng` || "0");
|
my ($state,$pos,$npos,$time);
|
||||||
chomp ($uid, $gid);
|
my ($f,$fsrc,$fdst,$prefix);
|
||||||
|
|
||||||
|
# use uid and gid from file
|
||||||
|
my ($uid,$gid)=(`ls -l $archive`=~/^[^\s]+\s+[^\s]+\s+([^\s]+)\s+([^\s]+)/);
|
||||||
|
|
||||||
import Date::Parse if ($parsedates);
|
import Date::Parse if ($parsedates);
|
||||||
|
|
||||||
# state==1 means diff contents, state==0 mens comments
|
# state==1 means diff contents, state==0 mens comments
|
||||||
$state=1;
|
$state=1; $f="";
|
||||||
$f="";
|
|
||||||
while (<I>) {
|
while (<I>) {
|
||||||
if (/^--- /) {
|
if (/^-{3} /) {
|
||||||
# start of a new file
|
# parse diff header
|
||||||
if ($state==1) {
|
if ($state==1) {
|
||||||
$npos=tell(I)-length;
|
$npos=tell(I)-length;
|
||||||
printf "-rw-r--r-- 1 %s %s %d %s %s\n", $uid, $gid, $npos-$pos, datetime($d), $f
|
printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $npos-$pos, datetime($time), $prefix, $f
|
||||||
if $f;
|
if $f;
|
||||||
$pos=$npos;
|
$pos=$npos;
|
||||||
}
|
}
|
||||||
$state=1;
|
$state=1;
|
||||||
s/^--- ([^\s]+).*$/$1/;
|
|
||||||
chomp;
|
error "Can't parse unified diff header"
|
||||||
$f=$_;
|
unless ((($_.=<I>).=<I>)=~/^\-{3} .*\n\+{3} .*\n@@ .* @@\n$/);
|
||||||
$d="";
|
($fsrc)=/^-{3} ([^\s]+).*\n.*\n.*\n$/;
|
||||||
} elsif (/^\+\+\+ /) {
|
($fdst)=/^.*\n\+{3} ([^\s]+).*\n.*\n$/;
|
||||||
# take date from the +++ field
|
($time)=/^.*\n\+{3} [^\s]+\s+([^\t\n]+).*\n.*\n$/;
|
||||||
s/^\+\+\+ ([^\s]+)\s*//;
|
|
||||||
s/^([^\t]+).*$/$1/;
|
# select filename, conform with (diff.info)Multiple patches
|
||||||
chomp;
|
$prefix="";
|
||||||
$d=$_;
|
if ($fsrc eq "/dev/null") {
|
||||||
|
$f=$fdst; $prefix="PATCH-CREATE/";
|
||||||
|
} elsif ($fdst eq "/dev/null") {
|
||||||
|
$f=$fsrc; $prefix="PATCH-REMOVE/";
|
||||||
|
} elsif (($fdst eq "/dev/null") && ($fsrc eq "/dev/null")) {
|
||||||
|
error "Malformed diff";
|
||||||
|
} elsif (!$fdst && !$fsrc) {
|
||||||
|
error "Index: not yet implemented";
|
||||||
|
} else {
|
||||||
|
# fewest path name components
|
||||||
|
if ($fdst=~s|/|/|g < $fsrc=~s|/|/|g) {
|
||||||
|
$f=$fdst;
|
||||||
|
} elsif ($fdst=~s|/|/|g > $fsrc=~s|/|/|g) {
|
||||||
|
$f=$fsrc;
|
||||||
|
} else {
|
||||||
|
# shorter base name
|
||||||
|
if (($fdst=~m|^.*/([^/]+)$|,length $1) < ($fsrc=~m|^.*/([^/]+)$|,length $1)) {
|
||||||
|
$f=$fdst;
|
||||||
|
} elsif (($fdst=~m|^.*/([^/]+)$|,length $1) > ($fsrc=~m|^.*/([^/]+)$|,length $1)) {
|
||||||
|
$f=$fsrc;
|
||||||
|
} else {
|
||||||
|
# shortest names
|
||||||
|
if (length $fdst < length $fsrc) {
|
||||||
|
$f=$fdst;
|
||||||
|
} else {
|
||||||
|
$f=$fsrc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$f=$f.".diff";
|
||||||
|
|
||||||
} elsif ($state==1 && !/^([+\- ]|@@)/) {
|
} elsif ($state==1 && !/^([+\- ]|@@)/) {
|
||||||
# start of comments, end of diff contents
|
# start of comments, end of diff contents
|
||||||
$npos=tell(I)-length;
|
$npos=tell(I)-length;
|
||||||
printf "-rw-r--r-- 1 %s %s %d %s %s\n", $uid, $gid, $npos-$pos, datetime($d), $f
|
printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $npos-$pos, datetime($time), $prefix, $f
|
||||||
if $f;
|
if $f;
|
||||||
$pos=$npos;
|
$pos=$npos;
|
||||||
$state=0;
|
$state=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$npos=tell(I);
|
$npos=tell(I);
|
||||||
printf "-rw-r--r-- 1 %s %s %d %s %s\n", $uid, $gid, $npos-$pos, datetime($d), $f
|
printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $npos-$pos, datetime($time), $prefix, $f
|
||||||
if $f && $state!=0;
|
if $f;
|
||||||
|
|
||||||
close I;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub copyout
|
sub copyout
|
||||||
{
|
{
|
||||||
my ($file,$out)=@_;
|
my ($file,$out)=@_;
|
||||||
my ($f,$state,$pos);
|
my ($fsrc,$fdst,$found,$state,$buf);
|
||||||
|
|
||||||
open O, "> $out";
|
$file=~s/^(PATCH-(CREATE|REMOVE)\/)?(.*)\.diff$/$3/;
|
||||||
$state=1;
|
|
||||||
$f="";
|
# state==1 means diff contents, state==0 mens comments
|
||||||
|
$state=1; $found=0; $buf="";
|
||||||
while (<I>) {
|
while (<I>) {
|
||||||
if (/^--- /) {
|
if (/^-{3} /) {
|
||||||
# start of a new file
|
# parse diff header
|
||||||
if ($state==1) {
|
last if ($state==1 && $found);
|
||||||
if ($f eq $file) {
|
|
||||||
seek(I,-length,1);
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
$pos=tell(I)-length;
|
|
||||||
}
|
|
||||||
$state=1;
|
$state=1;
|
||||||
s/^--- ([^\s]+).*$/$1/;
|
|
||||||
chomp;
|
error "Can't parse unified diff header"
|
||||||
$f=$_;
|
unless ((($_.=<I>).=<I>)=~/^\-{3} .*\n\+{3} .*\n@@ .* @@\n$/);
|
||||||
|
($fsrc)=/^-{3} ([^\s]+).*\n.*\n.*\n$/;
|
||||||
|
($fdst)=/^.*\n\+{3} ([^\s]+).*\n.*\n$/;
|
||||||
|
$found=1 if (($fsrc eq $file) || ($fdst eq $file));
|
||||||
|
|
||||||
} elsif ($state==1 && !/^([+\- ]|@@)/) {
|
} elsif ($state==1 && !/^([+\- ]|@@)/) {
|
||||||
# start of comments, end of diff contents
|
# start of comments, end of diff contents
|
||||||
if ($f eq $file) {
|
last if ($found);
|
||||||
seek(I,-length,1);
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
$pos=tell(I)-length;
|
|
||||||
$state=0;
|
$state=0;
|
||||||
|
$buf="";
|
||||||
}
|
}
|
||||||
|
$buf.=$_ if ($found || $state==0)
|
||||||
}
|
}
|
||||||
if ($f eq $file) {
|
if ($found) {
|
||||||
my $here=tell(I);
|
open O, "> $out";
|
||||||
seek(I,$pos,0);
|
|
||||||
read(I,my $buf,$here-$pos);
|
|
||||||
print O $buf;
|
print O $buf;
|
||||||
|
close O;
|
||||||
}
|
}
|
||||||
|
|
||||||
close O;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub copyin
|
||||||
|
{
|
||||||
|
# append diff to archive
|
||||||
|
my ($archive,$name,$f)=(quotemeta $_[0],$_[1],quotemeta $_[2]);
|
||||||
|
my ($cmd);
|
||||||
|
|
||||||
my $tmp;
|
error "File must have .diff or .patch extension"
|
||||||
my $quoted_name = quotemeta $ARGV[1];
|
unless $name=~/\.(diff|patch)(\.(bz|bz2|gz|z|Z))?$/;
|
||||||
$_=`$file $quoted_name`;
|
|
||||||
if (/bzip/) {
|
$_=`$file $f`;
|
||||||
$tmp=tmpnam();
|
if (/bzip/) {
|
||||||
system "$bzcat $quoted_name > $tmp";
|
$cmd="$bzip -dc $f";
|
||||||
open I, "< $tmp";
|
} elsif (/gzip/) {
|
||||||
} elsif (/gzip/) {
|
$cmd="$gzip -dc $f";
|
||||||
$tmp=tmpnam();
|
} else {
|
||||||
system "$gzcat $quoted_name > $tmp";
|
$cmd="cat $f";
|
||||||
open I, "< $tmp";
|
}
|
||||||
} else {
|
|
||||||
open I, "< $ARGV[1]";
|
$_=`$file $archive`;
|
||||||
|
if (/bzip/) {
|
||||||
|
system "$cmd | $bzip -c >> $archive";
|
||||||
|
} elsif (/gzip/) {
|
||||||
|
system "$cmd | $gzip -c >> $archive";
|
||||||
|
} else {
|
||||||
|
system "$cmd >> $archive";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub openread
|
||||||
|
{
|
||||||
|
# open (compressed) archive for reading
|
||||||
|
my ($archive) = (quotemeta $_[0]);
|
||||||
|
|
||||||
|
$_=`$file $archive`;
|
||||||
|
if (/bzip/) {
|
||||||
|
open I, "$bzip -dc $ARGV[1] |";
|
||||||
|
} elsif (/gzip/) {
|
||||||
|
open I, "$gzip -dc $ARGV[1] |";
|
||||||
|
} else {
|
||||||
|
open I, "< $ARGV[1]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($ARGV[0] eq "list") {
|
if ($ARGV[0] eq "list") {
|
||||||
list;
|
openread $ARGV[1];
|
||||||
exit(0);
|
list $ARGV[1];
|
||||||
|
exit 0;
|
||||||
} if ($ARGV[0] eq "copyout") {
|
} if ($ARGV[0] eq "copyout") {
|
||||||
|
openread $ARGV[1];
|
||||||
copyout ($ARGV[2], $ARGV[3]);
|
copyout ($ARGV[2], $ARGV[3]);
|
||||||
exit(0);
|
exit 0;
|
||||||
}
|
} if ($ARGV[0] eq "copyin") {
|
||||||
exit(1);
|
copyin ($ARGV[1], $ARGV[2], $ARGV[3]);
|
||||||
|
exit 0;
|
||||||
END {
|
|
||||||
system "rm $tmp" if ($tmp);
|
|
||||||
}
|
}
|
||||||
|
exit 1;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user