Changeset 93135fd
- Timestamp:
- 05/03/2006 12:25:38 AM (18 years ago)
- Branches:
- 1.0, 2.3, 2.3.x, 2.4, ablfs, ablfs-more, legacy, new_features, trunk
- Children:
- 511923a
- Parents:
- 47e524f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/common-functions
r47e524f r93135fd 628 628 } 629 629 630 631 630 #----------------------------# 632 631 get_sources() { # Download file, write name to MISSING_FILES.DMP if an error 632 #----------------------------# 633 local saveIFS=$IFS 634 local IFS line URL1 URL2 FILE MD5 HAVEMD5 fromARCHIVE 635 636 # Test if the packages must be downloaded 637 [ ! "$GETPKG" = "1" ] && return 638 639 gs_wrt_message(){ 640 echo "${RED}$1${OFF}" 641 echo "$1" >> MISSING_FILES.DMP 642 } 643 # Housekeeping 644 [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources 645 cd $BUILDDIR/sources 646 [[ -f MD5SUMS ]] && rm MD5SUMS 647 [[ -f MD5SUMS-$VERSION ]] && rm MD5SUMS-$VERSION 648 [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP 649 [[ -f urls.lst ]] && rm urls.lst 650 651 # Download a fresh MD5SUMS file 652 wget $SERVER/pub/lfs/conglomeration/MD5SUMS 653 654 # Generate URLs file 655 create_urls 656 657 IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only 658 for line in `cat urls.lst`; do 659 IFS=$saveIFS # Restore the system defaults 660 661 # Skip some packages if they aren't needed 662 case $line in 663 */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* ) 664 [[ "$TEST" = "0" ]] && continue 665 ;; 666 */vim-*-lang* ) 667 [[ "$VIMLANG" = "0" ]] && continue 668 ;; 669 esac 670 671 # Locations 672 URL1=`echo $line | cut -d" " -f1` # Upstream URL 673 URL2=`echo $line | cut -d" " -f2` # Fallback URL 674 FILE=`basename $URL2` # File name 675 676 # Find the md5 sum for this package. 677 set +e 678 HAVEMD5=1 # Always assume we have a MD5SUM 679 MD5=`grep " $FILE" MD5SUMS` 680 if [ $? -ne 0 ]; then 681 set -e 682 gs_wrt_message "$FILE not found in MD5SUMS" 683 # IMPORTANT:: There is no MD5SUM for this file. 684 HAVEMD5=0 685 fi 686 687 set -e 688 # If the file exists in the archive copy it to the 689 # $BUILDDIR/sources dir. MD5SUM will be validated later. 690 if [ ! -z ${SRC_ARCHIVE} ] && 691 [ -d ${SRC_ARCHIVE} ] && 692 [ -f ${SRC_ARCHIVE}/$FILE ]; then 693 cp ${SRC_ARCHIVE}/$FILE . 694 echo "$FILE: -- copied from $SRC_ARCHIVE" 695 fromARCHIVE=1 696 else 697 echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}" 698 fromARCHIVE=0 699 # If the file does not exist in /sources download a fresh one 700 if [ ! -f $FILE ] ; then 701 if ! wget $URL1 && ! wget $URL2 ; then 702 gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING" 703 continue 704 fi 705 fi 706 fi 707 708 # Is there a MD5SUM to validate the file against. 709 if [[ "$HAVEMD5" = "1" ]] ; then 710 # IF the md5sum does not match the existing files 711 if ! echo "$MD5" | md5sum -c - >/dev/null ; then 712 [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}" 713 [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}" 714 # Remove the old file and download a new one 715 rm -fv $FILE 716 # Force generation of MD5SUM and storage in SRC_ARCHIVE 717 fromARCHIVE=0; HAVEMD5=0 718 # Try and retrieve the file 719 # I swap server priority to allow for corruption on the primary site 720 if ! wget -N $URL1 && ! wget -N $URL2 ; then 721 gs_wrt_message "$FILE not found on the servers.. SKIPPING" 722 continue 723 fi 724 fi 725 fi 726 727 # Validate the MD5SUM one last time 728 if [[ "$HAVEMD5" = "1" ]] && ! echo "$MD5" | md5sum -c - >/dev/null ; then 729 gs_wrt_message "$FILE does not match MD5SUMS value" 730 fi 731 732 # Generate a fresh MD5SUM for this file 733 if [[ "$HAVEMD5" = "0" ]] ; then 734 echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE" 735 echo "NEW MD5SUM $(md5sum $FILE)" >> MISSING_FILES.DMP 736 fi 737 738 # Good or bad we write the original md5sum to a file 739 echo "$MD5" >> MD5SUMS-$VERSION 740 741 # Copy the freshly downloaded file 742 # to the source archive. 743 if [ ! -z ${SRC_ARCHIVE} ] && 744 [ -d ${SRC_ARCHIVE} ] && 745 [ -w ${SRC_ARCHIVE} ] && 746 [ "$fromARCHIVE" = "0" ] ; then 747 echo "Storing file:<$FILE> in the package archive" 748 cp -f $FILE ${SRC_ARCHIVE} 749 fi 750 751 done 752 753 if [[ -s MISSING_FILES.DMP ]]; then 754 echo -e "\n\n${tab_}${RED} One or more files were not retrieved or have a bad MD5SUMS chechsum.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n" 755 # Do not allow the automatic exection of the Makefile. 756 echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}" 757 RUNMAKE=0 758 fi 759 } 760 761 762 763 #----------------------------# 764 get_sourcesX() { # Download file, write name to MISSING_FILES.DMP if an error 633 765 #----------------------------# 634 766 local saveIFS=$IFS
Note:
See TracChangeset
for help on using the changeset viewer.