X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions%2Ffpkg;h=c420d7ba0b2f92e12033b221104032a31861dc98;hb=16e556be676ab727a73d9a98bcd7d68fb5a29f4f;hp=3330eed0977401962e7b0c8882e8bdf4e5ef75c3;hpb=16f1a75d215e027ad746fc60dd10cd456f07f8d6;p=hvlinux.git diff --git a/functions/fpkg b/functions/fpkg index 3330eed..c420d7b 100644 --- a/functions/fpkg +++ b/functions/fpkg @@ -301,8 +301,8 @@ test_archive_integrity() # pm (Perl module via CPAN) # fd (freedesktop.org) # -o Option specific to mode -# -h Display this help and returns # -s Subdirectory on server +# -w First erase destination file if it exists (except in test mode) fpkg() { local ORIG_ARGS=${*} @@ -313,8 +313,9 @@ fpkg() local MODE_OPT="" local SRC_DIR="" local FD_SUBDIR_FINAL="" + unset ERASE_FIRST - while getopts "d:e:f:m:o:s:" flag ;do + while getopts "d:e:f:m:o:s:w" flag ;do case ${flag} in d) # Fetch directory (where to put file) @@ -337,6 +338,9 @@ fpkg() s) SRC_DIR=${OPTARG} ;; + w) + ERASE_FIRST="y" + ;; ?) echo "${FUNCNAME}(): Invalid option: ${OPTARG}." return 1 @@ -507,9 +511,13 @@ fpkg() DEST_FILE=${DEST_DIR}/${PACK}.${FINAL_EXT} - if [ ! -f ${DEST_FILE} ]; then - if [ -z "${TEST_INTEGRITY}" ]; then - # Fetch package, unless we are testing integrity + if [ -z "${TEST_INTEGRITY}" ]; then + if [ -f ${DEST_FILE} -a -n "${ERASE_FIRST}" ]; then + rm ${DEST_FILE} + fi + + if [ ! -f ${DEST_FILE} ]; then + # Fetch package set +e static_getpkg ${SRC_FILENAME} ${URL} ${FILE_EXT} set -e @@ -523,9 +531,7 @@ fpkg() mv ${DOWNLOADED_FILE} ${DEST_FILE} fi fi - fi - - if [ -n "${TEST_INTEGRITY}" ]; then + else set +e test_archive_integrity "${PACK}" "${DEST_FILE}" "${FINAL_EXT}" set -e