aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-07-27 09:00:22 +0200
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-07-27 09:00:22 +0200
commit2e26c48aec83e2961bcc29cdd87de4b35ec479e2 (patch)
tree01f82800bf943e816155aae952f3e51d2facb98f
parent02c6893233b190fbec966803cca7820678b06250 (diff)
downloadsbotools2-2e26c48aec83e2961bcc29cdd87de4b35ec479e2.tar.xz
SBO::Lib: change copy op to move+copy back
This is so the node won't change when we restore after having made changes. This should fix #40.
-rw-r--r--SBO-Lib/lib/SBO/Lib.pm11
1 files changed, 10 insertions, 1 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm
index 6eb1c09..9443419 100644
--- a/SBO-Lib/lib/SBO/Lib.pm
+++ b/SBO-Lib/lib/SBO/Lib.pm
@@ -862,10 +862,19 @@ sub rewrite_slackbuild {
$args{SLACKBUILD} or script_error('rewrite_slackbuild requires SLACKBUILD.');
my $slackbuild = $args{SLACKBUILD};
my $changes = $args{CHANGES};
- unless (copy($slackbuild, "$slackbuild.orig")) {
+
+ # $status will be undefined if either the rename or the copy fails, otherwise it will be 1
+ my $status = eval {
+ rename($slackbuild, "$slackbuild.orig") or die "not ok";
+ copy("$slackbuild.orig", $slackbuild) or die "not ok";
+ 1;
+ };
+ if (not $status) {
+ rename "$slackbuild.orig", $slackbuild if not -f $slackbuild;
return "Unable to backup $slackbuild to $slackbuild.orig\n",
_ERR_OPENFH;
}
+
my $libdir_regex = qr/^\s*LIBDIRSUFFIX="64"\s*$/;
my $arch_regex = qr/\$VERSION-\$ARCH-\$BUILD/;
my $dc_regex = qr/(?<![a-z])(tar|p7zip|unzip|ar|rpm2cpio|sh)\s+/;