[salt.sh] Ignoring files using rsync 53/59653/4
authorJunaid Ali <junaidali.yahya@gmail.com>
Tue, 10 Jul 2018 14:39:50 +0000 (15:39 +0100)
committerJunaid Ali <junaidali.yahya@gmail.com>
Thu, 12 Jul 2018 10:49:46 +0000 (11:49 +0100)
  Currently rsync is not ignoring '.gitignore' file due to the
  specification of absolute path. This patch fixes the issue and
  also ignores the temporary directory if that is created inside
  the cloned fuel repo

  PatchSet2: Shell check
  PatchSet3: Minor improvements
  PatchSet4: Rebasing the commit

Change-Id: I05fc39236af1bc6f8eabb668304ba5a32dec0737
Signed-off-by: Junaid Ali <junaidali.yahya@gmail.com>
mcp/scripts/salt.sh

index 4a20bc4..dc2226e 100755 (executable)
@@ -29,8 +29,14 @@ NODE_MASK="${LOCAL_VIRT_NODES// /|}"
 # push to cfg01 current git repo first (including submodules), at ~ubuntu/opnfv
 # later we move it to ~root/opnfv (and ln as ~root/fuel); delete the temp clone
 remote_tmp="${SSH_SALT}:$(basename "${OPNFV_TMP_DIR}")"
+STORAGE_DIR=$(dirname "${LOCAL_PDF_RECLASS}")
+REL_STORAGE_DIR_PATH=${STORAGE_DIR#${LOCAL_GIT_DIR}}
+if [[ "${REL_STORAGE_DIR_PATH}" == "${STORAGE_DIR}" ]]
+then
+  REL_STORAGE_DIR_PATH=""
+fi
 rsync -Erl --delete -e "ssh ${SSH_OPTS}" \
-  --exclude-from="${F_GIT_ROOT}/.gitignore" \
+  --exclude={.gitignore,"$REL_STORAGE_DIR_PATH"} \
   "${LOCAL_GIT_DIR}/" "${remote_tmp}/"
 if [ -n "${LOCAL_PDF_RECLASS}" ] && [ -f "${LOCAL_PDF_RECLASS}" ]; then
   rsync -e "ssh ${SSH_OPTS}" "${LOCAL_PDF_RECLASS}" \