# 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=${*}
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)
s)
SRC_DIR=${OPTARG}
;;
+ w)
+ ERASE_FIRST="y"
+ ;;
?)
echo "${FUNCNAME}(): Invalid option: ${OPTARG}."
return 1
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
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