aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--t/LO2/nonexistentslackbuild/README1
-rw-r--r--t/LO2/nonexistentslackbuild/nonexistentslackbuild.SlackBuild15
-rw-r--r--t/LO2/nonexistentslackbuild/nonexistentslackbuild.info10
-rw-r--r--t/LO2/nonexistentslackbuild4/README1
-rw-r--r--t/LO2/nonexistentslackbuild4/nonexistentslackbuild4.SlackBuild15
-rw-r--r--t/LO2/nonexistentslackbuild4/nonexistentslackbuild4.info10
-rw-r--r--t/LO2/nonexistentslackbuild5/README1
-rw-r--r--t/LO2/nonexistentslackbuild5/nonexistentslackbuild5.SlackBuild15
-rw-r--r--t/LO2/nonexistentslackbuild5/nonexistentslackbuild5.info10
-rw-r--r--t/LO3/nonexistentslackbuild4/README1
-rw-r--r--t/LO3/nonexistentslackbuild4/nonexistentslackbuild4.SlackBuild15
-rw-r--r--t/LO3/nonexistentslackbuild4/nonexistentslackbuild4.info10
-rw-r--r--t/LO3/nonexistentslackbuild5/README1
-rw-r--r--t/LO3/nonexistentslackbuild5/nonexistentslackbuild5.SlackBuild15
-rw-r--r--t/LO3/nonexistentslackbuild5/nonexistentslackbuild5.info10
-rwxr-xr-xt/upgrade.t130
16 files changed, 260 insertions, 0 deletions
diff --git a/t/LO2/nonexistentslackbuild/README b/t/LO2/nonexistentslackbuild/README
new file mode 100644
index 0000000..6d388bb
--- /dev/null
+++ b/t/LO2/nonexistentslackbuild/README
@@ -0,0 +1 @@
+This doesn't exist!
diff --git a/t/LO2/nonexistentslackbuild/nonexistentslackbuild.SlackBuild b/t/LO2/nonexistentslackbuild/nonexistentslackbuild.SlackBuild
new file mode 100644
index 0000000..5f884c5
--- /dev/null
+++ b/t/LO2/nonexistentslackbuild/nonexistentslackbuild.SlackBuild
@@ -0,0 +1,15 @@
+#!/bin/bash
+PRGNAM="nonexistentslackbuild"
+VERSION=${VERSION:-1.1}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+TMP=${TMP:-/tmp/SBo}
+OUTPUT=${OUTPUT:-/tmp}
+
+mkdir -p $TMP/$PRGNAM-$VERSION
+cp README $TMP/$PRGNAM-$VERSION
+mkdir -p $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cp README $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cd $OUTPUT/package-$PRGNAM
+
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-noarch-$BUILD$TAG.tgz
diff --git a/t/LO2/nonexistentslackbuild/nonexistentslackbuild.info b/t/LO2/nonexistentslackbuild/nonexistentslackbuild.info
new file mode 100644
index 0000000..32656f8
--- /dev/null
+++ b/t/LO2/nonexistentslackbuild/nonexistentslackbuild.info
@@ -0,0 +1,10 @@
+PRGNAM="nonexistentslackbuild"
+VERSION="1.1"
+HOMEPAGE="http://www.example.com"
+DOWNLOAD="http://www.pastemobile.org/perf.dummy"
+MD5SUM="9cba6c70fb57a22a155073d54748b614"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES=""
+MAINTAINER="Andreas Guldstrand"
+EMAIL="doesnt@matter.org"
diff --git a/t/LO2/nonexistentslackbuild4/README b/t/LO2/nonexistentslackbuild4/README
new file mode 100644
index 0000000..6d388bb
--- /dev/null
+++ b/t/LO2/nonexistentslackbuild4/README
@@ -0,0 +1 @@
+This doesn't exist!
diff --git a/t/LO2/nonexistentslackbuild4/nonexistentslackbuild4.SlackBuild b/t/LO2/nonexistentslackbuild4/nonexistentslackbuild4.SlackBuild
new file mode 100644
index 0000000..071e0a3
--- /dev/null
+++ b/t/LO2/nonexistentslackbuild4/nonexistentslackbuild4.SlackBuild
@@ -0,0 +1,15 @@
+#!/bin/bash
+PRGNAM="nonexistentslackbuild4"
+VERSION=${VERSION:-1.1}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+TMP=${TMP:-/tmp/SBo}
+OUTPUT=${OUTPUT:-/tmp}
+
+mkdir -p $TMP/$PRGNAM-$VERSION
+cp README $TMP/$PRGNAM-$VERSION
+mkdir -p $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cp README $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cd $OUTPUT/package-$PRGNAM
+
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-noarch-$BUILD$TAG.tgz
diff --git a/t/LO2/nonexistentslackbuild4/nonexistentslackbuild4.info b/t/LO2/nonexistentslackbuild4/nonexistentslackbuild4.info
new file mode 100644
index 0000000..1eb29db
--- /dev/null
+++ b/t/LO2/nonexistentslackbuild4/nonexistentslackbuild4.info
@@ -0,0 +1,10 @@
+PRGNAM="nonexistentslackbuild4"
+VERSION="1.1"
+HOMEPAGE="http://www.example.com"
+DOWNLOAD="http://www.pastemobile.org/perf.dummy"
+MD5SUM="9cba6c70fb57a22a155073d54748b614"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES="nonexistentslackbuild5"
+MAINTAINER="Andreas Guldstrand"
+EMAIL="doesnt@matter.org"
diff --git a/t/LO2/nonexistentslackbuild5/README b/t/LO2/nonexistentslackbuild5/README
new file mode 100644
index 0000000..6d388bb
--- /dev/null
+++ b/t/LO2/nonexistentslackbuild5/README
@@ -0,0 +1 @@
+This doesn't exist!
diff --git a/t/LO2/nonexistentslackbuild5/nonexistentslackbuild5.SlackBuild b/t/LO2/nonexistentslackbuild5/nonexistentslackbuild5.SlackBuild
new file mode 100644
index 0000000..564b0a0
--- /dev/null
+++ b/t/LO2/nonexistentslackbuild5/nonexistentslackbuild5.SlackBuild
@@ -0,0 +1,15 @@
+#!/bin/bash
+PRGNAM="nonexistentslackbuild5"
+VERSION=${VERSION:-1.1}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+TMP=${TMP:-/tmp/SBo}
+OUTPUT=${OUTPUT:-/tmp}
+
+mkdir -p $TMP/$PRGNAM-$VERSION
+cp README $TMP/$PRGNAM-$VERSION
+mkdir -p $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cp README $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cd $OUTPUT/package-$PRGNAM
+
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-noarch-$BUILD$TAG.tgz
diff --git a/t/LO2/nonexistentslackbuild5/nonexistentslackbuild5.info b/t/LO2/nonexistentslackbuild5/nonexistentslackbuild5.info
new file mode 100644
index 0000000..796fd79
--- /dev/null
+++ b/t/LO2/nonexistentslackbuild5/nonexistentslackbuild5.info
@@ -0,0 +1,10 @@
+PRGNAM="nonexistentslackbuild5"
+VERSION="1.1"
+HOMEPAGE="http://www.example.com"
+DOWNLOAD="http://www.pastemobile.org/perf.dummy"
+MD5SUM="9cba6c70fb57a22a155073d54748b614"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES=""
+MAINTAINER="Andreas Guldstrand"
+EMAIL="doesnt@matter.org"
diff --git a/t/LO3/nonexistentslackbuild4/README b/t/LO3/nonexistentslackbuild4/README
new file mode 100644
index 0000000..6d388bb
--- /dev/null
+++ b/t/LO3/nonexistentslackbuild4/README
@@ -0,0 +1 @@
+This doesn't exist!
diff --git a/t/LO3/nonexistentslackbuild4/nonexistentslackbuild4.SlackBuild b/t/LO3/nonexistentslackbuild4/nonexistentslackbuild4.SlackBuild
new file mode 100644
index 0000000..c59389a
--- /dev/null
+++ b/t/LO3/nonexistentslackbuild4/nonexistentslackbuild4.SlackBuild
@@ -0,0 +1,15 @@
+#!/bin/bash
+PRGNAM="nonexistentslackbuild4"
+VERSION=${VERSION:-1.0}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+TMP=${TMP:-/tmp/SBo}
+OUTPUT=${OUTPUT:-/tmp}
+
+mkdir -p $TMP/$PRGNAM-$VERSION
+cp README $TMP/$PRGNAM-$VERSION
+mkdir -p $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cp README $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cd $OUTPUT/package-$PRGNAM
+
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-noarch-$BUILD$TAG.tgz
diff --git a/t/LO3/nonexistentslackbuild4/nonexistentslackbuild4.info b/t/LO3/nonexistentslackbuild4/nonexistentslackbuild4.info
new file mode 100644
index 0000000..1db6295
--- /dev/null
+++ b/t/LO3/nonexistentslackbuild4/nonexistentslackbuild4.info
@@ -0,0 +1,10 @@
+PRGNAM="nonexistentslackbuild4"
+VERSION="1.0"
+HOMEPAGE="http://www.example.com"
+DOWNLOAD="http://www.pastemobile.org/perf.dummy"
+MD5SUM="9cba6c70fb57a22a155073d54748b614"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES="nonexistentslackbuild5"
+MAINTAINER="Andreas Guldstrand"
+EMAIL="doesnt@matter.org"
diff --git a/t/LO3/nonexistentslackbuild5/README b/t/LO3/nonexistentslackbuild5/README
new file mode 100644
index 0000000..6d388bb
--- /dev/null
+++ b/t/LO3/nonexistentslackbuild5/README
@@ -0,0 +1 @@
+This doesn't exist!
diff --git a/t/LO3/nonexistentslackbuild5/nonexistentslackbuild5.SlackBuild b/t/LO3/nonexistentslackbuild5/nonexistentslackbuild5.SlackBuild
new file mode 100644
index 0000000..564b0a0
--- /dev/null
+++ b/t/LO3/nonexistentslackbuild5/nonexistentslackbuild5.SlackBuild
@@ -0,0 +1,15 @@
+#!/bin/bash
+PRGNAM="nonexistentslackbuild5"
+VERSION=${VERSION:-1.1}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+TMP=${TMP:-/tmp/SBo}
+OUTPUT=${OUTPUT:-/tmp}
+
+mkdir -p $TMP/$PRGNAM-$VERSION
+cp README $TMP/$PRGNAM-$VERSION
+mkdir -p $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cp README $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cd $OUTPUT/package-$PRGNAM
+
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-noarch-$BUILD$TAG.tgz
diff --git a/t/LO3/nonexistentslackbuild5/nonexistentslackbuild5.info b/t/LO3/nonexistentslackbuild5/nonexistentslackbuild5.info
new file mode 100644
index 0000000..796fd79
--- /dev/null
+++ b/t/LO3/nonexistentslackbuild5/nonexistentslackbuild5.info
@@ -0,0 +1,10 @@
+PRGNAM="nonexistentslackbuild5"
+VERSION="1.1"
+HOMEPAGE="http://www.example.com"
+DOWNLOAD="http://www.pastemobile.org/perf.dummy"
+MD5SUM="9cba6c70fb57a22a155073d54748b614"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES=""
+MAINTAINER="Andreas Guldstrand"
+EMAIL="doesnt@matter.org"
diff --git a/t/upgrade.t b/t/upgrade.t
new file mode 100755
index 0000000..8417cf0
--- /dev/null
+++ b/t/upgrade.t
@@ -0,0 +1,130 @@
+#!/usr/bin/env perl
+
+use 5.16.0;
+use strict;
+use warnings FATAL => 'all';
+use Test::More;
+use Capture::Tiny qw/ capture_merged /;
+use FindBin '$RealBin';
+use lib $RealBin;
+use lib "$RealBin/../SBO-Lib/lib";
+use Test::Execute;
+
+if ($ENV{TEST_INSTALL}) {
+ plan tests => 13;
+} else {
+ plan skip_all => 'Only run these tests if TEST_INSTALL=1';
+}
+$ENV{TEST_ONLINE} //= 0;
+
+$path = "$RealBin/../";
+
+sub cleanup {
+ capture_merged {
+ system(qw!/sbin/removepkg nonexistentslackbuild!);
+ system(qw!/sbin/removepkg nonexistentslackbuild4!);
+ system(qw!/sbin/removepkg nonexistentslackbuild5!);
+ unlink "$RealBin/LO/nonexistentslackbuild/perf.dummy";
+ unlink "$RealBin/LO/nonexistentslackbuild4/perf.dummy";
+ unlink "$RealBin/LO/nonexistentslackbuild5/perf.dummy";
+ unlink "$RealBin/LO2/nonexistentslackbuild/perf.dummy";
+ unlink "$RealBin/LO2/nonexistentslackbuild4/perf.dummy";
+ unlink "$RealBin/LO2/nonexistentslackbuild5/perf.dummy";
+ unlink "$RealBin/LO3/nonexistentslackbuild/perf.dummy";
+ unlink "$RealBin/LO3/nonexistentslackbuild4/perf.dummy";
+ unlink "$RealBin/LO3/nonexistentslackbuild5/perf.dummy";
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild-0.9!);
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild4-0.9!);
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild5-0.9!);
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild-1.0!);
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild4-1.0!);
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild5-1.0!);
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild-1.1!);
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild4-1.1!);
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild5-1.1!);
+ system(qw!rm -rf /tmp/package-nonexistentslackbuild!);
+ system(qw!rm -rf /tmp/package-nonexistentslackbuild4!);
+ system(qw!rm -rf /tmp/package-nonexistentslackbuild5!);
+ };
+}
+
+sub make_slackbuilds_txt {
+ state $made = 0;
+ my $fname = "/usr/sbo/repo/SLACKBUILDS.TXT";
+ if ($_[0]) {
+ if ($made) { return system(qw!rm -rf!, $fname); }
+ } else {
+ if (not -e $fname) { $made = 1; system('mkdir', '-p', '/usr/sbo/repo'); system('touch', $fname); }
+ }
+}
+
+sub set_lo {
+ state $set = 0;
+ state $lo;
+ if ($_[0]) {
+ if ($set) { script (qw/ sboconfig -o /, $lo, { test => 0 }); }
+ } else {
+ ($lo) = script (qw/ sboconfig -l /, { expected => qr/LOCAL_OVERRIDES=(.*)/, test => 0 });
+ $lo //= 'FALSE';
+ note "Saving original value of LOCAL_OVERRIDES: $lo";
+ $set = 1;
+ script (qw/ sboconfig -o /, "$RealBin/LO", { test => 0 });
+ }
+}
+
+cleanup();
+make_slackbuilds_txt();
+set_lo();
+
+sub install {
+ cleanup();
+ my $lo = shift;
+ my @pkgs = @_;
+
+ script (qw/ sboconfig -o /, "$RealBin/LO", { test => 0 });
+ for my $pkg (@pkgs) {
+ script (qw/ sboinstall -r /, $pkg, { test => 0 });
+ }
+ script (qw/ sboconfig -o /, "$RealBin/$lo", { test => 0 });
+}
+
+# 1-2: sboupgrade nonexistentslackbuild when it doesn't need to be upgraded
+install( 'LO', 'nonexistentslackbuild' );
+script (qw/ sboupgrade nonexistentslackbuild /, { expected => '' });
+script (qw/ sboupgrade -f nonexistentslackbuild /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild\b.*Upgrade queue: nonexistentslackbuild\n/s });
+
+# 3-7: sboupgrade nonexistentslackbuild4 and 5 when they don't need to be upgraded
+install( 'LO', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
+script (qw/ sboupgrade nonexistentslackbuild4 /, { expected => '' });
+script (qw/ sboupgrade nonexistentslackbuild5 /, { expected => '' });
+script (qw/ sboupgrade -f nonexistentslackbuild4 /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild4\n/s });
+script (qw/ sboupgrade -f nonexistentslackbuild5 /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Upgrade queue: nonexistentslackbuild5\n/s });
+script (qw/ sboupgrade -f -z nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s });
+
+# 8: sboupgrade nonexistentslackbuild when it needs to be upgraded
+install( 'LO2', 'nonexistentslackbuild' );
+script (qw/ sboupgrade nonexistentslackbuild /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild\b.*Upgrade queue: nonexistentslackbuild\n/s });
+
+# 9: sboupgrade nonexistentslackbuild4 and 5 when they need to be upgraded
+install( 'LO2', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
+script (qw/ sboupgrade nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s });
+
+# 10-11: sboupgrade nonexistentslackbuild4 and 5 when only 5 needs an update
+install( 'LO3', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
+script (qw/ sboupgrade nonexistentslackbuild4 /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Upgrade queue: nonexistentslackbuild5\n/s });
+install( 'LO3', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
+script (qw/ sboupgrade -f nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s });
+
+# 12-13: sboupgrade --all
+install( 'LO2', 'nonexistentslackbuild' );
+my @sbos = glob("/var/log/packages/*_SBo");
+script (qw/ sboupgrade --all /, { input => ("n\n" x (@sbos+1)), expected => qr/Proceed with nonexistentslackbuild\b/ });
+install( 'LO2', 'nonexistentslackbuild', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
+script(qw/ sboupgrade --all /, { input => ("n\n" x (@sbos+3)), expected => qr/Proceed with nonexistentslackbuild\b.*Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b/s });
+
+# Cleanup
+END {
+ set_lo('delete');
+ make_slackbuilds_txt('delete');
+ cleanup();
+}