Introduce a make variable PACKAGE_SITES to improve package fetching in
authorChris Pressey <cpressey@dragonflybsd.org>
Tue, 2 Aug 2005 17:57:14 +0000 (17:57 +0000)
committerChris Pressey <cpressey@dragonflybsd.org>
Tue, 2 Aug 2005 17:57:14 +0000 (17:57 +0000)
two ways:
- PACKAGE_SITES is a list of base URLs where packages are to be fetched
  from; if a package cannot be fetched from the first site, the second
  is tried, etc, until either the package is fetched, or all sites have
  been tried (at which point failure is announced.)  This allows
  multiple sites to be set up as package mirrors.
- PACKAGE_SITES is overridable by the administrator on the make command
  line, so that they may specify where e.g. any custom packages they
  may have shall be fetched from.

nrelease/Makefile

index 6c3f6a6..c1daf67 100644 (file)
@@ -1,4 +1,4 @@
-# $DragonFly: src/nrelease/Makefile,v 1.38 2005/07/14 07:35:52 corecode Exp $
+# $DragonFly: src/nrelease/Makefile,v 1.39 2005/08/02 17:57:14 cpressey Exp $
 #
 
 ISODIR ?= /usr/release
@@ -18,6 +18,8 @@ PACKAGES_LOC?= ${PACKAGES}/All
 .else
 PACKAGES_LOC?= /usr/ports/packages/All
 .endif
+PACKAGE_SITES?=http://www.bsdinstaller.org/packages/ \
+              http://cvs.bsdinstaller.org/packages/
 
 # Specify which root skeletons are required, and let the user include
 # their own.  They are copied into ISODIR during the `pkgcustomizeiso'
@@ -107,7 +109,16 @@ fetchpkgs:
        @if [ ! -f ${PACKAGES_LOC}/${PKG}.tgz ]; then \
                cd ${PACKAGES_LOC} && \
                echo "fetching ${PKG}..." && \
-               fetch http://www.bsdinstaller.org/packages/${PKG}.tgz; \
+               for SITE in ${PACKAGE_SITES}; do \
+                       if [ ! -f ${PKG}.tgz ]; then \
+                               fetch $${SITE}${PKG}.tgz || \
+                                   echo "Not available from $${SITE}"; \
+                       fi; \
+               done; \
+               if [ ! -f ${PKG}.tgz ]; then \
+                       echo "Couldn't retrieve ${PKG}.tgz!"; \
+                       exit 1; \
+               fi; \
        fi
 .endfor