Subject: Re: Packages with dynamic download sites
To: David Brownlee <abs@formula1.com>
From: Frederick Bruckman <fredb@immanent.net>
List: tech-pkg
Date: 12/19/2001 09:02:20
On Wed, 19 Dec 2001, Frederick Bruckman wrote:

> On Wed, 19 Dec 2001, David Brownlee wrote:
>
> > 	I'm trying to put together a package for a netscape plugin that seems
> > 	to want to have a changing download page (defined in some javascript).

I forgot that the script would need access to the name of the distfile.
So here's a script that parses the site out of the javascript, given the
name of the distfile as argument:

cut here---8\------------------getsites.sh
#!/bin/sh

ftp -o - http://www.cult3d.com/download/viewer/code.js |
awk -F '"' '
/'"$1"'/ {
        sub(/'"$1"'/, "", $2)
        print $2
        exit 0
}'
cut here---8\------------------getsites.sh

And here's an improved patch, to give the script the argument (still not
tested):

Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.882
diff -c -r1.882 bsd.pkg.mk
*** bsd.pkg.mk	2001/12/19 10:29:11	1.882
--- bsd.pkg.mk	2001/12/19 15:01:46
***************
*** 1283,1290 ****
  	${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_DISTDIR}
  .for fetchfile in ${_DISTFILES}
  	${_PKG_SILENT}${_PKG_DEBUG}cd ${_DISTDIR};			\
  	sortedsites=`${SORTED_MASTER_SITES_CMD}`;			\
! 	sites="${MASTER_SITES_${fetchfile:T}} $$sortedsites";		\
  	file="${fetchfile}";						\
  	bfile="${fetchfile:T}";						\
  	${_CHECK_DIST_PATH};						\
--- 1283,1291 ----
  	${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_DISTDIR}
  .for fetchfile in ${_DISTFILES}
  	${_PKG_SILENT}${_PKG_DEBUG}cd ${_DISTDIR};			\
+ 	dynamicsites=`${SH} ${FILESDIR}/getsites.sh $$fetchfile`;	\
  	sortedsites=`${SORTED_MASTER_SITES_CMD}`;			\
! 	sites="$$dynamicsites ${MASTER_SITES_${fetchfile:T}} $$sortedsites"; \
  	file="${fetchfile}";						\
  	bfile="${fetchfile:T}";						\
  	${_CHECK_DIST_PATH};						\


Frederick