diff mbox

[RFC,OSSTEST,v1,07/12] ts-debian-di-install: Allow Di Version to come from runvars

Message ID 1452263399-14094-7-git-send-email-ian.campbell@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Campbell Jan. 8, 2016, 2:29 p.m. UTC
and following the lead of the suite arrange for a version selected
from the defaults to be written back to the runvars.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 Osstest/Debian.pm    | 15 ++++++++++++++-
 ts-debian-di-install |  3 ++-
 2 files changed, 16 insertions(+), 2 deletions(-)

Comments

Ian Jackson Jan. 12, 2016, 2:39 p.m. UTC | #1
Ian Campbell writes ("[PATCH RFC OSSTEST v1 07/12] ts-debian-di-install: Allow Di Version to come from runvars"):
> and following the lead of the suite arrange for a version selected
> from the defaults to be written back to the runvars.
...
> -                      debian_guest_suite
> +                      debian_guest_suite debian_guest_diversion

Can we please call this function, ..._di_version ?  Otherwise it sounds
very much like something is being diverted.

> +sub debian_guest_diversion ($) {
> +    my ($gho) = @_;
> +
> +    $gho->{DiVersion} //= guest_var($gho,'diversion',undef);
> +
> +    if (!$gho->{DiVersion}) {
> +	$gho->{DiVersion} = $c{TftpDiVersion};
> +	store_runvar("$gho->{Guest}_diversion", $gho->{DiVersion});

I'm not sure what we should do about the runvar.  `diversion' is a bad
name but there is a risk with `..._di_version' getting confused with
all the `..._revision' fields.

OTOH

osstestdb=> select distinct name from runvars where name like '%version';
         name
         ----------------------
          device_model_version
          (1 row)

osstestdb=>

So maybe guest_di_version would be the right answer.

Aside from the questions about this name, this patch LGTM.

Ian.
Ian Campbell Jan. 15, 2016, 4:33 p.m. UTC | #2
On Tue, 2016-01-12 at 14:39 +0000, Ian Jackson wrote:
> Ian Campbell writes ("[PATCH RFC OSSTEST v1 07/12] ts-debian-di-install:
> Allow Di Version to come from runvars"):
> > and following the lead of the suite arrange for a version selected
> > from the defaults to be written back to the runvars.
> ...
> > -                      debian_guest_suite
> > +                      debian_guest_suite debian_guest_diversion
> 
> Can we please call this function, ..._di_version ?  Otherwise it sounds
> very much like something is being diverted.
> 
> > +sub debian_guest_diversion ($) {
> > +    my ($gho) = @_;
> > +
> > +    $gho->{DiVersion} //= guest_var($gho,'diversion',undef);
> > +
> > +    if (!$gho->{DiVersion}) {
> > +	$gho->{DiVersion} = $c{TftpDiVersion};
> > +	store_runvar("$gho->{Guest}_diversion", $gho->{DiVersion});
> 
> I'm not sure what we should do about the runvar.  `diversion' is a bad
> name but there is a risk with `..._di_version' getting confused with
> all the `..._revision' fields.
> 
> OTOH
> 
> osstestdb=> select distinct name from runvars where name like '%version';
>          name
>          ----------------------
>           device_model_version
>           (1 row)
> 
> osstestdb=>
> 
> So maybe guest_di_version would be the right answer.

Yes, I think so too, I'll go with that.

> Aside from the questions about this name, this patch LGTM.
> 
> Ian.
diff mbox

Patch

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 93b0ad4..f236b41 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -35,7 +35,7 @@  BEGIN {
     @ISA         = qw(Exporter);
     @EXPORT      = qw(debian_boot_setup
                       debian_overlays
-                      debian_guest_suite
+                      debian_guest_suite debian_guest_diversion
                       %preseed_cmds
                       preseed_base
                       preseed_create
@@ -1352,4 +1352,17 @@  sub debian_guest_suite ($) {
     return $gho->{Suite};
 }
 
+sub debian_guest_diversion ($) {
+    my ($gho) = @_;
+
+    $gho->{DiVersion} //= guest_var($gho,'diversion',undef);
+
+    if (!$gho->{DiVersion}) {
+	$gho->{DiVersion} = $c{TftpDiVersion};
+	store_runvar("$gho->{Guest}_diversion", $gho->{DiVersion});
+    }
+
+    return $gho->{DiVersion};
+}
+
 1;
diff --git a/ts-debian-di-install b/ts-debian-di-install
index 9a513d3..9875bef 100755
--- a/ts-debian-di-install
+++ b/ts-debian-di-install
@@ -151,7 +151,8 @@  sub setup_netboot($$$)
 	die if $r{ "$gho->{Guest}_netboot_kernel" }
 	||     $r{ "$gho->{Guest}_netboot_ramdisk" };
 
-	my $di_path = $c{TftpPath}.'/'.$ho->{Tftp}{DiBase}.'/'.${arch}.'/'.$c{TftpDiVersion}.'-'.$ho->{Suite};
+	my $di_path = $c{TftpPath}.'/'.$ho->{Tftp}{DiBase}.'/'.${arch}.'/'.\
+	    debian_guest_diversion($ho).'-'.$ho->{Suite};
 
         if (${arch} =~ m/amd64|i386/) {
 	    $kernel = "$di_path/vmlinuz-xen";