X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions%2Ffpkg;h=ee290c5d60f34655547dde689adfcaa9c6eb05c4;hb=1d75c88d37b999ca7af69cb579c15fd4fa282869;hp=673299b339cf035014b87dd18285f0bce4cbdd4d;hpb=405a39d61ac90e763e7428d02447c6b977cad559;p=hvlinux.git diff --git a/functions/fpkg b/functions/fpkg index 673299b..ee290c5 100644 --- a/functions/fpkg +++ b/functions/fpkg @@ -338,35 +338,50 @@ static_getpkg() PREFERRED_EXT="${DEFAULT_ARCH_EXT_LIST}" fi - for arch_ext in ${PREFERRED_EXT}; do - wget_wrapper ${URL} ${PACK}.${arch_ext} - wget_wrapper_status=$? + wget_wrapper_status= + url_list="${URL}" - if [ ${wget_wrapper_status} -eq 1 ]; then - return 1; - fi + if [ x"${URL}" != x"${HV_PACKAGES_URL}" ]; then + url_list+=" ${HV_PACKAGES_URL}" + fi - if [ ${wget_wrapper_status} -eq 2 ]; then - continue; - fi + for url in ${url_list}; do + for arch_ext in ${PREFERRED_EXT}; do + wget_wrapper ${url} ${PACK}.${arch_ext} + wget_wrapper_status=$? - # If we are here, it means the file was successfully downloaded. - FINAL_EXT=${arch_ext} + #if [ ${wget_wrapper_status} -eq 1 ]; then + # return 1; + #fi - # Convert to bzip2 format if requested and if it is a tar/gz archive - if [ -n "${PREFER_BZIP2_ARCHIVE}" ]; then - if is_extension_tar_gzip "${arch_ext}" ; then - rcmd "Converting ${PACK}.${arch_ext} to bzip2 format" \ - gztobz2 ${LFS_PKG_DIR}/${PACK}.${arch_ext} - FINAL_EXT="tar.bz2" + if [ ${wget_wrapper_status} -eq 0 ]; then + break; fi - fi + done - return $? + if [ ${wget_wrapper_status} -eq 0 ]; then + break; + fi done # Failure or file not found - return 1 + if [ ${wget_wrapper_status} -gt 0 ]; then + return 1; + fi + + # If we are here, it means the file was successfully downloaded. + FINAL_EXT=${arch_ext} + + # Convert to bzip2 format if requested and if it is a tar/gz archive + if [ -n "${PREFER_BZIP2_ARCHIVE}" ]; then + if is_extension_tar_gzip "${arch_ext}" ; then + rcmd "Converting ${PACK}.${arch_ext} to bzip2 format" \ + gztobz2 ${LFS_PKG_DIR}/${PACK}.${arch_ext} + FINAL_EXT="tar.bz2" + fi + fi + + return 0 } # Test integrity of archive @@ -425,7 +440,14 @@ test_archive_integrity() # pm (Perl module via CPAN) # fd (freedesktop.org) # -o Option specific to mode -# -s Subdirectory on server +# -s DIR Subdirectory on server +# -v NUM Subdirectory on server is equal to package version. If -s option is specified, then +# append version number to value of -s argument: +# NUM= Full version number +# NUM=1 First number of package version +# NUM=2 First two numbers of package version +# Ex: fpkg -s "v" -v 2 mypkg-1.2.3 http://mypkg.com would fetch from url: +# http://mypkg.com/v1.2/mypkg-1.2.3.tar.bz2 # -w First erase destination file if it exists (except in test mode) fpkg() { @@ -437,9 +459,11 @@ fpkg() local MODE_OPT="" local SRC_DIR="" local FD_SUBDIR_FINAL="" + local VARG="" + unset VOPTION unset ERASE_FIRST - while getopts "d:e:f:m:o:s:w" flag ;do + while getopts "d:e:f:m:o:s:v:w" flag ;do case ${flag} in d) # Fetch directory (where to put file) @@ -462,6 +486,10 @@ fpkg() s) SRC_DIR=${OPTARG} ;; + v) + VOPTION="y" + VARG=${OPTARG} + ;; w) ERASE_FIRST="y" ;; @@ -489,6 +517,29 @@ fpkg() local URL=${2} fi + if [ -n "${VOPTION}" ]; then + # Append version number to SRC_DIR (if specified) + case ${VARG} in + 0) + # Full version number + SRC_DIR+="$(get_pkg_ver ${PACK})" + ;; + 1) + SRC_DIR+="$(get_pkg_ver1 ${PACK})" + ;; + 2) + SRC_DIR+="$(get_pkg_ver2 ${PACK})" + ;; + 3) + SRC_DIR+="$(get_pkg_ver3 ${PACK})" + ;; + *) + echo "${FUNCNAME}(), invalid -v argument: ${VARG}" + return 1 + ;; + esac + fi + if [ -n "${MODE}" ]; then case ${MODE} in gnu)