From 27f490cceec2197f9637188e80290ad619f3dd7a Mon Sep 17 00:00:00 2001 From: Pat Date: Mon, 16 Jan 2023 10:43:54 +0000 Subject: [PATCH] install: specify version to install script (#6693) * install: add support for specifying version Signed-off-by: Patrick Stephens * install: add option for dry run or other prefix Signed-off-by: Patrick Stephens * packaging: add config to tests Signed-off-by: Patrick Stephens Signed-off-by: Patrick Stephens --- install.sh | 19 ++++++++++++++++--- packaging/test-release-packages.sh | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index ba712fb76c7..316ce42f879 100755 --- a/install.sh +++ b/install.sh @@ -5,6 +5,11 @@ set -e RELEASE_URL=${FLUENT_BIT_PACKAGES_URL:-https://packages.fluentbit.io} RELEASE_KEY=${FLUENT_BIT_PACKAGES_KEY:-$RELEASE_URL/fluentbit.key} +# Optionally specify the version to install +RELEASE_VERSION=${FLUENT_BIT_RELEASE_VERSION:-} +# Optionally prefix install commands, e.g. use 'echo ' here to prevent installation after repo set up. +INSTALL_CMD_PREFIX=${FLUENT_BIT_INSTALL_COMMAND_PREFIX:-} + echo "================================" echo " Fluent Bit Installation Script " echo "================================" @@ -35,6 +40,14 @@ else sudo -k fi +# Set up version pinning +APT_VERSION='' +YUM_VERSION='' +if [[ -n "${RELEASE_VERSION}" ]]; then + APT_VERSION="=$RELEASE_VERSION" + YUM_VERSION="-$RELEASE_VERSION" +fi + # Now set up repos and install dependent on OS, version, etc. # Will require sudo case ${OS} in @@ -55,7 +68,7 @@ enabled=1 EOF sed -i 's|VERSION_ARCH_SUBSTR|\$releasever/\$basearch/|g' /etc/yum.repos.d/fluent-bit.repo cat /etc/yum.repos.d/fluent-bit.repo -yum -y install fluent-bit +$INSTALL_CMD_PREFIX yum -y install fluent-bit$YUM_VERSION SCRIPT ;; centos|centoslinux|rhel|redhatenterpriselinuxserver|fedora|rocky|almalinux) @@ -73,7 +86,7 @@ enabled=1 EOF sed -i 's|VERSION_ARCH_SUBSTR|\$releasever/\$basearch/|g' /etc/yum.repos.d/fluent-bit.repo cat /etc/yum.repos.d/fluent-bit.repo -yum -y install fluent-bit +$INSTALL_CMD_PREFIX yum -y install fluent-bit$YUM_VERSION SCRIPT ;; ubuntu|debian) @@ -88,7 +101,7 @@ deb [signed-by=/usr/share/keyrings/fluentbit-keyring.gpg] $RELEASE_URL/${OS}/${C EOF cat /etc/apt/sources.list.d/fluent-bit.list apt-get -y update -apt-get -y install fluent-bit +$INSTALL_CMD_PREFIX apt-get -y install fluent-bit$APT_VERSION SCRIPT ;; *) diff --git a/packaging/test-release-packages.sh b/packaging/test-release-packages.sh index 13687939a81..8573a32da17 100755 --- a/packaging/test-release-packages.sh +++ b/packaging/test-release-packages.sh @@ -52,6 +52,8 @@ do $CONTAINER_RUNTIME run --rm -t \ -e FLUENT_BIT_PACKAGES_URL="${FLUENT_BIT_PACKAGES_URL:-https://packages.fluentbit.io}" \ -e FLUENT_BIT_PACKAGES_KEY="${FLUENT_BIT_PACKAGES_KEY:-https://packages.fluentbit.io/fluentbit.key}" \ + -e FLUENT_BIT_RELEASE_VERSION="${FLUENT_BIT_RELEASE_VERSION:-}" \ + -e FLUENT_BIT_INSTALL_COMMAND_PREFIX="${FLUENT_BIT_INSTALL_COMMAND_PREFIX:-}" \ $EXTRA_MOUNTS \ "$IMAGE" \ sh -c "$INSTALL_CMD && /opt/fluent-bit/bin/fluent-bit --version" | tee "$LOG_FILE" @@ -68,6 +70,8 @@ do $CONTAINER_RUNTIME run --rm -t \ -e FLUENT_BIT_PACKAGES_URL="${FLUENT_BIT_PACKAGES_URL:-https://packages.fluentbit.io}" \ -e FLUENT_BIT_PACKAGES_KEY="${FLUENT_BIT_PACKAGES_KEY:-https://packages.fluentbit.io/fluentbit.key}" \ + -e FLUENT_BIT_RELEASE_VERSION="${FLUENT_BIT_RELEASE_VERSION:-}" \ + -e FLUENT_BIT_INSTALL_COMMAND_PREFIX="${FLUENT_BIT_INSTALL_COMMAND_PREFIX:-}" \ $EXTRA_MOUNTS \ "$IMAGE" \ sh -c "apt-get update && apt-get install -y gpg curl;$INSTALL_CMD && /opt/fluent-bit/bin/fluent-bit --version" | tee "$LOG_FILE"