aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--t/travis-deps/install.sh3
-rwxr-xr-xt/travis-deps/installpkg57
-rwxr-xr-xt/travis-deps/makepkg25
-rwxr-xr-xt/travis-deps/removepkg3
-rwxr-xr-xt/travis-deps/upgradepkg119
6 files changed, 208 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml
index 4a4c8ec..fbce77f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,5 +4,5 @@ perl:
- "5.18"
- "5.16"
sudo: required
-install: true
+install: sudo bash t/travis-deps/install.sh
script: t/travis.sh
diff --git a/t/travis-deps/install.sh b/t/travis-deps/install.sh
new file mode 100644
index 0000000..565852e
--- /dev/null
+++ b/t/travis-deps/install.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+mkdir -p /var/log/packages
+cp -a t/travis-deps/*pkg /sbin/
diff --git a/t/travis-deps/installpkg b/t/travis-deps/installpkg
new file mode 100755
index 0000000..1c4c8b7
--- /dev/null
+++ b/t/travis-deps/installpkg
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+# Stripped down and useless version of this script merely used for testing.
+# But some bits taken from the original upgradepkg, so here's its copyright
+# notice.
+
+# Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA
+# Copyright 2001, 2002, 2003 Slackware Linux, Inc., Concord, California, USA
+# Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2015 Michal Nazarewicz <mina86@mina86.com>
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Modified to handle either old 8.3 or new package-version-arch-build.tgz
+# packages, Sat Nov 17 14:25:58 PST 2001 volkerdi
+#
+# Rewritten to clean out _all_ old packages of a given basename, not just
+# the first one found, Thu Apr 4 01:01:05 PST 2002 volkerdi
+#
+# Added --install-new and --reinstall, Fri May 31 14:11:14 PDT 2002 volkerdi
+# Added --dry-run, Sat Apr 26 18:13:29 PDT 2003
+#
+# Sat Apr 25 21:18:53 UTC 2009
+# Support new compression types and package extensions.
+# Converted to use new pkgbase() function to remove pathname and
+# valid package extensions.
+#
+# Sat 17 Jan 16:21:32 UTC 2015 mina86
+# Various optimisation mostly resolving around avoiding having to fork
+# and call cut, basename and other helper commands. Slight
+# refactoring of code calling removepkg.
+
+pkgbase() {
+ PKGRETURN=${1##*/}
+ case "$PKGRETURN" in *.t[gblx]z)
+ PKGRETURN=${PKGRETURN%.*}
+ esac
+ echo "$PKGRETURN"
+}
+
+touch /var/log/packages/$(pkgbase $1)
diff --git a/t/travis-deps/makepkg b/t/travis-deps/makepkg
new file mode 100755
index 0000000..54c1b3c
--- /dev/null
+++ b/t/travis-deps/makepkg
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+while [[ $# > 1 ]]
+do
+key="$1"
+
+case $key in
+ -l|--linkadd)
+ LINKADD="$2"
+ shift
+ ;;
+ -c|--chown)
+ CHOWN="$2"
+ shift
+ ;;
+ -p|--prepend)
+ PREPEND=1
+ ;;
+esac
+shift
+done
+
+touch $1
+
+echo "Slackware package $1 created.
diff --git a/t/travis-deps/removepkg b/t/travis-deps/removepkg
new file mode 100755
index 0000000..a79caa1
--- /dev/null
+++ b/t/travis-deps/removepkg
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+rm /var/log/packages/$1 || rm /var/log/packages/$1-*
diff --git a/t/travis-deps/upgradepkg b/t/travis-deps/upgradepkg
new file mode 100755
index 0000000..3591936
--- /dev/null
+++ b/t/travis-deps/upgradepkg
@@ -0,0 +1,119 @@
+#!/bin/bash
+
+# Stripped down and useless version of this script merely used for testing.
+# But some bits taken from the original, so here's the original copyright
+# notice.
+
+# Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA
+# Copyright 2001, 2002, 2003 Slackware Linux, Inc., Concord, California, USA
+# Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2015 Michal Nazarewicz <mina86@mina86.com>
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Modified to handle either old 8.3 or new package-version-arch-build.tgz
+# packages, Sat Nov 17 14:25:58 PST 2001 volkerdi
+#
+# Rewritten to clean out _all_ old packages of a given basename, not just
+# the first one found, Thu Apr 4 01:01:05 PST 2002 volkerdi
+#
+# Added --install-new and --reinstall, Fri May 31 14:11:14 PDT 2002 volkerdi
+# Added --dry-run, Sat Apr 26 18:13:29 PDT 2003
+#
+# Sat Apr 25 21:18:53 UTC 2009
+# Support new compression types and package extensions.
+# Converted to use new pkgbase() function to remove pathname and
+# valid package extensions.
+#
+# Sat 17 Jan 16:21:32 UTC 2015 mina86
+# Various optimisation mostly resolving around avoiding having to fork
+# and call cut, basename and other helper commands. Slight
+# refactoring of code calling removepkg.
+
+
+while [[ $# > 1 ]]
+do
+key="$1"
+
+case $key in
+ --dryrun)
+ DRYRUN=1
+ ;;
+ --install-new)
+ NEW=1
+ ;;
+ --reinstall)
+ REINSTALL=1
+ ;;
+ --verbose)
+ VERBOSE=1
+ ;;
+esac
+shift
+done
+
+PACKAGE="$1"
+
+pkgbase() {
+ PKGRETURN=${1##*/}
+ case "$PKGRETURN" in *.t[gblx]z)
+ PKGRETURN=${PKGRETURN%.*}
+ esac
+ echo "$PKGRETURN"
+}
+
+package_name() {
+ STRING=$(pkgbase "$1")
+ case "$STRING" in
+ *-*-*-*)
+ # At least four segments, strip version arch and build and return name:
+ echo "${STRING%-*-*-*}"
+ ;;
+ *)
+ # Old style package name with one segment or we don't have four
+ # segments: return the old-style (or out of spec) package name.
+ echo $STRING
+ esac
+}
+
+for ARG; do
+ OLD=${ARG%'%'*}
+ NEW=${ARG#*'%'}
+
+ INCOMINGDIR=$(dirname $NEW)
+ NNAME=${NEW##*/}
+ ONAME=${OLD##*/}
+ NEW=$(pkgbase $NEW)
+ OLD=$(pkgbase $OLD)
+
+ SHORT="$(package_name $OLD)"
+ if [ ! -r /var/log/packages/$OLD ]; then
+ if ls /var/log/packages/$SHORT* &>/dev/null ; then
+ for installed_package in /var/log/packages/$SHORT* ; do
+ if [ "$(package_name $installed_package)" = "$SHORT" ]; then
+ OLD="${installed_package##*/}"
+ break
+ fi
+ done
+ fi
+ fi
+
+ /sbin/removepkg $OLD
+ /sbin/installpkg $INCOMINGDIR/$NNAME
+done