{
# HTTP: will return "ERROR 404: Not Found"
# FTP: will say "File not found" or "No such file"
- if grep --ignore-case -e "not found" -e "no such file" ${WGET_LOG_FILE} \
- 1> /dev/null 2>&1; then
+ if grep -q --ignore-case -e "not found" -e "no such file" ${WGET_LOG_FILE}; \
+ then
#echo "404 NOTFOUND"
return 0
fi
# Failure: if it was a connection timeout, don't try for other file
# extensions.
- if grep "failed: Connection timed out" ${WGET_LOG_FILE} \
- 1> /dev/null 2>&1; then
+ if grep -q "failed: Connection timed out" ${WGET_LOG_FILE}; then
echo "Error, wget reported: Connection timed out"
return 1
fi
# 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
# Rename any patch fetched (in fpkg call) and replace SOURCE by TARGET
# in patch name.
- if ls ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch 1> /dev/null 2>&1; then
- echo "CMD=${SRC_FILENAME} ${PACK} ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch"
- rename ${SRC_FILENAME} ${PACK} ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch
+ local PATCHES_LIST="${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch"
+ if ls ${PATCHES_LIST} 1> /dev/null 2>&1; then
+ echo "CMD=${SRC_FILENAME} ${PACK} ${PATCHES_LIST}"
+ rename ${SRC_FILENAME} ${PACK} ${PATCHES_LIST}
fi
fi
}