From 16e556be676ab727a73d9a98bcd7d68fb5a29f4f Mon Sep 17 00:00:00 2001 From: gobo72 Date: Fri, 11 Mar 2011 19:28:13 +0000 Subject: [PATCH] Ajout option pour effacer un fichier avant de le re-telecharger --- functions/fpkg | 22 ++++++++++++++-------- stage4/packages-update | 4 ++-- 2 files changed, 16 insertions(+), 10 deletions(-) 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 diff --git a/stage4/packages-update b/stage4/packages-update index 5bd7d05..f8da0ae 100755 --- a/stage4/packages-update +++ b/stage4/packages-update @@ -16,8 +16,8 @@ for module in ${XORG_MODULES_LIST}; do MOD_NAME=$(get_pkg_name ${module}) DEST_DIR=${LFS_PKG_DIR}/${MOD_NAME} - fpkg -d ${DEST_DIR} -e wget ${module} ${BLFS_XORG_URL} - fpkg -d ${DEST_DIR} -e md5 ${module} ${BLFS_XORG_URL} + fpkg -d ${DEST_DIR} -e wget -w ${module} ${BLFS_XORG_URL} + fpkg -d ${DEST_DIR} -e md5 -w ${module} ${BLFS_XORG_URL} if [ "${MOD_NAME}" = "driver" ]; then if [ -n "${XORG_VIDEO_DRIVER}" ]; then -- 2.20.1