if (!$c) { exec './gpt','config',$inputfile; die $!; }
}
sub fin_prep () {
- $!=0; close P; die "$! $?" if $! or $?;
+ close P; die "$?" if $?;
}
read_prep('perms');
chomp; s/^\s+//; s/\s+$//;
next if m/^\#/; next unless m/\S/;
last if m/^\.$/;
- m/^(.*\S)\s+([0-7]+)$/ or die;
- ($of,$pe)=($1,oct $2);
- $isdir= $of =~ s,/$,,;
- ($isdir ? $dirperms{$of} : $fileperms{$of}) = $pe;
+ if (m/(.*\S)\s+\-\>\s+(\S.*)/) {
+ $linktargs{$1}= $2;
+ } elsif (m/^(.*\S)\s+(\S+)$/) {
+ ($of,$pe)=($1,$2);
+ $isdir= $of =~ s,/$,,;
+ if ($pe =~ m/^[0-7]+$/) {
+ $pe= oct $&;
+ } elsif ($pe eq '+x') {
+ $pe= 0777&~$umask;
+ } elsif ($pe eq '/') {
+ $pe= 02777&~$umask;
+ } else {
+ die "$pe ?";
+ }
+ ($isdir ? $dirperms{$of} : $fileperms{$of}) = $pe;
+ }
}
fin_prep();
if ($nowperms != $perms) {
would($of, sprintf 'chmod %04o -> %04o', $nowperms, $perms);
}
- if (!$action) {
- system 'diff','-u',$home.$of,$newf;
- $?==0 or $?==256 or die $?;
- $changes++ if $?;
- }
+ system 'diff','-u',$home.$of,$newf;
+ $?==0 or $?==256 or die $?;
+ $changes++ if $?;
} else {
+ die unless $!==&ENOENT;
would($of, sprintf 'create %04o', $perms);
}
if ($action) {
die join(', ', keys %fileperms) if %fileperms;
+foreach $link (keys %linktargs) {
+ mkparents($link);
+ $targ= $linktargs{$link};
+ if (lstat $home.$link) {
+ -l _ or die "$link is not a link!";
+ defined($rl= readlink $home.$link) or die $!;
+ } else {
+ die unless $!==&ENOENT;
+ $rl= undef;
+ }
+ if ($rl ne $targ) {
+ would($link, "symlink $targ <-");
+ if ($action) {
+ unlink $home.$link if defined $rl;
+ symlink $targ,$home.$link or die $!;
+ }
+ }
+}
+
foreach $dir (keys %dirperms) {
ensuredir($dir);
}