ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / modules / extfs / patchfs
1 #!/bin/sh
2
3 # Peter Daum <gator@cs.tu-berlin.de> (Jan 1998, mc-4.1.22)
4
5 # paths to used programs:
6 ncat=cat                  # regular cat
7 zcat=zcat                 # gunzip to stdout
8 bzcat="bzip2 -dc"         # bunzip2 to stdout
9 file=file                 # "file" command
10 sed=sed
11
12 filelist=FILELIST         # names for "special" files
13
14 patchfs_list ()
15 {
16     date=`date +"%b %d %H:%M"`
17     perm="-r--r--r--"
18     uid=00000000
19     gid=00000000
20     size=00000000
21     nlink="  1"
22
23     echo "$perm $nlink $uid $gid $size $date $filelist"
24     $cat $1 | 
25     $sed -n "/^diff /{
26         s|^.* \([^ ]*\)$|$perm $nlink $uid $gid $size $date \1|gp
27     }"
28 }
29
30 patchfs_copyout ()
31 {
32     if [ "$2" = "$filelist" ]; then  # list of all affected files
33         $cat $1 | 
34         $sed -n "/^diff /{
35             s|^.* \([^ ]*\)$|\1|gp
36         }" > $3
37         exit 0
38      fi
39     
40     fn=`echo $2|$sed 's|/|\\\/|g'`   # escape '/' in filename
41     $cat $1 | 
42     $sed -n "/^diff .*$fn/,/^diff /{
43         /^diff ./{
44             /$fn/p
45             d
46         }
47         p
48     }" > $3
49 }
50
51 patchfs_run ()
52 {
53     exit 0
54 }
55
56 type=`$file $2`
57 case $type in
58     *bzip*) cat=$bzcat ;;
59     *gzip*) cat=$zcat ;;
60     *text*) cat=$ncat ;;
61     *) exit 1
62 esac
63
64 umask 077
65 case "$1" in
66     list) patchfs_list $2; exit 0;;
67     copyout) patchfs_copyout $2 $3 $4; exit 0;;
68     run) patchfs_run; exit 0;;
69 esac
70
71 exit 1
72
73