From 2e26c48aec83e2961bcc29cdd87de4b35ec479e2 Mon Sep 17 00:00:00 2001 From: Andreas Guldstrand Date: Wed, 27 Jul 2016 09:00:22 +0200 Subject: 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. --- SBO-Lib/lib/SBO/Lib.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'SBO-Lib/lib/SBO/Lib.pm') 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/(?