X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions-update;h=a72b304ea61d007e386a5488e31e4f3aa70d39a8;hb=907fcfdccdd0ddd33accef87490f9e0b750797ad;hp=d886f24588391d504872942d6195e817d5027af9;hpb=532a0d1a77242192d6809b03ec7c14e271e29e82;p=hvlinux.git diff --git a/functions-update b/functions-update index d886f24..a72b304 100644 --- a/functions-update +++ b/functions-update @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash LFS_PKG_BASE="$(dirname $(pwd))/packages" LFS_PKG_DIR="${LFS_PKG_BASE}/${LFS_STAGE}" @@ -25,7 +25,7 @@ TETEX_URL="http://www.tug.org/ftp/tex-archive/systems/unix/teTeX" BLFS_XORG_URL="http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg" XORG_URL="http://xorg.freedesktop.org/releases/individual" -WGETCMD="wget --directory-prefix=${LFS_PKG_DIR} --timeout=15 --tries=3 -nc --continue --no-check-certificate -o ${WGET_LOG_FILE}" +WGETCMD="wget --directory-prefix=${LFS_PKG_DIR} --timeout=15 --tries=3 -nc --continue --no-check-certificate --no-verbose --output-file=${WGET_LOG_FILE}" LFS_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-lfs.html BLFS_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-blfs.html @@ -40,6 +40,10 @@ static_fetch_patches_list() PATCHES_LIST_FILENAME=${2} ${WGETCMD} "${PATCHES_URL}/" && + + # Append log to global log file + cat ${WGET_LOG_FILE} >> ${LFS_LOG_FILE} && + mv ${LFS_PKG_DIR}/index.html ${PATCHES_LIST_FILENAME} } @@ -92,11 +96,17 @@ static_checkpatch() local PATCHES_LIST=${2} local PATCHES_URL=${3} - local PATCHES_FOUND=$(cat ${PATCHES_LIST} | grep "${PACK}-" | sed "s/.*\(${PACK}-.*\.patch\).*/\1/") + # 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/") if [ -n "${PATCHES_FOUND}" ]; then for p in ${PATCHES_FOUND}; do - if [ ! -f ${LFS_PKG_DIR}/${p} ]; then - rcmd "Fetching ${p} from ${PATCHES_URL}" ${WGETCMD} ${PATCHES_URL}/${p} + # Remplace les "%2B" par "+" + PATCH_NAME=$(echo ${p} | sed s!%2B!\+!g) + + if [ ! -f ${LFS_PKG_DIR}/${PATCH_NAME} ]; then + rcmd "Fetching ${PATCH_NAME} from ${PATCHES_URL}" ${WGETCMD} ${PATCHES_URL}/${p} fi done fi @@ -191,6 +201,7 @@ detect_file_not_found() echo "404 NOTFOUND" return 0 elif grep "No such file" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then + echo "No such file" return 0 else return 1 @@ -218,25 +229,28 @@ static_getpkg() MY_ARCH_EXT="tar.bz2 tar.gz tgz tar.Z" fi - echo " MY_ARCH_EXT=${MY_ARCH_EXT}" - for arch_ext in ${MY_ARCH_EXT}; do # Don't take any chance: remove any partially downloaded file. # If we arrive here, it means the final destination file was not found # so we can safely remove any file prior to trying to download it. rm -f ${LFS_PKG_DIR}/${PACK}.${arch_ext} - ${WGETCMD} ${URL}/${PACK}.${arch_ext} + rcmd "Fetching ${PACK}.${arch_ext}" ${WGETCMD} ${URL}/${PACK}.${arch_ext} wget_status=$? - # Failure: if it was a connection timeout, don't try for other file extensions. + # Append log to global log file + cat ${WGET_LOG_FILE} >> ${LFS_LOG_FILE} + + # 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 echo "Error, wget reported: Connection timed out" return 1 fi if detect_file_not_found; then - # Try next archive extension if web server reported that file is not found. + # Try next archive extension if web server reported that file is not + # found. continue; fi @@ -245,8 +259,9 @@ static_getpkg() return 1 fi - # If we arrive here, it means we were able to successfully download the file. - if [ "x${arch_ext}" = "xtar.gz" -o "x${arch_ext}" = "xtgz" -o "x${arch_ext}" = "xtar.Z" ]; then + # If we are here, it means the file was successfully downloaded. + if [ "x${arch_ext}" = "xtar.gz" -o "x${arch_ext}" = "xtgz" \ + -o "x${arch_ext}" = "xtar.Z" ]; then gztobz2 ${LFS_PKG_DIR}/${PACK}.${arch_ext} fi return $? @@ -309,17 +324,12 @@ fpkg() local PACK=${1} local URL=${2} - local FETCH_STRING="Fetching ${PACK}" if [ -z "${SRC_FILENAME}" ]; then # Default source filename = name of package SRC_FILENAME=${PACK} fi - if [ -n "${FILE_EXT}" ]; then - FETCH_STRING="${FETCH_STRING}.${FILE_EXT}" - fi - if [ -z "${FILE_EXT}" -o \ "x${FILE_EXT}" = "xtar.gz" -o \ "x${FILE_EXT}" = "xtgz" -o \ @@ -348,7 +358,9 @@ fpkg() DEST_FILE=${DEST_DIR}/${PACK}.${FINAL_EXT} if [ ! -f ${DEST_FILE} ]; then - rcmd "${FETCH_STRING}" static_getpkg ${SRC_FILENAME} ${URL} ${FILE_EXT} + set +e + static_getpkg ${SRC_FILENAME} ${URL} ${FILE_EXT} + set -e # Move file if source filename is not equal to package name and/or destination # directory is not the default: @@ -367,13 +379,16 @@ fpkg() # Check for available patches with PACKAGE (TARGET) name. static_getpatch ${PACK} - # Check for available patches with SRC_FILENAME name. - static_getpatch ${SRC_FILENAME} + if [ ${SRC_FILENAME} != ${PACK} ]; then + # Check for available patches with SRC_FILENAME name. + static_getpatch ${SRC_FILENAME} - # 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 - rename ${SRC_FILENAME} ${PACK} ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch + # 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 + fi fi }