File 6001-ssh-Update-build-scripts-for-ssh_compat_SUITE-docker.patch of Package erlang

From 3de2aa8537d56be31bda72f9b6313f4321a671d6 Mon Sep 17 00:00:00 2001
From: Hans Nilsson <hans@erlang.org>
Date: Wed, 8 Dec 2021 10:09:45 +0100
Subject: [PATCH] ssh: Update build scripts for ssh_compat_SUITE docker

---
 .../ssh_compat_SUITE_data/build_scripts/DF    |  5 ++++
 .../build_scripts/MOVE.howto                  | 23 +++++++++++++++++++
 .../build_scripts/create-base-image           |  2 +-
 .../build_scripts/create-ssh-image            | 17 ++++++++++----
 .../build_scripts/create-ssl-image            | 17 +++++++++++---
 5 files changed, 56 insertions(+), 8 deletions(-)
 create mode 100644 lib/ssh/test/ssh_compat_SUITE_data/build_scripts/DF
 create mode 100644 lib/ssh/test/ssh_compat_SUITE_data/build_scripts/MOVE.howto

diff --git a/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/DF b/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/DF
new file mode 100644
index 0000000000..f3a8898fa9
--- /dev/null
+++ b/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/DF
@@ -0,0 +1,5 @@
+FROM ssh_compat:bld
+    
+# Start the daemon, but keep it in foreground to avoid killing the container
+CMD /buildroot/ssh/sbin/sshd -D -p 1234
+
diff --git a/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/MOVE.howto b/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/MOVE.howto
new file mode 100644
index 0000000000..3453e607d5
--- /dev/null
+++ b/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/MOVE.howto
@@ -0,0 +1,23 @@
+To move an image, do:
+
+On src machine:
+
+$ docker run -itd --rm -p 1234 REPOSITORY:TAG
+$ docker export XYZ -o FIL
+$ scp FIL  hans@laura.otp.ericsson.se:/ldisk/hans/docker
+$ docker kill THE_DOCKER_REF
+
+On dst machine:
+
+hans$ chmod a+r FIL
+$ docker import FIL ssh_compat:bld
+$ docker build -t REPOSITORY:TAG -f DF .
+$ docker rmi ssh_compat:bld
+
+(DF contains:
+FROM ssh_compat:bld
+    
+# Start the daemon, but keep it in foreground to avoid killing the container
+CMD /buildroot/ssh/sbin/sshd -D -p 1234
+
+)
diff --git a/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-base-image b/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-base-image
index 1cb7bf33e1..bb3bee5f11 100755
--- a/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-base-image
+++ b/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-base-image
@@ -6,7 +6,7 @@ USER=sshtester
 PWD=foobar
 
 docker build \
-    -t ubuntubuildbase \
+    -t ssh_compat_suite-ubuntu \
     --build-arg https_proxy=$HTTPS_PROXY \
     --build-arg http_proxy=$HTTP_PROXY \
     - <<EOF
diff --git a/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-ssh-image b/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-ssh-image
index 2e08408841..2a0b763058 100755
--- a/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-ssh-image
+++ b/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-ssh-image
@@ -1,8 +1,6 @@
 #!/bin/sh
 
-# ./create-image openssh 7.3p1 openssl 1.0.2m
-
-set -x
+# ./create-image openssh 7.3p1 openssl 1.0.2m [in-file]
 
 case $1 in
     openssh)
@@ -20,6 +18,8 @@ esac
 FAMssl=$3
 VERssl=$4
 
+INPUT_FILE=$5
+
 VER=${FAMssh}${VERssh}-${FAMssl}${VERssl}
 
 # This way of fetching the tar-file separate from the docker commands makes
@@ -62,7 +62,16 @@ EOF
 
 # Fetch the tar file. This could be done in an "ADD ..." in the Dockerfile,
 # but then we hit the proxy problem...
-wget -O $TMP $PFX$VERssh$SFX
+
+if [ "x$INPUT_FILE" = "x" ]
+then
+    wget -O $TMP $PFX$VERssh$SFX
+
+elif [ "x$INPUT_FILE" != "x$TMP" ]
+then
+    echo "Use $INPUT_FILE for input"
+    cp $INPUT_FILE $TMP
+fi
 
 # Build the image:
 docker build -t  ssh_compat_suite-ssh:$VER -f ./TempDockerFile .
diff --git a/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-ssl-image b/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-ssl-image
index 4ab2a8bddc..4daf356f10 100755
--- a/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-ssl-image
+++ b/lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-ssl-image
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# ./create-image openssl 1.0.2m
+# ./create-image openssl 1.0.2m [in-file] 
 
 case "$1" in
     "openssl")
@@ -23,6 +23,8 @@ case "$1" in
 	;;
 esac
 
+INPUT_FILE=$3
+
 case $1$2 in
     openssl0.9.8[a-l])
         CONFIG_FLAGS=no-asm
@@ -41,7 +43,7 @@ esac
 # Make a Dockerfile. This method simplifies env variable handling considerably:
 cat - > TempDockerFile <<EOF
 
-    FROM ubuntubuildbase
+    FROM ssh_compat_suite-ubuntu:latest
 
     LABEL version=$FAM-$VER
 
@@ -62,7 +64,16 @@ EOF
 
 # Fetch the tar file. This could be done in an "ADD ..." in the Dockerfile,
 # but then we hit the proxy problem...
-wget -O $TMP $PFX$VER$SFX
+
+if [ "x$INPUT_FILE" = "x" ]
+then
+    wget -O $TMP $PFX$VER$SFX
+
+elif [ "x$INPUT_FILE" != "x$TMP" ]
+then
+     echo "Use $INPUT_FILE for input"
+    cp $INPUT_FILE $TMP
+fi
 
 # Build the image:
 docker build -t ssh_compat_suite-$FAM:$VER -f ./TempDockerFile .
-- 
2.31.1

openSUSE Build Service is sponsored by