source: common/libs/func_download_pkgs@ 38ae01f

2.3 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 38ae01f was 139c34e, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

HLFS: Select the proper kernel package for packages list and download.

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