From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: [PATCH OSSTEST v2 08/15] Debian: add preseed_create_guest helper Date: Mon, 28 Apr 2014 11:41:29 +0100 Message-ID: <1398681696-2773-8-git-send-email-ian.campbell@citrix.com> References: <1398681672.29700.55.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1398681672.29700.55.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: ian.jackson@eu.citrix.com Cc: Ian Campbell , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Creates a preseed file suitable for use in a PV guest Signed-off-by: Ian Campbell --- Osstest/Debian.pm | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm index ab09abb..043ab0d 100644 --- a/Osstest/Debian.pm +++ b/Osstest/Debian.pm @@ -35,6 +35,7 @@ BEGIN { %preseed_cmds preseed_base preseed_create + preseed_create_guest preseed_hook_command preseed_hook_installscript di_installcmdline_core ); @@ -429,6 +430,8 @@ sub di_installcmdline_core ($$;@) { sub preseed_base ($$;@) { my ($suite,$extra_packages,%xopts) = @_; + $extra_packages ||= ''; + return <<"END"; d-i mirror/suite string $suite @@ -498,7 +501,66 @@ $xopts{ExtraPreseed} ### END OF DEBIAN PRESEED BASE END -} +} + +sub preseed_create_guest ($$;@) { + my ($ho, $sfx, %xopts) = @_; + + my $suite= $xopts{Suite} || $c{DebianSuite}; + + my $extra_packages; + + my $preseed_file= preseed_base($suite, $extra_packages, %xopts); + $preseed_file.= (<.ssh/authorized_keys +$authkeys +ENDKEYS + +u=osstest +h=/home/\$u +mkdir /target\$h/.ssh +cp .ssh/authorized_keys /target\$h/.ssh +chroot /target chown -R \$u.\$u \$h/.ssh + +rm -f /target/etc/ssh/ssh_host_*_key +rm -f /target/etc/ssh/ssh_host_*_key.pub + +cat <<'ENDKEYS' > /target/etc/ssh/ssh_host_rsa_key +$host_rsa_key +ENDKEYS +chmod 0600 /target/etc/ssh/ssh_host_rsa_key +END + + foreach my $di_key (keys %preseed_cmds) { + $preseed_file .= "d-i preseed/$di_key string ". + (join ' && ', @{ $preseed_cmds{$di_key} }). "\n"; + } + + return create_webfile($ho, "preseed$sfx", $preseed_file); +} sub preseed_create ($$;@) { my ($ho, $sfx, %xopts) = @_; -- 1.9.0