commit 2e26c48aec83e2961bcc29cdd87de4b35ec479e2
parent 02c6893233b190fbec966803cca7820678b06250
Author: Andreas Guldstrand <andreas.guldstrand@gmail.com>
Date: Wed, 27 Jul 2016 09:00:22 +0200
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.
Diffstat:
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git 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+/;