source: common/libs/func_download_pkgs@ 897416c

2.4 ablfs-more legacy new_features trunk
Last change on this file since 897416c was de84c00, checked in by Pierre Labastie <pierre@…>, 11 years ago

download and builds the test programs, even if tests are disabled

  • Property mode set to 100644
File size: 6.1 KB
RevLine 
[fe30c61]1#!/bin/bash
2
3# $Id$
4
5
6#----------------------------#
7get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
8#----------------------------#
9 local saveIFS=$IFS
[de63126]10 local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE WGETPARAM
11
12 WGETPARAM=""
13 if [[ "${RETRYSRCDOWNLOAD}" = "y" ]] ; then
14 WGETPARAM+="--retry-connrefused"
15 fi
16 WGETPARAM+=" --tries ${RETRYDOWNLOADCNT}"
17 WGETPARAM+=" --timeout ${DOWNLOADTIMEOUT}"
[fe30c61]18
19 # Test if the packages must be downloaded
20 [ ! "$GETPKG" = "y" ] && return
21
22 gs_wrt_message(){
23 echo "${RED}$1${OFF}"
24 echo "$1" >> MISSING_FILES.DMP
25 }
26 # Housekeeping
27 [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
28 cd $BUILDDIR/sources
29 [[ -f MD5SUMS ]] && rm MD5SUMS
30 [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
31 [[ -f urls.lst ]] && rm urls.lst
32
33 # Generate URLs file
34 create_urls
35
36 IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
37 for line in `cat urls.lst`; do
38 IFS=$saveIFS # Restore the system defaults
39
40 # Skip some packages if they aren't needed
41 case $line in
[de84c00]42 */tree* | */gcc-testsuite* ) #unneeded now?
[fe30c61]43 [[ "$TEST" = "0" ]] && continue
44 ;;
[7072e1f]45 */vim-*-lang* )
[fe30c61]46 [[ "$VIMLANG" = "0" ]] && continue
47 ;;
48 esac
49
50 # Locations
51 URL1=`echo $line | cut -d" " -f2` # Preferred URL
52 URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
53 FILE=`basename $URL1` # File name
54 BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
55
56 # Validation pair
57 MD5="$BOOKMD5 $FILE"
58 HAVEMD5=1
59
60 set -e
61 # If the file exists in the archive copy it to the
62 # $BUILDDIR/sources dir. MD5SUM will be validated later.
63 if [ ! -z ${SRC_ARCHIVE} ] &&
64 [ -d ${SRC_ARCHIVE} ] &&
65 [ -f ${SRC_ARCHIVE}/$FILE ]; then
66 cp ${SRC_ARCHIVE}/$FILE .
67 echo "$FILE: -- copied from $SRC_ARCHIVE"
68 fromARCHIVE=1
69 else
70 fromARCHIVE=0
71 # If the file does not exist yet in /sources download a fresh one
72 if [ ! -f $FILE ] ; then
[9d55d85]73 if [[ ! ("$SRC_ARCHIVE" = "") ]] ; then
[7072e1f]74 echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE} or ${BUILDDIR}/sources${OFF}"
[9d55d85]75 else
[7072e1f]76 echo "${BOLD}${YELLOW}$FILE: not found in ${BUILDDIR}/sources${OFF}"
[9d55d85]77 fi
[de63126]78 if ! wget $URL1 $WGETPARAM && ! wget $URL2 $WGETPARAM ; then
[fe30c61]79 gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
80 continue
81 fi
[7072e1f]82 else
83 echo "${BOLD}${YELLOW}$FILE: using cached file in ${BUILDDIR}/sources${OFF}"
[fe30c61]84 fi
85 fi
86
[5210ae1]87 # Deal with udev and bootscripts m5sum issue
[0700131]88 [[ $BOOKMD5 = "BOOTSCRIPTS-MD5SUM" ]] && continue
89 [[ $BOOKMD5 = "UDEV-MD5SUM" ]] && continue
90 [[ $BOOKMD5 = "LFS-NETSCRIPTS-MD5SUM" ]] && continue
[5210ae1]91
[fe30c61]92 # IF the md5sum does not match the existing files
93 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
94 [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
95 [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
96 # Remove the old file and download a new one
97 rm -fv $FILE
98 # Force storage in SRC_ARCHIVE
99 fromARCHIVE=0;
100 # Try to retrieve again the file. Servers in reverse order.
[de63126]101 if ! wget $URL2 $WGETPARAM && ! wget $URL1 $WGETPARAM ; then
[fe30c61]102 gs_wrt_message "$FILE not found on the servers.. SKIPPING"
103 continue
104 fi
105 fi
106
107 # Validate the MD5SUM one last time
108 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
109 gs_wrt_message "$FILE does not match MD5SUMS value"
110 # Force generation of MD5SUM
111 HAVEMD5=0
112 fi
113
114 # Generate a fresh MD5SUM for this file
115 if [[ "$HAVEMD5" = "0" ]] ; then
116 echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
117 echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
118 fi
119
120 # Good or bad we write the original md5sum to a file
[93fd2d0]121 echo "$MD5" >> MD5SUMS
[fe30c61]122
123 # Copy the freshly downloaded file
124 # to the source archive.
125 if [ ! -z ${SRC_ARCHIVE} ] &&
126 [ -d ${SRC_ARCHIVE} ] &&
127 [ -w ${SRC_ARCHIVE} ] &&
128 [ "$fromARCHIVE" = "0" ] ; then
129 echo "Storing file:<$FILE> in the package archive"
130 cp -f $FILE ${SRC_ARCHIVE}
131 fi
132
133 done
134
135 if [[ -s MISSING_FILES.DMP ]]; then
136 echo -e "\n\n${tab_}${RED} One or more files were not retrieved or have bad MD5SUMS.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n"
137 # Do not allow the automatic execution of the Makefile.
138 echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
139 RUNMAKE="n"
140 fi
141}
142
143#----------------------------#
144create_urls() { #
145#----------------------------#
146 cd $JHALFSDIR
147
148 case ${PROGNAME} in
[809a821]149 clfs*)
[fe30c61]150 echo -n "Creating CLFS <${ARCH}> specific URLs file"
151 xsltproc --nonet --xinclude \
152 --stringparam server $SERVER \
[a9ca77f]153 --stringparam family clfs \
[fe30c61]154 -o $BUILDDIR/sources/urls.lst urls.xsl \
[809a821]155 $BOOK/BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]156 echo " ...OK"
157 ;;
158 hlfs)
[139c34e]159 echo -n "Creating HLFS <${MODEL}> + <${KERNEL}> specific URLs file"
[fe30c61]160 xsltproc --nonet --xinclude \
161 --stringparam server $SERVER \
[a9ca77f]162 --stringparam family lfs \
[fe30c61]163 --stringparam model $MODEL \
[139c34e]164 --stringparam kernel $KERNEL \
[fe30c61]165 -o $BUILDDIR/sources/urls.lst urls.xsl \
166 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
167 echo " ...OK"
168 ;;
169 lfs)
170 echo -n "Creating LFS specific URLs file"
171 xsltproc --nonet --xinclude \
172 --stringparam server $SERVER \
[a9ca77f]173 --stringparam family lfs \
[7072e1f]174 --stringparam pkgmngt $PKGMNGT \
[fe30c61]175 -o ../sources/urls.lst urls.xsl \
176 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
177 echo " ...OK"
178 ;;
179 esac
180
181 cd $BUILDDIR/sources
182
183 if [[ "${BLFS_TOOL}" = "y" ]]; then
184 add_blfs_deps_urls
185 fi
186
187 if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
188 add_CustomToolsURLS
189 fi
190
191}
192
Note: See TracBrowser for help on using the repository browser.