tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Adding options to README.html files
I didn't read the patch but love the idea.
> On Jul 27, 2015, at 9:00 PM, Daniel Loffgren <netbsd!daniel%loffgren.org@localhost> wrote:
>
> The readme target(s) of pkgsrc don’t currently show the build options for each package. This has always slightly annoyed me, since I often find myself building a package, then finding out afterwards that I needed a build option that wasn’t default, or just plain forgetting to check the build options available. I’ve got a patch for generating and inserting a table of options into the README.html, which I use for my local copies of pkgsrc. Is this something that other people might want, too? If so, here it is:
>
> Index: mk/scripts/genreadme.awk
> ===================================================================
> RCS file: /cvsroot/pkgsrc/mk/scripts/genreadme.awk,v
> retrieving revision 1.35
> diff -u -r1.35 genreadme.awk
> --- mk/scripts/genreadme.awk 9 May 2013 23:37:27 -0000 1.35
> +++ mk/scripts/genreadme.awk 20 Jul 2015 04:47:08 -0000
> @@ -165,6 +165,15 @@
> next;
> }
>
> +/^htmloptions / {
> + htmloptions = $3;
> + for (i = 4; i <= NF; i++){
> + htmloptions = htmloptions " " $i;
> + }
> + options[$2] = htmloptions;
> + next;
> +}
> +
> /^index / {
> #
> # read lines like:
> @@ -396,6 +405,8 @@
> gsub(/%%VULDATE%%/, ""vuldate"");
> gsub(/%%RUN_DEPENDS%%/, ""rundeps"");
>
> + gsub(/%%OPTIONS%%/, ""options[toppkg]"");
> +
> line = $0;
>
> if( line ~/%%BIN_PKGS%%/ ) {
> Index: mk/scripts/htmloptions.awk
> ===================================================================
> RCS file: mk/scripts/htmloptions.awk
> diff -N mk/scripts/htmloptions.awk
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ mk/scripts/htmloptions.awk 20 Jul 2015 04:47:08 -0000
> @@ -0,0 +1,25 @@
> +#!/usr/bin/awk -f
> +
> +BEGIN {
> + FS = "\t";
> +}
> +
> +/^\t/ {
> + o++;
> + printf "<tr><td>%s</td><td>%s</td></tr>", $2, $3;
> +}
> +
> +/^These options are/ {
> + finalize();
> + exit;
> +}
> +
> +END {
> + finalize();
> +}
> +
> +function finalize() {
> + if(o == 0) {
> + printf "<tr><td><EM>none</EM></tr></td>";
> + }
> +}
> Index: mk/scripts/mkdatabase
> ===================================================================
> RCS file: /cvsroot/pkgsrc/mk/scripts/mkdatabase,v
> retrieving revision 1.9
> diff -u -r1.9 mkdatabase
> --- mk/scripts/mkdatabase 18 Nov 2005 11:07:27 -0000 1.9
> +++ mk/scripts/mkdatabase 20 Jul 2015 04:47:08 -0000
> @@ -160,6 +160,11 @@
> esac
>
>
> +here=`pwd`
> +tmp1=`dirname "$here"`
> +pkgcat=`basename "$tmp1"`
> +pkg=`basename "$here"`
> +pkgpath=$pkgcat/$pkg
> if [ $append_flag = yes ]; then
> echo "$prompt Appending to database in ${DATABASE}"
> if [ ! -f "${DATABASE}" ]; then
> @@ -167,11 +172,6 @@
> fi
> # make sure we haven't already been listed before
> # appending ourselves.
> - here=`pwd`
> - tmp1=`dirname "$here"`
> - pkgcat=`basename "$tmp1"`
> - pkg=`basename "$here"`
> - pkgpath=$pkgcat/$pkg
> case $debug_flag in
> yes) echo "Looking for $pkgpath before appending";;
> esac
> @@ -184,7 +184,9 @@
> fi
> else
> echo "$prompt Creating new database in ${DATABASE}"
> - ${BMAKE} print-summary-data > "${DATABASE}" || exit 1
> + o=`${BMAKE} show-options | ${AWK} -f ../../mk/scripts/htmloptions.awk`
> + echo "htmloptions ${pkgpath} $o" > ${DATABASE}
> + ${BMAKE} print-summary-data >> "${DATABASE}" || exit 1
> fi
> here=`pwd`
> echo "$prompt Depending in $here (pass #1)"
> Index: mk/scripts/mkreadme
> ===================================================================
> RCS file: /cvsroot/pkgsrc/mk/scripts/mkreadme,v
> retrieving revision 1.27
> diff -u -r1.27 mkreadme
> --- mk/scripts/mkreadme 13 Jun 2015 12:09:32 -0000 1.27
> +++ mk/scripts/mkreadme 20 Jul 2015 04:47:08 -0000
> @@ -381,6 +381,7 @@
> echo " but the directory does not exist. Please fix this!" > /dev/stderr
> else
> cd ${PKGSRCDIR}/${c}/${pkgdir}
> + o=`${BMAKE} show-options | ${AWK} -f ${PKGSRCDIR}/mk/scripts/htmloptions.awk`
> l=`${BMAKE} print-summary-data`
> if [ $? != 0 ]; then
> echo "WARNING (printdepends): the package in ${c}/${pkgdir} had problem with" \
> @@ -391,6 +392,7 @@
> ${BMAKE} print-summary-data 2>&1 > /dev/stderr
> else
> echo "$l" >> $DATABASEFILE
> + echo "htmloptions ${c}/${pkgdir} $o" >> $DATABASEFILE
> fi
> fi
> if [ "x$quiet" = "xno" ]; then
> Index: templates/README.pkg
> ===================================================================
> RCS file: /cvsroot/pkgsrc/templates/README.pkg,v
> retrieving revision 1.26
> diff -u -r1.26 README.pkg
> --- templates/README.pkg 18 Mar 2010 10:18:19 -0000 1.26
> +++ templates/README.pkg 20 Jul 2015 04:47:08 -0000
> @@ -68,6 +68,13 @@
> </p>
>
> <p>
> +This package supports the following build-time options:
> +<TABLE>
> +%%OPTIONS%%
> +</TABLE>
> +</p>
> +
> +<p>
> Select one of the links below to <FONT COLOR="red">download</FONT> the
> package in precompiled binary form for installation with pkg_add(1).
> Available machine architectures and package versions:
Home |
Main Index |
Thread Index |
Old Index