Skip to content

Commit 02cb80d

Browse files
authored
Merge pull request #569 from thaJeztah/cleanup_ver
minor cleanups and fixes
2 parents 4e49bdc + ae0db93 commit 02cb80d

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

install.sh

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -587,44 +587,49 @@ do_install() {
587587
fi
588588

589589
pkg_version=""
590+
cli_pkg_version=""
590591
if [ -n "$VERSION" ]; then
591592
if is_dry_run; then
592593
echo "# WARNING: VERSION pinning is not supported in DRY_RUN"
593594
else
594595
# Will work for incomplete versions IE (17.12), but may not actually grab the "latest" if in the test channel
595596
pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/~ce~.*/g' | sed 's/-/.*/g')"
596597
search_command="apt-cache madison docker-ce | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3"
597-
pkg_version="$($sh_c "$search_command")"
598598
echo "INFO: Searching repository for VERSION '$VERSION'"
599599
echo "INFO: $search_command"
600+
pkg_version="$($sh_c "$search_command")"
600601
if [ -z "$pkg_version" ]; then
601602
echo
602603
echo "ERROR: '$VERSION' not found amongst apt-cache madison results"
603604
echo
604605
exit 1
605606
fi
607+
pkg_version="=$pkg_version"
608+
606609
if version_gte "18.09"; then
607-
search_command="apt-cache madison docker-ce-cli | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3"
608-
echo "INFO: $search_command"
609-
cli_pkg_version="=$($sh_c "$search_command")"
610+
search_command="apt-cache madison docker-ce-cli | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3"
611+
echo "INFO: $search_command"
612+
cli_pkg_version="$($sh_c "$search_command")"
613+
if [ -n "$cli_pkg_version" ]; then
614+
cli_pkg_version="=$cli_pkg_version"
615+
fi
610616
fi
611-
pkg_version="=$pkg_version"
612617
fi
613618
fi
614619
(
615-
pkgs="docker-ce${pkg_version%=}"
620+
pkgs="docker-ce${pkg_version}"
616621
if version_gte "18.09"; then
617-
# older versions didn't ship the cli and containerd as separate packages
618-
pkgs="$pkgs docker-ce-cli${cli_pkg_version%=} containerd.io"
622+
# older versions didn't ship the cli and containerd as separate packages
623+
pkgs="$pkgs docker-ce-cli${cli_pkg_version} containerd.io"
619624
fi
620625
if version_gte "20.10"; then
621-
pkgs="$pkgs docker-compose-plugin docker-ce-rootless-extras$pkg_version"
626+
pkgs="$pkgs docker-compose-plugin docker-ce-rootless-extras$pkg_version"
622627
fi
623628
if version_gte "23.0"; then
624-
pkgs="$pkgs docker-buildx-plugin"
629+
pkgs="$pkgs docker-buildx-plugin"
625630
fi
626631
if version_gte "28.2"; then
627-
pkgs="$pkgs docker-model-plugin"
632+
pkgs="$pkgs docker-model-plugin"
628633
fi
629634
if ! is_dry_run; then
630635
set -x
@@ -680,6 +685,7 @@ do_install() {
680685
fi
681686

682687
pkg_version=""
688+
cli_pkg_version=""
683689
if command_exists dnf; then
684690
pkg_manager="dnf"
685691
pkg_manager_flags="-y -q --best"
@@ -698,22 +704,23 @@ do_install() {
698704
fi
699705
pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/\\\\.ce.*/g' | sed 's/-/.*/g').*$pkg_suffix"
700706
search_command="$pkg_manager list --showduplicates docker-ce | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'"
701-
pkg_version="$($sh_c "$search_command")"
702707
echo "INFO: Searching repository for VERSION '$VERSION'"
703708
echo "INFO: $search_command"
709+
pkg_version="$($sh_c "$search_command")"
704710
if [ -z "$pkg_version" ]; then
705711
echo
706712
echo "ERROR: '$VERSION' not found amongst $pkg_manager list results"
707713
echo
708714
exit 1
709715
fi
716+
# Cut out the epoch and prefix with a '-'
717+
pkg_version="-$(echo "$pkg_version" | cut -d':' -f 2)"
718+
710719
if version_gte "18.09"; then
711720
# older versions don't support a cli package
712721
search_command="$pkg_manager list --showduplicates docker-ce-cli | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'"
713722
cli_pkg_version="$($sh_c "$search_command" | cut -d':' -f 2)"
714723
fi
715-
# Cut out the epoch and prefix with a '-'
716-
pkg_version="-$(echo "$pkg_version" | cut -d':' -f 2)"
717724
fi
718725
fi
719726
(

0 commit comments

Comments
 (0)