/[corp_html]/.data/save_perm.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /.data/save_perm.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Thu Mar 21 13:49:24 2002 UTC (20 years, 8 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -1 lines
File MIME type: text/plain
don't create symlinks which are unneeded

1 dpavlin 1.1 #!/usr/local/bin/perl -w
2    
3     use English;
4 dpavlin 1.2 use strict;
5 dpavlin 1.1
6 dpavlin 1.2 my @dirs = @ARGV;
7 dpavlin 1.1
8     while (@dirs) {
9     my $curr_dir=shift @dirs;
10     opendir(DIR,$curr_dir) || warn "opendir: $!";
11     my @ignore = ('.', '..', 'CVS');
12     if (-f "$curr_dir/.cvsignore") {
13     open(I,"$curr_dir/.cvsignore");
14     while(<I>) {
15     chomp;
16     push @ignore,$_;
17     }
18     close(I);
19     }
20     print STDERR "ignore: ",join("|",@ignore);
21 dpavlin 1.2 my @clutter = readdir(DIR);
22 dpavlin 1.1 foreach my $file (@clutter) {
23     if (-l "$curr_dir/$file" && grep(/^\Q$file\E$/,@ignore) == 0) {
24     my $dest=readlink("$curr_dir/$file");
25     $dest="$curr_dir/$dest" if (substr($dest,0,1) ne "/");
26 dpavlin 1.3 print "ln -snf $dest $curr_dir/$file\n";
27 dpavlin 1.2 } elsif ((-f "$curr_dir/$file" || -d "$curr_dir/$file") && grep(/^\Q$file\E$/,@ignore) == 0 && -r "$curr_dir/$file") {
28 dpavlin 1.1 my (undef,undef,$mode,undef,$uid,$gid) = stat("$curr_dir/$file");
29 dpavlin 1.2 if ( $uid != $UID || $gid != $GID ) {
30     print "chown ",(scalar(getpwuid($uid)) || $uid),":",(scalar(getgrgid($gid)) || $gid)," $curr_dir/$file\n";
31 dpavlin 1.1 printf "chmod %04o %s\n", ($mode & 07777), "$curr_dir/$file";
32     }
33     push @dirs,"$curr_dir/$file" if (-d "$curr_dir/$file");
34     } else {
35     print STDERR "skip: $curr_dir/$file\n";
36     }
37     }
38     }

  ViewVC Help
Powered by ViewVC 1.1.26