From 49f2f0b441a3b835b180bcd4ef8fc3cc9209067e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 29 Apr 2021 14:37:13 +0200 Subject: [PATCH] build: fix sed command for linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following command ended up being missinterpreted on linux, generating a wrong file named ceph.clusterserviceversion.yaml'\'' with broken quotes. Making it an array ensures the command and the args are parsed correctly. Tested on both linux and macos. Signed-off-by: Sébastien Han --- cluster/olm/ceph/generate-rook-csv.sh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/cluster/olm/ceph/generate-rook-csv.sh b/cluster/olm/ceph/generate-rook-csv.sh index 460f6f2eb..2021cfc03 100755 --- a/cluster/olm/ceph/generate-rook-csv.sh +++ b/cluster/olm/ceph/generate-rook-csv.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e ################## @@ -76,7 +76,8 @@ ROOK_OP_VERSION=$3 ############# # VARIABLES # ############# -SED_I=${SED_CMD:-"sed -i'' -e"} +SED_I=(sed -i'' -e) +[ -n "$SED_CMD" ] || read -ra SED_CMD <<< "${SED_I[@]}" YQ_CMD_DELETE=($yq delete -i) YQ_CMD_MERGE_OVERWRITE=($yq merge --inplace --overwrite --prettyPrint) YQ_CMD_MERGE=($yq merge --inplace --append -P ) @@ -222,26 +223,26 @@ function hack_csv() { # rook-ceph-osd --> serviceAccountName # rook-ceph-osd --> rule - $SED_I 's/rook-ceph-global/rook-ceph-system/' "$CSV_FILE_NAME" - $SED_I 's/rook-ceph-object-bucket/rook-ceph-system/' "$CSV_FILE_NAME" - $SED_I 's/rook-ceph-cluster-mgmt/rook-ceph-system/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/rook-ceph-global/rook-ceph-system/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/rook-ceph-object-bucket/rook-ceph-system/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/rook-ceph-cluster-mgmt/rook-ceph-system/' "$CSV_FILE_NAME" - $SED_I 's/rook-ceph-mgr-cluster/rook-ceph-mgr/' "$CSV_FILE_NAME" - $SED_I 's/rook-ceph-mgr-system/rook-ceph-mgr/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/rook-ceph-mgr-cluster/rook-ceph-mgr/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/rook-ceph-mgr-system/rook-ceph-mgr/' "$CSV_FILE_NAME" - $SED_I 's/cephfs-csi-nodeplugin/rook-csi-cephfs-plugin-sa/' "$CSV_FILE_NAME" - $SED_I 's/cephfs-external-provisioner-runner/rook-csi-cephfs-provisioner-sa/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/cephfs-csi-nodeplugin/rook-csi-cephfs-plugin-sa/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/cephfs-external-provisioner-runner/rook-csi-cephfs-provisioner-sa/' "$CSV_FILE_NAME" - $SED_I 's/rbd-csi-nodeplugin/rook-csi-rbd-plugin-sa/' "$CSV_FILE_NAME" - $SED_I 's/rbd-external-provisioner-runner/rook-csi-rbd-provisioner-sa/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/rbd-csi-nodeplugin/rook-csi-rbd-plugin-sa/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/rbd-external-provisioner-runner/rook-csi-rbd-provisioner-sa/' "$CSV_FILE_NAME" # The operator-sdk also does not properly respect when # Roles differ from the Service Account name # The operator-sdk instead assumes the Role/ClusterRole is the ServiceAccount name # # To account for these mappings, we have to replace Role/ClusterRole names with # the corresponding ServiceAccount. - $SED_I 's/cephfs-external-provisioner-cfg/rook-csi-cephfs-provisioner-sa/' "$CSV_FILE_NAME" - $SED_I 's/rbd-external-provisioner-cfg/rook-csi-rbd-provisioner-sa/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/cephfs-external-provisioner-cfg/rook-csi-cephfs-provisioner-sa/' "$CSV_FILE_NAME" + "${SED_I[@]}" 's/rbd-external-provisioner-cfg/rook-csi-rbd-provisioner-sa/' "$CSV_FILE_NAME" } function generate_package() {