pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils/sysupgrade Update to 1.4:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/52b48a38775c
branches:  trunk
changeset: 609833:52b48a38775c
user:      jmmv <jmmv%pkgsrc.org@localhost>
date:      Thu Oct 11 00:16:46 2012 +0000

description:
Update to 1.4:

- Add support to fetch release sets via ssh.

diffstat:

 sysutils/sysupgrade/Makefile                 |   4 +-
 sysutils/sysupgrade/files/default.conf       |   3 +-
 sysutils/sysupgrade/files/sysupgrade.8       |   4 +-
 sysutils/sysupgrade/files/sysupgrade.conf.5  |   8 +++-
 sysutils/sysupgrade/files/sysupgrade.sh      |  23 ++++++++++
 sysutils/sysupgrade/files/sysupgrade_test.sh |  64 ++++++++++++++++++++++++++++
 6 files changed, 100 insertions(+), 6 deletions(-)

diffs (189 lines):

diff -r d8a1f68616d3 -r 52b48a38775c sysutils/sysupgrade/Makefile
--- a/sysutils/sysupgrade/Makefile      Wed Oct 10 19:45:49 2012 +0000
+++ b/sysutils/sysupgrade/Makefile      Thu Oct 11 00:16:46 2012 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.4 2012/09/07 12:48:32 jmmv Exp $
+# $NetBSD: Makefile,v 1.5 2012/10/11 00:16:46 jmmv Exp $
 
-DISTNAME=      sysupgrade-1.3
+DISTNAME=      sysupgrade-1.4
 CATEGORIES=    sysutils
 MASTER_SITES=  # empty
 DISTFILES=     # empty
diff -r d8a1f68616d3 -r 52b48a38775c sysutils/sysupgrade/files/default.conf
--- a/sysutils/sysupgrade/files/default.conf    Wed Oct 10 19:45:49 2012 +0000
+++ b/sysutils/sysupgrade/files/default.conf    Thu Oct 11 00:16:46 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: default.conf,v 1.1 2012/08/06 17:06:17 jmmv Exp $
+# $NetBSD: default.conf,v 1.2 2012/10/11 00:16:46 jmmv Exp $
 
 # Configuration of automatic system upgrades by sysupgrade(8).
 #
@@ -8,6 +8,7 @@
 
 # Path to the release files (local path or remote URL).
 #RELEASEDIR="ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-6.0/$(uname -m)"
+#RELEASEDIR="ssh://me%builder.example.net@localhost/home/sysbuild/release/$(uname -m)"
 RELEASEDIR="/home/sysbuild/release/$(uname -m)"
 
 # Name of the kernel to be installed.
diff -r d8a1f68616d3 -r 52b48a38775c sysutils/sysupgrade/files/sysupgrade.8
--- a/sysutils/sysupgrade/files/sysupgrade.8    Wed Oct 10 19:45:49 2012 +0000
+++ b/sysutils/sysupgrade/files/sysupgrade.8    Thu Oct 11 00:16:46 2012 +0000
@@ -25,7 +25,7 @@
 .\" 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.
-.Dd August 24, 2012
+.Dd October 10, 2012
 .Dt SYSUPGRADE 8
 .Os
 .Sh NAME
@@ -251,7 +251,7 @@
 directory pointing to the original files.
 Otherwise, if
 .Va RELEASEDIR
-points to a remote FTP or HTTP site, the fetch command will retrieve the
+points to a remote FTP, HTTP or SSH site, the fetch command will retrieve the
 contents of the release directory into the local cache directory.
 .Pp
 Please note that all the commands that access distribution sets do so by looking
diff -r d8a1f68616d3 -r 52b48a38775c sysutils/sysupgrade/files/sysupgrade.conf.5
--- a/sysutils/sysupgrade/files/sysupgrade.conf.5       Wed Oct 10 19:45:49 2012 +0000
+++ b/sysutils/sysupgrade/files/sysupgrade.conf.5       Thu Oct 11 00:16:46 2012 +0000
@@ -25,7 +25,7 @@
 .\" 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.
-.Dd August 24, 2012
+.Dd October 10, 2012
 .Dt SYSUPGRADE.CONF 5
 .Os
 .Sh NAME
@@ -130,6 +130,12 @@
 subdirectory).
 This can be either a local path or a URL.
 .Pp
+If the location is a URL, any of the HTTP, FTP or SSH protocols are supported.
+In the case of SSH, the URL takes the form:
+.Sq ssh://[user[:password]@]<host>/<absolute_path> ,
+which is different to the syntax accepted by
+.Xr scp 1 .
+.Pp
 Default: not set.
 .It Va SETS
 Whitespace-separated list of distribution sets to install.
