source: common/libs/func_download_pkgs@ 560bef1

2.4 ablfs-more legacy new_features trunk
Last change on this file since 560bef1 was 3158dfa, checked in by Matthew Burgess <matthew@…>, 13 years ago

Remove GETKERNEL parameter. The kernel has been required for its headers since LFS-6.3.

  • Property mode set to 100644
File size: 6.8 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
[7072e1f]42 */check* | */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
[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
[134572c]88 [[ $BOOKMD5 = "BOOTSCRIPTS-MD5SUM" ]] && continue
89 [[ $BOOKMD5 = "UDEV-MD5SUM" ]] && continue
[5210ae1]90
[fe30c61]91 # IF the md5sum does not match the existing files
92 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
93 [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
94 [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
95 # Remove the old file and download a new one
96 rm -fv $FILE
97 # Force storage in SRC_ARCHIVE
98 fromARCHIVE=0;
99 # Try to retrieve again the file. Servers in reverse order.
[de63126]100 if ! wget $URL2 $WGETPARAM && ! wget $URL1 $WGETPARAM ; then
[fe30c61]101 gs_wrt_message "$FILE not found on the servers.. SKIPPING"
102 continue
103 fi
104 fi
105
106 # Validate the MD5SUM one last time
107 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
108 gs_wrt_message "$FILE does not match MD5SUMS value"
109 # Force generation of MD5SUM
110 HAVEMD5=0
111 fi
112
113 # Generate a fresh MD5SUM for this file
114 if [[ "$HAVEMD5" = "0" ]] ; then
115 echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
116 echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
117 fi
118
119 # Good or bad we write the original md5sum to a file
[93fd2d0]120 echo "$MD5" >> MD5SUMS
[fe30c61]121
122 # Copy the freshly downloaded file
123 # to the source archive.
124 if [ ! -z ${SRC_ARCHIVE} ] &&
125 [ -d ${SRC_ARCHIVE} ] &&
126 [ -w ${SRC_ARCHIVE} ] &&
127 [ "$fromARCHIVE" = "0" ] ; then
128 echo "Storing file:<$FILE> in the package archive"
129 cp -f $FILE ${SRC_ARCHIVE}
130 fi
131
132 done
133
134 if [[ -s MISSING_FILES.DMP ]]; then
135 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"
136 # Do not allow the automatic execution of the Makefile.
137 echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
138 RUNMAKE="n"
139 fi
140}
141
142#----------------------------#
143create_urls() { #
144#----------------------------#
145 cd $JHALFSDIR
146
147 case ${PROGNAME} in
148 clfs)
149 echo -n "Creating CLFS <${ARCH}> specific URLs file"
150 xsltproc --nonet --xinclude \
151 --stringparam server $SERVER \
[a9ca77f]152 --stringparam family clfs \
[fe30c61]153 -o $BUILDDIR/sources/urls.lst urls.xsl \
154 $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
155 echo " ...OK"
156 ;;
157 clfs2)
158 echo -n "Creating CLFS2 <${ARCH}> specific URLs file"
159 xsltproc --nonet --xinclude \
160 --stringparam server $SERVER \
[a9ca77f]161 --stringparam family clfs \
[fe30c61]162 -o $BUILDDIR/sources/urls.lst urls.xsl \
163 $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
164 echo " ...OK"
165 ;;
166 clfs3)
167 echo -n "Creating CLFS3 <${ARCH}> specific URLs file"
168 xsltproc --nonet --xinclude \
169 --stringparam server $SERVER \
[a9ca77f]170 --stringparam family clfs \
[fe30c61]171 -o $BUILDDIR/sources/urls.lst urls.xsl \
172 $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
173 echo " ...OK"
174 ;;
175 hlfs)
[139c34e]176 echo -n "Creating HLFS <${MODEL}> + <${KERNEL}> specific URLs file"
[fe30c61]177 xsltproc --nonet --xinclude \
178 --stringparam server $SERVER \
[a9ca77f]179 --stringparam family lfs \
[fe30c61]180 --stringparam model $MODEL \
[139c34e]181 --stringparam kernel $KERNEL \
[fe30c61]182 -o $BUILDDIR/sources/urls.lst urls.xsl \
183 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
184 echo " ...OK"
185 ;;
186 lfs)
187 echo -n "Creating LFS specific URLs file"
188 xsltproc --nonet --xinclude \
189 --stringparam server $SERVER \
[a9ca77f]190 --stringparam family lfs \
[7072e1f]191 --stringparam pkgmngt $PKGMNGT \
[fe30c61]192 -o ../sources/urls.lst urls.xsl \
193 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
194 echo " ...OK"
195 ;;
196 esac
197
198 cd $BUILDDIR/sources
199
200 if [[ "${BLFS_TOOL}" = "y" ]]; then
201 add_blfs_deps_urls
202 fi
203
204 if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
205 add_CustomToolsURLS
206 fi
207
208}
209
Note: See TracBrowser for help on using the repository browser.