Skip to content

Commit 0e685c6

Browse files
authored
Merge pull request #248 from thaJeztah/carry_239_s390x_script
Added support for sles (s390x) in installation script (carry 239)
2 parents f7e4852 + 63fb206 commit 0e685c6

1 file changed

Lines changed: 78 additions & 1 deletion

File tree

install.sh

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ do_install() {
347347
esac
348348
;;
349349

350-
centos|rhel)
350+
centos|rhel|sles)
351351
if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
352352
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
353353
fi
@@ -453,6 +453,10 @@ do_install() {
453453
exit 0
454454
;;
455455
centos|fedora|rhel)
456+
if [ "$(uname -m)" != "s390x" ] && [ "$lsb_dist" = "rhel" ]; then
457+
echo "Packages for RHEL are currently only available for s390x."
458+
exit 1
459+
fi
456460
yum_repo="$DOWNLOAD_URL/linux/$lsb_dist/$REPO_FILE"
457461
if ! curl -Ifs "$yum_repo" > /dev/null; then
458462
echo "Error: Unable to curl repository file $yum_repo, is it valid?"
@@ -527,6 +531,79 @@ do_install() {
527531
echo_docker_as_nonroot
528532
exit 0
529533
;;
534+
sles)
535+
if [ "$(uname -m)" != "s390x" ]; then
536+
echo "Packages for SLES are currently only available for s390x"
537+
exit 1
538+
fi
539+
sles_repo="$DOWNLOAD_URL/linux/$lsb_dist/$REPO_FILE"
540+
opensuse_repo="https://download.opensuse.org/repositories/security:SELinux/SLE_15_SP2/security:SELinux.repo"
541+
if ! curl -Ifs "$sles_repo" > /dev/null; then
542+
echo "Error: Unable to curl repository file $sles_repo, is it valid?"
543+
exit 1
544+
fi
545+
pre_reqs="ca-certificates curl libseccomp2 awk"
546+
(
547+
if ! is_dry_run; then
548+
set -x
549+
fi
550+
$sh_c "zypper install -y $pre_reqs"
551+
$sh_c "zypper addrepo $sles_repo"
552+
if ! is_dry_run; then
553+
cat >&2 <<-'EOF'
554+
WARNING!!
555+
openSUSE repository (https://download.opensuse.org/repositories/security:SELinux) will be enabled now.
556+
Do you wish to continue?
557+
You may press Ctrl+C now to abort this script.
558+
EOF
559+
( set -x; sleep 30 )
560+
fi
561+
$sh_c "zypper addrepo $opensuse_repo"
562+
$sh_c "zypper --gpg-auto-import-keys refresh"
563+
$sh_c "zypper lr -d"
564+
)
565+
pkg_version=""
566+
if [ -n "$VERSION" ]; then
567+
if is_dry_run; then
568+
echo "# WARNING: VERSION pinning is not supported in DRY_RUN"
569+
else
570+
pkg_pattern="$(echo "$VERSION" | sed "s/-ce-/\\\\.ce.*/g" | sed "s/-/.*/g")"
571+
search_command="zypper search -s --match-exact 'docker-ce' | grep '$pkg_pattern' | tail -1 | awk '{print \$6}'"
572+
pkg_version="$($sh_c "$search_command")"
573+
echo "INFO: Searching repository for VERSION '$VERSION'"
574+
echo "INFO: $search_command"
575+
if [ -z "$pkg_version" ]; then
576+
echo
577+
echo "ERROR: '$VERSION' not found amongst zypper list results"
578+
echo
579+
exit 1
580+
fi
581+
search_command="zypper search -s --match-exact 'docker-ce-cli' | grep '$pkg_pattern' | tail -1 | awk '{print \$6}'"
582+
# It's okay for cli_pkg_version to be blank, since older versions don't support a cli package
583+
cli_pkg_version="$($sh_c "$search_command")"
584+
pkg_version="-$pkg_version"
585+
586+
search_command="zypper search -s --match-exact 'docker-ce-rootless-extras' | grep '$pkg_pattern' | tail -1 | awk '{print \$6}'"
587+
rootless_pkg_version="$($sh_c "$search_command")"
588+
rootless_pkg_version="-$rootless_pkg_version"
589+
fi
590+
fi
591+
(
592+
if ! is_dry_run; then
593+
set -x
594+
fi
595+
# install the correct cli version first
596+
if [ -n "$cli_pkg_version" ]; then
597+
$sh_c "zypper install -y docker-ce-cli-$cli_pkg_version"
598+
fi
599+
$sh_c "zypper install -y docker-ce$pkg_version"
600+
if version_gte "20.10"; then
601+
$sh_c "zypper install -y docker-ce-rootless-extras$rootless_pkg_version"
602+
fi
603+
)
604+
echo_docker_as_nonroot
605+
exit 0
606+
;;
530607
*)
531608
if [ -z "$lsb_dist" ]; then
532609
if is_darwin; then

0 commit comments

Comments
 (0)