aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ Pipkin <j@dawnrazor.net>2012-09-04 09:41:19 -0500
committerJ Pipkin <j@dawnrazor.net>2012-09-04 09:41:19 -0500
commit8634f81f0036c7dc4d37b082912336864eaaa7b8 (patch)
tree7af30ef54e6739bea44dd34e95ef200df9434aed
parentc76fb8cf15685c99ed9a8bb60f0f74fab3c46f98 (diff)
downloadsbotools2-8634f81f0036c7dc4d37b082912336864eaaa7b8.tar.xz
back-port of -w force_reqs thing
-rw-r--r--man1/sboupgrade.1~70
-rwxr-xr-xsboupgrade30
-rwxr-xr-xt/prep.pl2
-rwxr-xr-xt/test.t15
4 files changed, 39 insertions, 78 deletions
diff --git a/man1/sboupgrade.1~ b/man1/sboupgrade.1~
deleted file mode 100644
index bd7c4ab..0000000
--- a/man1/sboupgrade.1~
+++ /dev/null
@@ -1,70 +0,0 @@
-.TH sboupgrade 1 "Boomtime, Bureaucracy 28, 3178 YOLD" "sbotools 0.8 fnord" dawnrazor.net
-.SH NAME
-.P
-sboupgrade - install or upgrade slackbuilds
-.SH SYNAPSES
-.P
-sboupgrade [-h] [-v] [-d TRUE|FALSE] [-j #|FALSE] [-c TRUE|FALSE] [-f] [-N] [-r] [-R] [-i] sbo_name (sbo_name)
-.SH DESCRIPTION
-.P
-sboupgrade is used to upgrade packages installed from slackbuilds. If the -r flag is NOT specified, sboupgrade will attempt to grok a list of requirements in the README for a given slackbuild. If such a list exists, sboupgrade, will look to see whether or not those requirements are already installed, and if not, it will ask whether or not it should attempt to install them first. Note that this method is FAR from foolproof, which is why this does not happen if the README is bypassed. sboupgrade will also note groupadd and useradd commands in README files and offer to run those first. If the README documents options of the KEY=value form, sboupgrade will offer the opportunity to set options.
-
-.SH OPTIONS
-.P
--h
-.RS
-Show help information.
-.RE
-.P
--v
-.RS
-Show sbotools version information.
-.RE
-.P
--c (TRUE|FALSE)
-.RS
-If TRUE, then DO NOT clean working directories after building the slackbuild. These are the directories where the source is unpacked and compiled, and where the package is put together in, which are under /tmp/SBo. By default, these directories are removed after building an slackbuild. This option leaves those directories in place. This can be set as default via the sboconfig(1) command. Also see sbotools.conf(5). This option overrides the default.
-.RE
-.P
--d (TRUE|FALSE)
-.RS
-If TRUE, then DO remove the source code after building the slackbuild. By default, the source code is not removed, and lives under $SBO_HOME/distfiles, which, by default, is /usr/sbo/distfiles; this option can be set as default via the sboconfig(1) command. See also sbotools.conf(5). This option overrides the default.
-.RE
-.P
--f
-.RS
-Force an upgrade, even if the installed version is equal to or less than the slackbuilds.org version.
-.RE
-.P
--i
-.RS
-Do not actually install the package created at the end of the build process. So, the slackbuild will be run, and the package will be left in /tmp, or in $PKG_DIR if so defined (see sboconfig(1) and sbotools.conf(5)).
-.RE
--j (#|FALSE)
-.RS
-If numeric (2,5,10, etc), then that number will be fed to the "-j" argument to make when a slackbuild which invokes "make" is run. This only makes sense on multicore systems, where one might set the JOBS to the number of available cores, or half that number, etc.
-.RE
-.P
--N
-.RS
-Install any new slackbuilds specified. So, if you want to upgrade some things and install new things with the same command, then you would use the -N flag. Note that upgrades are handled prior to new installs.
-.RE
-.P
--r
-.RS
-Skip viewing of the README and the yes or no question which accompanies it. Anytime sboupgrade is run, the first thing the command will attempt to do is show you the README for a given slackbuild and ask whether or not you wish to proceed; this option skips the README and bypasses the question. If multiple slackbuilds are specified, this option bypasses them all.
-.RE
-.P
--R
-.RS
-This option causes sboupgrade to skip requirement parsing, but still show the README and prompt the user to proceed.
-.RE
-.SH BUGS
-.P
-Requirement parsing is not foolproof; there are very likely corner cases where it does not function as expected. If any such cases are found, please report this to j@dawnrazor.net; patches are always welcome as well.
-.SH SEE ALSO
-.P
-sbocheck(1), sboclean(1), sboconfig(1), sbofind(1), sbosnap(1), sbotools.conf(5)
-.SH AUTHOR
-.P
-Jacob Pipkin <j@dawnrazor.net>
diff --git a/sboupgrade b/sboupgrade
index d6f12d9..4dd37be 100755
--- a/sboupgrade
+++ b/sboupgrade
@@ -34,6 +34,7 @@ Options:
-N: install any new SBo's listed.
-r: skip viewing of the SBo README.
-R: view the README but do not attempt to parse requirements.
+ -w: when used with -f, will force rebuilding an SBo's requirements as well.
Example:
$self -d libsexy
@@ -43,7 +44,7 @@ EOF
}
my %options;
-getopts ('hvacdfj:NriopR', \%options);
+getopts ('hvacdfj:NriopRw', \%options);
show_usage && exit 0 if exists $options{h};
show_version && exit 0 if exists $options{v};
@@ -56,6 +57,7 @@ my $no_install = exists $options{i} ? 1 : 0;
my $only_new = exists $options{o} ? 1 : 0;
my $compat32 = exists $options{p} ? 1 : 0;
my $no_reqs = exists $options{R} ? 1 : 0;
+my $force_reqs = exists $options{w} ? 1 : 0;
if (exists $options{j}) {
die "You have provided an invalid parameter for -j\n" unless
@@ -135,6 +137,20 @@ sub get_requires ($$) {
return \@deps;
}
+# remove any installed requirements from req list
+sub clean_reqs ($) {
+ exists $_[0] or script_error 'clean_reqs requires an argument.';
+ my $reqs = shift;
+ my $inst = get_installed_sbos;
+ my $inst_names = get_inst_names $inst;
+ my @new_reqs;
+ for my $req (@$reqs) {
+ $req = $compat32 ? "$req-compat32" : $req;
+ push @new_reqs, $req unless $req ~~ @$inst_names;
+ }
+ return \@new_reqs;
+}
+
# ask to install any requirements found
sub ask_requires (%) {
my %args = (
@@ -146,18 +162,18 @@ sub ask_requires (%) {
unless ($args{REQUIRES} && $args{README} && $args{SBO}) {
script_error 'ask_requires requires three arguments.';
}
- FIRST: for my $req (@{$args{REQUIRES}}) {
+ my $reqs = $args{REQUIRES};
+ $reqs = clean_reqs $reqs unless ($force && $force_reqs);
+ FIRST: for my $req (@$reqs) {
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 $args{README};
print "\nIt looks like $args{SBO} requires $name; shall I";
print " attempt to install it first? [y] ";
if (<STDIN> =~ /^[Yy\n]/) {
- my @cmd_args = ('/usr/sbin/sboupgrade', '-oN');
+ my @cmd_args = ('/usr/sbin/sboupgrade');
+ push @cmd_args, $force_reqs ? '-N' : '-oN';
# populate args so that they carry over correctly
- for my $arg (qw(c d p)) {
+ for my $arg (qw(c d p f)) {
push @cmd_args, "-$arg" if exists $options{$arg};
}
push @cmd_args, "-j $options{j}" if exists $options{j};
diff --git a/t/prep.pl b/t/prep.pl
index eaf1d4e..ae91c77 100755
--- a/t/prep.pl
+++ b/t/prep.pl
@@ -17,7 +17,7 @@ sub pr ($) {
print {$write} "our \$$thing = 1;\n";
}
-for my $thing (qw(interactive compat32 no_readme jobs distclean noclean no_install no_reqs)) {
+for my $thing (qw(interactive compat32 no_readme jobs distclean noclean no_install no_reqs force force_reqs)) {
pr $thing;
}
diff --git a/t/test.t b/t/test.t
index 3af92d7..c743336 100755
--- a/t/test.t
+++ b/t/test.t
@@ -288,3 +288,18 @@ $fh = open_read "$sbo_home/libraries/libmatchbox/README";
$readme = do {local $/; <$fh>};
close $fh;
ok (! (get_opts $readme), 'get_opts good where README does not define opts');
+
+# 88-90, clean_reqs tests
+$fh = open_read "$sbo_home/system/wine/README";
+$readme = do {local $/; <$fh>};
+close $fh;
+$reqs = get_requires "wine", $readme;
+$reqs = clean_reqs $reqs;
+ok (! $$reqs[0], 'clean_reqs good for already installed reqs');
+$fh = open_read "$sbo_home/games/pingus/README";
+$readme = do {local $/; <$fh>};
+close $fh;
+$reqs = get_requires "pingus", $readme;
+$reqs = clean_reqs $reqs;
+ok ($$reqs[0] eq 'scons', 'clean_reqs good for un/installed reqs.');
+ok ($$reqs[1] eq 'physfs', 'clean_reqs good for un/installed reqs.');