aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SBO-Lib/lib/SBO/Lib.pm57
-rwxr-xr-xsboupgrade34
-rwxr-xr-xt/test.t4
3 files changed, 64 insertions, 31 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm
index 959fe22..e76fa8d 100644
--- a/SBO-Lib/lib/SBO/Lib.pm
+++ b/SBO-Lib/lib/SBO/Lib.pm
@@ -417,9 +417,18 @@ sub check_multilib () {
}
# make a backup of the existent SlackBuild, and rewrite the original as needed
-sub rewrite_slackbuild ($$%) {
- exists $_[1] or script_error 'rewrite_slackbuild requires two arguments.';
- my ($slackbuild, $tempfn, %changes) = @_;
+sub rewrite_slackbuild (%) {
+ my %args = (
+ SLACKBUILD => '',
+ TEMPFN => '',
+ CHANGES => {},
+ @_
+ );
+ unless ($args{SLACKBUILD} && $args{TEMPFN}) {
+ script_error 'rewrite_slackbuild requires SLACKBUILD and TEMPFN.';
+ }
+ my $slackbuild = $args{SLACKBUILD};
+ my $changes = $args{CHANGES};
copy ($slackbuild, "$slackbuild.orig") or
die "Unable to backup $slackbuild to $slackbuild.orig\n";
my $tar_regex = qr/(un|)tar .*$/;
@@ -433,17 +442,17 @@ sub rewrite_slackbuild ($$%) {
# get the output of the tar and makepkg commands. hope like hell that v
# is specified among tar's arguments
if ($line =~ $tar_regex || $line =~ $makepkg_regex) {
- $line = "$line | tee -a $tempfn";
+ $line = "$line | tee -a $args{TEMPFN}";
}
- # then check for and apply any other %changes
- if (exists $changes{libdirsuffix}) {
- $line =~ s/64/$changes{libdirsuffix}/ if $line =~ $libdir_regex;
+ # then check for and apply any other %$changes
+ if (exists $$changes{libdirsuffix}) {
+ $line =~ s/64/$$changes{libdirsuffix}/ if $line =~ $libdir_regex;
}
- if (exists $changes{make}) {
- $line =~ s/make/make $changes{make}/ if $line =~ $make_regex;
+ if (exists $$changes{make}) {
+ $line =~ s/make/make $$changes{make}/ if $line =~ $make_regex;
}
- if (exists $changes{arch_out}) {
- $line =~ s/\$ARCH/$changes{arch_out}/ if $line =~ $arch_regex;
+ if (exists $$changes{arch_out}) {
+ $line =~ s/\$ARCH/$$changes{arch_out}/ if $line =~ $arch_regex;
}
}
untie @sb_file;
@@ -563,7 +572,11 @@ sub perform_sbo (%) {
$cmd = "$args{OPTS} $cmd" if $args{OPTS};
my $tempfh = tempfile (DIR => $tempdir);
my $fn = get_tmp_extfn $tempfh;
- rewrite_slackbuild "$location/$sbo.SlackBuild", $fn, %changes;
+ rewrite_slackbuild (
+ SLACKBUILD => "$location/$sbo.SlackBuild",
+ TEMPFN => $fn,
+ CHANGES => \%changes,
+ );
chdir $location, my $out = system $cmd;
revert_slackbuild "$location/$sbo.SlackBuild";
die "$sbo.SlackBuild returned non-zero ext status\n" unless $out == 0;
@@ -637,13 +650,21 @@ sub do_slackbuild (%) {
}
# remove work directories (source and packaging dirs under /tmp/SBo)
-sub make_clean ($$$) {
- exists $_[2] or script_error 'make_clean requires three arguments.';
- my ($sbo, $src, $version) = @_;
- say "Cleaning for $sbo-$version...";
+sub make_clean (%) {
+ my %args = (
+ SBO => '',
+ SRC => '',
+ VERSION => '',
+ @_
+ );
+ unless ($args{SBO} && $args{SRC} && $args{VERSION}) {
+ script_error 'make_clean requires three arguments.';
+ }
+ say "Cleaning for $args{SBO}-$args{VERSION}...";
my $tmpsbo = "/tmp/SBo";
- remove_tree ("$tmpsbo/$src") if -d "$tmpsbo/$src";
- remove_tree ("$tmpsbo/package-$sbo") if -d "$tmpsbo/package-$sbo";
+ remove_tree ("$tmpsbo/$args{SRC}") if -d "$tmpsbo/$args{SRC}";
+ remove_tree ("$tmpsbo/package-$args{SBO}") if
+ -d "$tmpsbo/package-$args{SBO}";
return 1;
}
diff --git a/sboupgrade b/sboupgrade
index 7b7b46d..a49234c 100755
--- a/sboupgrade
+++ b/sboupgrade
@@ -135,25 +135,32 @@ sub get_requires ($$) {
return \@deps;
# ask to install any requirements found
-sub ask_requires ($$$) {
- exists $_[2] or script_error 'ask_requires requires three arguments.';
- my ($requires, $readme, $sbo) = shift;
- FIRST: for my $req (@$requires) {
+sub ask_requires (%) {
+ my %args = (
+ REQUIRES => '',
+ README => '',
+ SBO => '',
+ @_
+ );
+ unless ($args{REQUIRES} && $args{README} && $args{SBO}) {
+ script_error 'ask_requires requires three arguments.';
+ }
+ FIRST: for my $req (@{$args{REQUIRES}}) {
my $name = $compat32 ? "$req-compat32" : $req;
my $inst = get_installed_sbos;
my $inst_names = get_inst_names $inst;
next FIRST if $name ~~ @$inst_names;
- say $readme;
- print "\nIt looks like this slackbuild requires $name; shall I";
+ say $args{README};
+ print "\nIt looks like $args{SBO} requires $name; shall I";
print " attempt to install it first? [y] ";
if (<STDIN> =~ /^[Yy\n]/) {
- my @args = ('/usr/sbin/sboupgrade', '-oN');
+ my @cmd_args = ('/usr/sbin/sboupgrade', '-oN');
# populate args so that they carry over correctly
for my $arg (qw(c d p)) {
- push @args, "-$arg" if exists $options{$arg};
+ push @cmd_args, "-$arg" if exists $options{$arg};
}
- push @args, "-j $options{j}" if exists $options{j};
- system (@args, $req) == 0 or die "$name failed to install.\n";
+ push @cmd_args, "-j $options{j}" if exists $options{j};
+ system (@cmd_args, $req) == 0 or die "$name failed to install.\n";
}
}
return;
@@ -343,7 +350,12 @@ FIRST: for my $sbo (@ARGV) {
print " yet installed. Shall I install it first? [y] ";
if (<STDIN> =~ /^[Yy\n]/) {
my @args = ('/usr/sbin/sboupgrade', '-oN', $sbo);
- system (@args) == 0 or exit 1;
+ # populate args so that they carry over correctly
+ for my $arg (qw(c d)) {
+ push @args, "-$arg" if exists $options{$arg};
+ }
+ push @args, "-j $options{j}" if exists $options{j};
+ system (@args, $sbo) == 0 or die "$sbo failed to install.\n";
} else {
warn "Please install $sbo\n" and exit 0;
}
diff --git a/t/test.t b/t/test.t
index cdc5701..99456b1 100755
--- a/t/test.t
+++ b/t/test.t
@@ -163,7 +163,7 @@ my $slackbuild = "$rewrite_dir/ifuse.SlackBuild";
$tempfh = tempfile (DIR => $rewrite_dir);
my $tempfn = get_tmp_extfn $tempfh;
my %changes;
-is (rewrite_slackbuild ($slackbuild, $tempfn, %changes), 1, 'rewrite_slackbuild with no %changes good');
+is (rewrite_slackbuild (SLACKBUILD => $slackbuild,TEMPFN => $tempfn,CHANGES => \%changes), 1, 'rewrite_slackbuild with no %changes good');
ok (-f "$slackbuild.orig", 'rewrite_slackbuild backing up original is good.');
my $expected_out = "67c67
< tar xvf \$CWD/\$PRGNAM-\$VERSION.tar.bz2
@@ -179,7 +179,7 @@ is (revert_slackbuild $slackbuild, 1, 'revert_slackbuild is good');
$changes{libdirsuffix} = '';
$changes{make} = '-j 5';
$changes{arch_out} = 'i486';
-is (rewrite_slackbuild ($slackbuild, $tempfn, %changes), 1, 'rewrite_slackbuild with all %changes good');
+is (rewrite_slackbuild (SLACKBUILD => $slackbuild,TEMPFN => $tempfn,CHANGES => \%changes), 1, 'rewrite_slackbuild with all %changes good');
ok (-f "$slackbuild.orig", 'rewrite_slackbuild backing up original is good.');
$expected_out = "55c55
< LIBDIRSUFFIX=\"64\"