util/install: rm the target file before overwriting to prevent running process from crashing.
This commit is contained in:
parent
5b6c063ae7
commit
526c35ce2f
16
util/install
16
util/install
|
@ -42,6 +42,21 @@ if (!-d $target_dir) {
|
|||
shell("mkdir -p $target_dir");
|
||||
}
|
||||
|
||||
if (-f $dst) {
|
||||
shell("rm $dst");
|
||||
|
||||
} else {
|
||||
for my $f (@src) {
|
||||
if (-f $f) {
|
||||
(my $name = $f) =~ s{.*/}{}g;
|
||||
my $target = "$target_dir/$name";
|
||||
if (-f $target) {
|
||||
shell("rm $target");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shell("cp @src $dst");
|
||||
|
||||
if (-f $dst) {
|
||||
|
@ -76,6 +91,7 @@ sub usage {
|
|||
|
||||
sub shell {
|
||||
my $cmd = shift;
|
||||
#warn $cmd;
|
||||
system($cmd) == 0 or
|
||||
die "failed to run command $cmd\n";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue