Re: [PATCH v2 08/10] make-setup-generated: optionally add GIT metadata

"Michael S. Tsirkin" <[email protected]> Fri, 10 Oct 2025 07:52:24 -0400
Newsgroups dev.linux.lists.virtio-comment
Message-ID <[email protected]>
On Fri, Oct 10, 2025 at 12:20:08PM +0100, Alex Bennée wrote:
> This isn't a full conversion to git based metadata but it allows for
> local builds to add git commit and tree status to the final built
> product. The normal formal build process is unaffected and uses
> manually updated VERSION, REVISION and REVISION-DATE metadata.

This violates oasis naming guidelines but I guess
as long as it is very clear this has no status beyond
a development help - okay I guess....

So what is the name format?


> Signed-off-by: Alex Bennée <[email protected]>
> Message-ID: <[email protected]>

Pls avoid Message-ID trailers in patches you post. It's really confusing.

> ---
>  make-setup-generated.sh | 32 ++++++++++++++++++++++++++++----
>  makeall.sh              |  4 ++--
>  makehtml.sh             |  2 +-
>  makepdf.sh              |  2 +-
>  4 files changed, 32 insertions(+), 8 deletions(-)
> 
> diff --git a/make-setup-generated.sh b/make-setup-generated.sh
> index 2c5c7f8..8d33ac5 100755
> --- a/make-setup-generated.sh
> +++ b/make-setup-generated.sh
> @@ -1,16 +1,31 @@
>  #! /bin/sh
> +#
> +# Generate version and metadata preamble for the document
> +#
>  
>  DATESTR=${DATESTR:-`cat REVISION-DATE 2>/dev/null`}
> -if [ x"$DATESTR" = x ]; then
> -    ISODATE=`git show --format=format:'%cd' --date=iso | head -n 1`
> -    DATESTR=`date -d "$DATE" +'%d %B %Y'`
> +
> +# If a second argument is passed we extract what we can from git
> +# metadata (closest lightweight tag) and local tree status. This
> +# allows locally generated copies to be tagged appropriately.
> +#
> +# The formal build process skips this.
> +if ! test -z "$2"; then
> +    TAG=$(git describe --dirty --tags)
> +    # base date on now
> +    DATESTR=$(date +'%d %B %Y')
> +    COMMIT=$(git rev-parse --short HEAD)
> +
> +    # Finally check if we have un-committed changes in the tree
> +    if ! git diff-index --quiet HEAD -- ; then
> +        COMMIT="$COMMIT with local changes"
> +    fi
>  fi
>  
>  case "$1" in
>      *-wd*)
>  	STAGE=wd
>  	STAGENAME="Working Draft"
> -	WORKINGDRAFT=`basename "$1" | sed 's/.*-wd//'`
>  	;;
>      *-os*)
>  	STAGE=os

This is used in the generated latex:
make-setup-generated.sh:\newcommand{\virtioworkingdraft}{$WORKINGDRAFT}

Are you sure output for a wd is unaffected?
We still need to be able to generate these for the TC process.


> @@ -41,6 +56,15 @@ esac
>  
>  VERSION=`echo "$1"| sed -e 's/virtio-v//' -e 's/-.*//'`
>  
> +#
> +# Finally if we are building a local draft copy append the commit
> +# details to the end of the working draft
> +#
> +if ! test -z "$COMMIT" ; then
> +    STAGEEXTRATITLE="$STAGEEXTRATITLE (@ git $COMMIT)"
> +fi
> +
> +
>  #Prepend OASIS unless already there
>  case "$STAGENAME" in
>  	OASIS*)
> diff --git a/makeall.sh b/makeall.sh
> index 37e6c34..5f5d5dc 100755
> --- a/makeall.sh
> +++ b/makeall.sh
> @@ -3,8 +3,8 @@
>  export SPECDOC=${SPECDOC:-`cat REVISION`}
>  export DATESTR=${DATESTR:-`cat REVISION-DATE`}
>  ./makezip.sh
> -./makehtml.sh
> -./makepdf.sh
> +./makehtml.sh $1
> +./makepdf.sh $1
>  zip $SPECDOC.zip $SPECDOC.pdf
>  echo Generated file $SPECDOC.zip
>  echo To change output file name, set SPECDOC environment variable
> diff --git a/makehtml.sh b/makehtml.sh
> index 45b7080..cf1a8d7 100755
> --- a/makehtml.sh
> +++ b/makehtml.sh
> @@ -1,7 +1,7 @@
>  #!/bin/sh
>  
>  SPECDOC=${SPECDOC:-`cat REVISION`}
> -./make-setup-generated.sh "$SPECDOC"
> +./make-setup-generated.sh "$SPECDOC" $1
>  
>  cp virtio-html.tex $SPECDOC.tex
>  
> diff --git a/makepdf.sh b/makepdf.sh
> index 9cae903..bdfb8e5 100755
> --- a/makepdf.sh
> +++ b/makepdf.sh
> @@ -1,7 +1,7 @@
>  #!/bin/sh
>  
>  SPECDOC=${SPECDOC:-`cat REVISION`}
> -./make-setup-generated.sh "$SPECDOC"
> +./make-setup-generated.sh "$SPECDOC" $1
>  
>  rm $SPECDOC.aux $SPECDOC.pdf $SPECDOC.out
>  xelatex --jobname $SPECDOC virtio.tex
> -- 
> 2.47.3
>