#!/usr/bin/perl # update script to help maintain the intel documents repository # it reads the file update.ins which contains update instruction lines # each line is of the form # cmd {sep} file [{sep} renamedFile] # {sep} is one or more consecutive tabs or colons # comments can be added after the final used argument if proceeded by a {sep} # also blank lines and lines beginning with ; are ignored # the first letter of cmd is one of (in upper or lower case) # u update file in the repository, the new file is in this directory (also acts as add) # d delete the file from the repository # r rename the file to renamedfile use strict; open my $fh, ") { chomp; my ($cmd, $file, $newfile) = split /[\t:]+/; $cmd =~ s/^\s+//; next if $cmd =~ /^(;.*)?$/; if ($cmd =~ /^a/i) { if (! -f $file || -f "../$file") { print "skip add $file\n"; unlink $file if -f $file; } else { rename $file, "../$file"; } } elsif ($cmd =~ /^u/i) { if (! -f $file) { print "skip update $file\n"; } elsif (-f "../$file") { print "Updating $file\n"; unlink("../$file"); } else { print "Adding $file\n"; } rename "$file", "../$file"; } elsif ($cmd =~ /^d/i) { if (-f "../$file") { print "Deleting $file\n"; unlink "../$file"; } else { print "skip delete $file\n"; } } elsif ($cmd =~ /^r/i) { if (-f "../$file") { print "Renaming $file $newfile\n"; rename "../$file", "../$newfile"; } else { print "skip rename $file\n"; } } else { print "bad update $_\n"; } } close $fh;