Subject: Suggested change to README.html generation: tables for binaries
To: None <tech-pkg@netbsd.org>
From: Nathan J. Williams <nathanw@MIT.EDU>
List: tech-pkg
Date: 11/06/1999 20:42:35
I was looking at the README.html for a bunch of packages, and found
the list of binary packages to be somewhat annoying to use. It's long,
and not sorted by either version or architecture. I figured that a
table with versions vs. architectures would be a good way to do this. 

The implementation is in the patch to bsd.pkg.mk and README.pkg
below. The code is gross, but I think that there's not much to be done
about that. The README.pkg change should probably go in anyway, since
the current bsd.pkg.mk does emit table stuff for slightly nicer
arrangement.

The big downside I see to this patch is that it makes the pages much
less readable with non-table-aware browsers (Lynx, for example). I
don't know what we expect the audience of this HTML to be,
really. It's been suggested that the people who look for binary
packages on a web page and the people who use non-table-aware browsers
may be completely disjoint sets.

Finally, the ordering of the versions (as suggested by a couple of
folks) puts the latest release on the left, and decreasing across, and
then the -current packages for various versions all the way on the
right. The idea was to make the "most popular" versions the leftmost
ones.

You can look at the audio/mpg123 page generated by this code at
http://www.mit.edu/people/nathanw/netbsd/mpg123-new.html (contrast to
../mpg123-old.html). 

        - Nathan


Index: mk/bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.363
diff -c -r1.363 bsd.pkg.mk
*** bsd.pkg.mk	1999/11/01 11:15:20	1.363
--- bsd.pkg.mk	1999/11/07 01:24:48
***************
*** 2169,2174 ****
--- 2169,2177 ----
  		;;							\
  	*)								\
  		cd ${PACKAGES}/../..;					\
+ 		for i in [1-9].*; do echo $$i; done > $@.tmp1;		\
+ 		rels=`grep -v '[a-zA-Z]' $@.tmp1 | sort -nr ; 		\
+ 			grep '[a-zA-Z]' $@.tmp1 | sort -n`;		\
  		for i in [1-9].*/*; do (				\
  			d=$$i/${PKGREPOSITORYSUBDIR} ; 			\
  			if [ -d "$$d" ]; then 				\
***************
*** 2180,2209 ****
  					fi ;				\
  				done ; 					\
  			fi ) ; 						\
! 		done | ${AWK} -F/ '					\
  			{						\
  				release = $$1;				\
  				arch = $$2; 				\
  				pkg = $$3;				\
! 				gsub("\.tgz","", pkg);			\
! 				if (arch != "m68k") {			\
! 					if (arch in urls)		\
! 						urls[arch "/" pkg "/" release] = "<a href=\"${PKG_URL}/" release "/" arch "/${PKGREPOSITORYSUBDIR}/" pkg "${PKG_SUFX}\">" pkg "</a>, " urls[arch]; \
! 					else				\
! 						urls[arch "/" pkg "/" release] = "<a href=\"${PKG_URL}/" release "/" arch "/${PKGREPOSITORYSUBDIR}/" pkg "${PKG_SUFX}\">" pkg "</a> "; \
  				}					\
  			} 						\
  			END { 						\
! 				for (av in urls) {			\
! 					split(av, ava, "/");		\
! 					arch=ava[1];			\
! 					pkg=ava[2];			\
! 					release=ava[3];			\
! 					print "<TR><TD><LI> " arch ": <TD>" urls[av] " <TD>(${OPSYS} " release ")"; \
  				}					\
  			} '						\
  		;;							\
  	esac
  .endif
  
  ################################################################
--- 2183,2233 ----
  					fi ;				\
  				done ; 					\
  			fi ) ; 						\
! 		done > $@.tmp2;						\
! 		(grep -v '^[0-9.]*[a-zA-Z]' $@.tmp2 | sort -r -t/ +0 -1 ; grep '^[0-9.]*[a-zA-Z]' $@.tmp2 | sort -t/ +0 -1) | sort -s -t/ +1 -2	\
! 			| ${AWK} -F/ -v rels="$$rels" '	\
! 		BEGIN	{	numreleases = split(rels,releaselist,"\n");	\
! 				numarches = 0;				\
! 				numurls = 0;				\
! 			}						\
  			{						\
  				release = $$1;				\
  				arch = $$2; 				\
  				pkg = $$3;				\
! 				if (arch == "m68k")			\
! 					next;				\
! 				if (archset[arch] != 1)	{		\
! 					archlist[numarches++] = arch;	\
! 					archset[arch] = 1;		\
  				}					\
+ 				gsub("\.tgz","", pkg);			\
+ 				urlarch[numurls] = arch;		\
+ 				urlrel[numurls] = release;		\
+ 				urls[numurls++] = "<a href=\"${PKG_URL}/" release "/" arch "/${PKGREPOSITORYSUBDIR}/" pkg "${PKG_SUFX}\">" pkg "</a>";	\
  			} 						\
  			END { 						\
! 				pkgnum = 0;				\
! 				print "<TR><TD>";			\
! 				for (r = 1; r <= numreleases; r++) {	\
! 					print " <TD align=center>" releaselist[r];	\
! 				}					\
! 				for (a = 0; a < numarches; a++) {	\
! 					arch = archlist[a];		\
! 					print "<TR><TD>" arch;		\
! 					for (r = 1; r <= numreleases; r++) {	\
! 						rel = releaselist[r];	\
! 						print "<TD>";		\
! 						while (	urlrel[pkgnum] == rel && \
! 								urlarch[pkgnum] == arch) {	\
! 							print urls[pkgnum++];	\
! 						}			\
! 					}				\
  				}					\
  			} '						\
  		;;							\
  	esac
+ 	@${RM} -f $@.tmp1 $@.tmp2 
+ 
  .endif
  
  ################################################################
Index: templates/README.pkg
===================================================================
RCS file: /cvsroot/pkgsrc/templates/README.pkg,v
retrieving revision 1.12
diff -c -r1.12 README.pkg
*** README.pkg	1999/11/03 04:12:48	1.12
--- README.pkg	1999/11/07 01:24:48
***************
*** 51,59 ****
--- 51,61 ----
  Select one of the links below to <FONT COLOR=red>download</FONT> the
  package in precompiled binary form for the following machine
  architectures: 
+ <TABLE>
  <UL>
  %%BIN_PKGS%%
  </UL>
+ </TABLE>
  
  The NetBSD packages collection is designed to permit
              easy <a href="../../README">installation from source</a> -