Improve quoting of asterisks 12/23812/4
authorVratko Polak <vrpolak@cisco.com>
Thu, 5 Dec 2019 16:07:24 +0000 (17:07 +0100)
committerPeter Mikus <pmikus@cisco.com>
Thu, 5 Dec 2019 17:14:51 +0000 (17:14 +0000)
When quoted, the asterisks are understood as literal characters.
When unquoted, so they act as globs patterns.

When used to match files already present in the filesystem,
the asterisks should be unquoted.
When used to match a package name (not a file),
the asterisks should be quoted to prevent the bash expansion,
as programs such as apt-get and yum do their own expasion afterwards.

Unquoted asterisks for matching package names
may happen to work when there are no files to match the bash expansion,
but quoted asterisks are sure to avoid accidents.

Also, we want an asterisk both before and after "vpp",
due to package names such as libvppinfra-dev and python3-vpp-api.

Change-Id: I657a24c24a71d865915aba201bd0d3276cb33281
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
resources/libraries/bash/function/gather.sh
resources/libraries/python/DUTSetup.py

index 429a2cc..0bef292 100644 (file)
@@ -124,10 +124,10 @@ function gather_vpp () {
     # - ${CSIT_DIR}/DPDK_STABLE_VER - DPDK version to use
     #   by csit-vpp not-timed jobs.
     # - ${CSIT_DIR}/VPP_STABLE_VER_UBUNTU - Ubuntu VPP version to usee.
-    # - ../vpp*.deb|rpm - Relative to ${DOWNLOAD_DIR}, copied for vpp-csit jobs.
+    # - ../*vpp*.deb|rpm - Relative to ${DOWNLOAD_DIR}, copied for vpp-csit jobs.
     # Directories updated:
     # - ${DOWNLOAD_DIR}, vpp-*.deb files are copied here for vpp-csit jobs.
-    # - ./ - Assumed ${DOWNLOAD_DIR}, vpp-*.deb|rpm files
+    # - ./ - Assumed ${DOWNLOAD_DIR}, *vpp*.deb|rpm files
     #   are downloaded here for csit-vpp.
     # Functions called:
     # - die - Print to stderr and exit, defined in common_functions.sh
@@ -157,7 +157,7 @@ function gather_vpp () {
             ;;
         "vpp-csit-"*)
             # Use locally built packages.
-            mv "${DOWNLOAD_DIR}"/../"vpp"*".${PKG_SUFFIX}" "${DOWNLOAD_DIR}"/ || {
+            mv "${DOWNLOAD_DIR}"/../*vpp*."${PKG_SUFFIX}" "${DOWNLOAD_DIR}"/ || {
                 die "Move command failed."
             }
             ;;
index 1cca974..3544997 100644 (file)
@@ -661,7 +661,7 @@ class DUTSetup:
                         node, f"rpm -ivh {vpp_pkg_dir}*.rpm",
                         timeout=120, sudo=True, message=message
                     )
-                    exec_cmd_no_error(node, u"rpm -qai *vpp*", sudo=True)
+                    exec_cmd_no_error(node, u"rpm -qai '*vpp*'", sudo=True)
                     DUTSetup.restart_service(node, Constants.VPP_UNIT)
 
     @staticmethod