diff -r d8a1f68616d3 -r 52b48a38775c sysutils/sysupgrade/files/sysupgrade.sh
--- a/sysutils/sysupgrade/files/sysupgrade.sh   Wed Oct 10 19:45:49 2012 +0000
+++ b/sysutils/sysupgrade/files/sysupgrade.sh   Thu Oct 11 00:16:46 2012 +0000
@@ -219,6 +219,29 @@
             done
             ;;
 
+        ssh://*)
+            mkdir -p "${cachedir}"
+
+            local relative_srcs=""
+            for relative_file in ${fetch_files}; do
+                local local_file="${cachedir}/${relative_file##*/}"
+                if [ -f "${local_file}" ]; then
+                    shtk_cli_warning "Reusing existing ${local_file}"
+                else
+                    if [ -z "${relative_srcs}" ]; then
+                        relative_srcs="${relative_file}"
+                    else
+                        relative_srcs="${relative_srcs},${relative_file}"
+                    fi
+                fi
+            done
+            if [ -n "${relative_srcs}" ]; then
+                local host="$(echo ${releasedir} | cut -d / -f 3)"
+                local dir="$(echo ${releasedir} | cut -d / -f 4-)"
+                scp "${host}:/${dir}/{${relative_srcs}}" "${cachedir}/"
+            fi
+            ;;
+
         /*)
             mkdir -p "${cachedir}"
 
diff -r d8a1f68616d3 -r 52b48a38775c sysutils/sysupgrade/files/sysupgrade_test.sh
--- a/sysutils/sysupgrade/files/sysupgrade_test.sh      Wed Oct 10 19:45:49 2012 +0000
+++ b/sysutils/sysupgrade/files/sysupgrade_test.sh      Thu Oct 11 00:16:46 2012 +0000
@@ -347,6 +347,67 @@
 }
 
 
+atf_test_case fetch__ssh__one_set
+fetch__ssh__one_set_body() {
+    create_mock_binary scp
+    PATH="$(pwd):${PATH}"
+
+    SYSUPGRADE_CACHEDIR="$(pwd)/a/b/c"; export SYSUPGRADE_CACHEDIR
+    mkdir -p a/b/c
+    atf_check -o ignore -e ignore sysupgrade -c /dev/null \
+        -o RELEASEDIR="ssh://example.net/home/sysbuild/release/machine" \
+        -o KERNEL="" -o SETS="one" fetch
+
+    cat >expout <<EOF
+Command: scp
+Directory: $(pwd)
+Arg: example.net:/home/sysbuild/release/machine/{binary/sets/one.tgz}
+Arg: $(pwd)/a/b/c/
+
+EOF
+    atf_check -o file:expout cat commands.log
+}
+
+
+atf_test_case fetch__ssh__many_sets
+fetch__ssh__many_sets_body() {
+    create_mock_binary scp
+    PATH="$(pwd):${PATH}"
+
+    SYSUPGRADE_CACHEDIR="$(pwd)/a/b/c"; export SYSUPGRADE_CACHEDIR
+    mkdir -p a/b/c
+    atf_check -o ignore -e ignore sysupgrade -c /dev/null \
+        -o RELEASEDIR="ssh://example.net/home/sysbuild/release/machine" \
+        -o KERNEL=GENERIC -o SETS="one two" fetch
+
+    cat >expout <<EOF
+Command: scp
+Directory: $(pwd)
+Arg: example.net:/home/sysbuild/release/machine/{binary/sets/one.tgz,binary/sets/two.tgz,binary/kernel/netbsd-GENERIC.gz}
+Arg: $(pwd)/a/b/c/
+
+EOF
+    atf_check -o file:expout cat commands.log
+}
+
+
+atf_test_case fetch__ssh__already_exist
+fetch__ssh__already_exist_body() {
+    create_mock_binary scp
+    PATH="$(pwd):${PATH}"
+
+    SYSUPGRADE_CACHEDIR="$(pwd)/a/b/c"; export SYSUPGRADE_CACHEDIR
+    mkdir -p a/b/c
+    touch a/b/c/netbsd-GENERIC.gz
+    touch a/b/c/one.tgz
+    atf_check -o ignore -e ignore sysupgrade -c /dev/null \
+        -o RELEASEDIR="ssh://example.net/home/sysbuild/release/machine" \
+        -o KERNEL=GENERIC -o SETS="one" fetch
+
+    [ ! -f commands.log ] || atf_fail "scp was invoked"
+}
+
+
 atf_test_case fetch__local
 fetch__local_body() {
     create_mock_release release base comp etc netbsd-GENERIC tests text
@@ -1076,6 +1137,9 @@
 
     atf_add_test_case fetch__ftp
     atf_add_test_case fetch__http
+    atf_add_test_case fetch__ssh__one_set
+    atf_add_test_case fetch__ssh__many_sets
+    atf_add_test_case fetch__ssh__already_exist
     atf_add_test_case fetch__local
     atf_add_test_case fetch__no_kernel
     atf_add_test_case fetch__unknown



Home | Main Index | Thread Index | Old Index