diff --git a/mod_for_factory_scripts/500copyQualDb b/mod_for_factory_scripts/500copyQualDb index 9f48039191..778d8dc600 100755 --- a/mod_for_factory_scripts/500copyQualDb +++ b/mod_for_factory_scripts/500copyQualDb @@ -5,17 +5,25 @@ # found in the LICENSE file. TEST_DIR="${ROOT_FS_DIR}/usr/local/autotest/site_tests/hardware_Components" -COMPONENTS_FILE="${TEST_DIR}/qualified_components" -# If QUALDB not specified, use the one based on board name. +pushd ${TEST_DIR} 1> /dev/null + if [ -z ${QUALDB} ]; then - QUALDB="${TEST_DIR}/qualified_components_${BOARD}" + # If QUALDB not specified, check the existence of the qualified components + # belonging to the board. + QUALDB="qualified_components_${BOARD}*" + FIRST_QUALDB=$(ls $QUALDB | head -1) + if [ ! -z ${FIRST_QUALDB} ]; then + # Remove qualified components belonging to other boards + ls qualified_components* | grep -v qualified_components_${BOARD} \ + | xargs rm -f + else + echo "No qualified component file found at: ${QUALDB}" + fi +else + rm -f qualified_components* + echo "Copying ${QUALDB} to the image." + cp -f ${QUALDB} ${TEST_DIR}/ fi -if [ ! -z ${QUALDB} ] && [ -f ${QUALDB} ]; then - # Copy the qualified component file to the image - echo "Copying ${QUALDB} to the image." - cp -f ${QUALDB} ${COMPONENTS_FILE} -else - echo "No qualified component file found at: ${QUALDB}" -fi +popd 1> /dev/null