[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH 2/2] build: add --full to version.sh to guess $(XEN_FULLVERSION)


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Thu, 9 Sep 2021 12:10:22 +0100
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 09 Sep 2021 11:10:38 +0000
  • Ironport-hdrordr: A9a23:7slNFKFVVSogsWeRpLqE6MeALOsnbusQ8zAXP0AYc3Jom+ij5q STdZUgpHrJYVkqNU3I9ertBEDEewK6yXcX2/hyAV7BZmnbUQKTRekIh7cKgQeQeBEWntQts5 uIGJIeNDSfNzdHsfo=
  • Ironport-sdr: oeS8OCS6MLWm29N85pjyiZpxkOflXHTsDGYpLD1INgTv74mkHaRqwfwq2iXExnnPy2ePlITjqD QYTdkQ5InAMGqh5KgDpoEIlhNXcv+oMxMuW76g1k5IyfyONsElIg2hgcZrEszm9KqAeLK7loto dO1wm7CREQ1s4COC2/p/fwIqByjMwgmzI2uzUY6uM8R+45pvbDKzMv7IQgmK76yz0wtmJN7Ce2 m8Td9cgtWS7MRoKj03ggkbuLfJA6OOiNgTd8GlCOtt8c1FyoUo04KpCpDpi9EWMf/nC9Qh4fk/ EzoGfhZ2WFxmBZk4nmSQYN0g
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Sep 08, 2021 at 02:27:17PM +0200, Jan Beulich wrote:
> On 08.09.2021 11:54, Anthony PERARD wrote:
> > --- a/tools/flask/policy/Makefile.common
> > +++ b/tools/flask/policy/Makefile.common
> > @@ -35,7 +35,7 @@ OUTPUT_POLICY ?= $(BEST_POLICY_VER)
> >  #
> >  ########################################
> >  
> > -POLICY_FILENAME = $(FLASK_BUILD_DIR)/xenpolicy-$(shell $(MAKE) -C 
> > $(XEN_ROOT)/xen xenversion --no-print-directory)
> > +POLICY_FILENAME = $(FLASK_BUILD_DIR)/xenpolicy-$(shell 
> > $(XEN_ROOT)/version.sh --full $(XEN_ROOT)/xen/Makefile)
> 
> Shell scripts better get invoked by "$(SHELL) <script>", to avoid
> depending on the script actually being marked as executable (which is
> impossible on some file systems).
> 
> > --- a/version.sh
> > +++ b/version.sh
> > @@ -1,5 +1,18 @@
> >  #!/bin/sh
> >  
> > +opt_full=false
> > +while [ $# -gt 1 ]; do
> > +    case "$1" in
> > +        --full) opt_full=true ;;
> > +        *) break ;;
> > +    esac
> > +    shift
> > +done
> > +
> >  MAJOR=`grep "export XEN_VERSION" $1 | sed 's/.*=//g' | tr -s " "`
> >  MINOR=`grep "export XEN_SUBVERSION" $1 | sed 's/.*=//g' | tr -s " "`
> > -printf "%d.%d" $MAJOR $MINOR
> > +
> > +if $opt_full; then
> > +    EXTRAVERSION=$(grep "export XEN_EXTRAVERSION" $1 | sed 's/^.* 
> > ?=\s\+//; s/\$([^)]*)//g; s/ //g')
> > +fi
> > +printf "%d.%d%s" $MAJOR $MINOR $EXTRAVERSION
> 
> I guess you want to clear EXTRAVERSION either prior to the "if" or
> in an "else".

Actually, I'm thinking of writing this instead:
    if $opt_full; then
        extraversion=$(grep "export XEN_EXTRAVERSION" $1 | sed 's/^.* ?=\s\+//; 
s/\$([^)]*)//g; s/ //g')
        : ${XEN_EXTRAVERSION:=${extraversion}${XEN_VENDORVERSION}}
    else
        unset XEN_EXTRAVERSION
    fi

This would takes care of cases where a packager add XEN_EXTRAVERSION or
XEN_VENDORVERSION to the environment, and I think would produce the same
result as `make xenversion` in that case.

But that leaves the case of running e.g. "make XEN_VENDORVERSION=-neat
xenversion" out, hopefully, no one does that. Otherwise, we might need
"export" or a new macro in the build system (and that would still leave
out someone having "xen/xen-version" file).

:-( I think I just found a package overriding XEN_VENDORVERSION with a
command line argument, the AUR package. So ./version.sh needs help from
the build system:

Maybe

    XEN_FULLVERSION=$(shell env XEN_EXTRAVERSION=$(XEN_EXTRAVERSION) 
XEN_VENDORVERSION=$(XEN_VENDORVERSION) $(SHELL) $(XEN_ROOT)/version.sh --full 
$(XEN_ROOT)/xen/Makefile)

or probably just exporting those two var in Config.mk or tools/Rules.mk.

Cheers,

-- 
Anthony PERARD



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.