X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;ds=sidebyside;f=functions%2Ffpkg;h=1fc6ec4e8b69054f3650c3c610eb95bb6417da4e;hb=498549fb1b100f0649a8fcee8a5f5a0e0593369a;hp=fed9089c6158fd68b327c58de93d542c893e24a1;hpb=05a63ae322941e807a917d83bed8348202e22807;p=hvlinux.git diff --git a/functions/fpkg b/functions/fpkg index fed9089..1fc6ec4 100644 --- a/functions/fpkg +++ b/functions/fpkg @@ -16,9 +16,25 @@ BLFS_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-blfs.html CLFS_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-clfs.html HV_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-hv.html -FTYPE_ARCHIVE="0" -FTYPE_PATCH="1" -FTYPE_OTHER="2" +# Test if the given file extension correspond to a compressed archive +# Arg. #1: File extension +is_extension_archive() +{ + if [ ${#} -ne 1 ]; then + echo "${FUNCNAME}(), wrong number of arguments: ${*}" + return 1 + fi + + local EXT=${1} + + for k in "gz" "tgz" "Z" "zip" "xz" "bz2"; do + if [ "x${EXT}" = "x${k}" ]; then + return 0 + fi + done + + return 1 +} # Test if the given file extension correspond to a tar/gzip archive # Arg. #1: File extension @@ -68,23 +84,19 @@ remove_partial_file() # Download a file, and making sure it is valid (at least it's header!) # Arg. #1: Source URL. # Arg. #2: Source filename (on server) -# Arg. #3: File type: 0 : Archive -# 2 : Patch -# 1 : Other # # Return: 0 : success # 1 : wget error -# 2 : File not found or not an archive +# 2 : File not found or not an archive (if file extension was archive type) wget_wrapper() { - if [ ${#} -lt 2 -a ${#} -gt 3 ]; then + if [ ${#} -lt 2 ]; then echo "${FUNCNAME}(), wrong number of arguments: ${*}" return 1 fi local URL=${1} local SOURCE=${2} - local FTYPE=${3} remove_partial_file ${LFS_PKG_DIR}/${SOURCE} @@ -113,14 +125,18 @@ wget_wrapper() fi if [ ${wget_status} -ne 0 ]; then + echo "Error: wget returned error status ${wget_status}" >> \ + ${LFS_LOG_FILE} remove_partial_file ${LFS_PKG_DIR}/${SOURCE} return 1 fi - if [ "x${FTYPE}" = "x${FTYPE_ARCHIVE}" ]; then + local FEXT=${SOURCE##*.} + if is_extension_archive "${FEXT}"; then # Just to be sure, test if downloaded file is really an archive: if ! is_archive ${LFS_PKG_DIR}/${SOURCE}.part; then # Partial failure if file is invalid. + echo "Error: failed archive test" >> ${LFS_LOG_FILE} remove_partial_file ${LFS_PKG_DIR}/${SOURCE} return 2 fi @@ -215,16 +231,24 @@ static_checkpatch() # Remplace les "+" par "%2B" local PACK_URL=$(echo $PACK | sed s!\+!%2B!g) - local PATCHES_FOUND=$(cat ${PATCHES_LIST} | grep "${PACK_URL}-" | sed "s/.*\(${PACK_URL}-.*\.patch\).*/\1/") + # Patches list formats (patches-list-*.html): + # LFS: a href="name.patch" + # hugovil: A HREF "dir/subdir/subdir/name.patch + # We must search for a patch beginning with either a slash or a " to avoid + # the possibility of having another package name within a patch name: + # if patch = Mesalib-8.0.4-llvm-3.1-fixes-1.patch + # then we could erroneously try to download patch "llvm-3.1-fixes-1.patch" + local PATCHES_FOUND=$(cat ${PATCHES_LIST} | \ + egrep "\"${PACK_URL}-|/${PACK_URL}-" | \ + sed "s/.*\(${PACK_URL}-.*\.patch\)\".*/\1/") + if [ -n "${PATCHES_FOUND}" ]; then for p in ${PATCHES_FOUND}; do # Remplace les "%2B" par "+" PATCH_NAME=$(echo ${p} | sed s!%2B!\+!g) if [ ! -f ${LFS_PKG_DIR}/${PATCH_NAME} ]; then - # String uses $PATCH_NAME and not $p ??? - #####rcmd "Fetching ${PATCH_NAME} from ${PATCHES_URL}" wget_wrapper ${PATCHES_URL} ${p} ${FTYPE_OTHER} - wget_wrapper ${PATCHES_URL} ${p} ${FTYPE_PATCH} + wget_wrapper ${PATCHES_URL} ${PATCH_NAME} fi done fi @@ -303,7 +327,7 @@ static_getpkg() fi for arch_ext in ${PREFERRED_EXT}; do - wget_wrapper ${URL} ${PACK}.${arch_ext} ${FTYPE_ARCHIVE} + wget_wrapper ${URL} ${PACK}.${arch_ext} wget_wrapper_status=$? if [ ${wget_wrapper_status} -eq 1 ]; then @@ -463,7 +487,7 @@ fpkg() fi if [ -z "${FILE_EXT}" ]; then # Default file extension is tar.gz - FILE_EXT="tar.gz" + FILE_EXT="tar.xz" fi ;; gnome) @@ -473,6 +497,10 @@ fpkg() SRC_DIR=$(get_pkg_name ${PACK}) fi SRC_DIR="${SRC_DIR}/$(get_pkg_ver2 ${PACK})" + if [ -z "${FILE_EXT}" ]; then + # Default file extension is xz + FILE_EXT="tar.xz" + fi ;; sf) URL=${SOURCEFORGE_URL}