From patchwork Thu Jul 6 14:42:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9828449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 52EDC60361 for ; Thu, 6 Jul 2017 14:44:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42ED8285EA for ; Thu, 6 Jul 2017 14:44:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 375A828645; Thu, 6 Jul 2017 14:44:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4A9DB285EA for ; Thu, 6 Jul 2017 14:44:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dT7zY-0008OM-4I; Thu, 06 Jul 2017 14:42:52 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dT7zX-0008JP-5o for xen-devel@lists.xenproject.org; Thu, 06 Jul 2017 14:42:51 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id B1/12-02177-A6C4E595; Thu, 06 Jul 2017 14:42:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsXitHSDvW6mT1y kwc5jIhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bP7gtsBafdK/Y197M0MC627mJk55AQ8Jc4 X9bFyMnBJqAjcXHuTrYuRg4OEQEVidt7DUDCzALuEncuLGICsYUFnCW+fVzLCmKzAJWs2DAHL M4rYCVxfN9MMFtCQE/i7cQXjCA2J1D89JUvYLaQgKXEvq/NzBD1ghInZz5hgZivKdG6/Tc7hC 0v0bx1NjNEvaJE/7wHbBMY+WYhaZmFpGUWkpYFjMyrGDWKU4vKUot0jQz1kooy0zNKchMzc3Q NDYz1clOLixPTU3MSk4r1kvNzNzECw6yegYFxB2PPXr9DjJIcTEqivBXmcZFCfEn5KZUZicUZ 8UWlOanFhxhlODiUJHgXegHlBItS01Mr0jJzgAEPk5bg4FES4T3tDJTmLS5IzC3OTIdInWI05 ljQs+ELE8erCf+/MQmx5OXnpUqJ8/J7A5UKgJRmlObBDYJF4iVGWSlhXkYGBgYhnoLUotzMEl T5V4ziHIxKwrxmIFN4MvNK4Pa9AjqFCegUxcYYkFNKEhFSUg2MrhqnXy+9vfStY+PO3ov9fWe W2K418tq26KRJMMcOng5Xi4yEs8U7rr19IP3mdX928RKZEqF3a6ufxK62TglffWJ321yftXkh swTE159+kyDJfr1R95vYh/sn3m2VPaK2I37W2ecvJOr/Tn6ROf2D4dntL1Oe7t0t9/DhpTkhX Ql8b26Jbvs62UWJpTgj0VCLuag4EQBPIxXUvwIAAA== X-Env-Sender: prvs=3536ba782=roger.pau@citrix.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1499352162!46184956!6 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26798 invoked from network); 6 Jul 2017 14:42:48 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-4.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 6 Jul 2017 14:42:48 -0000 X-IronPort-AV: E=Sophos;i="5.40,317,1496102400"; d="scan'208";a="438999911" From: Roger Pau Monne To: Date: Thu, 6 Jul 2017 15:42:20 +0100 Message-ID: <20170706144227.36580-10-roger.pau@citrix.com> X-Mailer: git-send-email 2.11.0 (Apple Git-81) In-Reply-To: <20170706144227.36580-1-roger.pau@citrix.com> References: <20170706144227.36580-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Ian.Jackson@eu.citrix.com, Roger Pau Monne Subject: [Xen-devel] [PATCH v4 09/16] osstest: introduce a FreeBSD build script X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In order to generate the FreeBSD installer image and the install media. The install sets are the vanilla ones generated by the 'ftp' release target. The installer image is handcrafted based on the filesystem created by the 'bootonly' target, which is then populated with the ssh host keys, and setup in order to use the serial console. The other difference from upstream FreeBSD installer images is that the one built by osstest uses a ramdisk instead of relying on the installer media to be somehow attached, either on a CD or USB drive. This is required in order to boot the image from pxelinux (where no CD or USB is actually attached to the host, and everything is fetched from tftp). Due to the nature of the FreeBSD build, the outputs are different from what osstest expects from a buildjob, more specifically path_freebsddist points to a folder that contains the several outputs form this buildjob. Signed-off-by: Roger Pau Monné --- Changes since v3: - Introduce two helpers to perform the build process. - Install packages using target_install_packages. Changes since v2: - Increase build target timeouts. - Use sysrc instead echo to set rc.conf options. Changes since v1: - Remove the ts-build-check FreeBSD hack. - Use pkg-static instead of pkg. - Introduce buildcmd_stamped_logged_root and target_cmd_build_root. - Use target_cmd_build_root and buildcmd_stamped_logged_root in the ts-freebsd-build script. - Fix the script snippets to use <. + +# Consumes the following input runvars: +# +# revision_freebsd: FreeBSD commit ID to generate the install media from. +# tree_freebsd: FreeBSD git tree to fetch the source code from. +# +# Produces the following output: +# +# Compressed install sets: kernel.txz, base.txz +# Compressed debug symbols for the kernel: kernel-dbg.txz +# Manifest file (checkums): MANIFEST +# Installer image: install.img +# +# Sets the following runvar: +# +# path_freebsddist: points to the folder where the above files are stored. +# freebsd_buildversion: version of FreeBSD built. + +use strict qw(vars); +use DBI; +use POSIX; + +unshift @INC, qw(.); +use Osstest; +use Osstest::TestSupport; +use Osstest::BuildSupport; + +tsreadconfig(); + +selectbuildhost(\@ARGV); +builddirsprops(); + +sub install_deps () { + target_install_packages($ho, 'git'); +} + +sub checkout () { + prepbuilddirs(); + + # Remove the directory as root, there might be files owned by root + target_cmd_build_root($ho, 300, $builddir, <<'END'); +# chflags will return error if the directory doesn't exist +chflags -fR noschg freebsd || true +rm -rf freebsd +END + + logm("Checkout the FreeBSD source tree"); + build_clone($ho, 'freebsd', $builddir, 'freebsd', ); +} + +sub build_target($$$) { + my ($target, $prefix, $time) = @_; + + buildcmd_stamped_logged($time, 'freebsd', $target, + $prefix, <) { + target_putfile_root($ho, 30, $file, + "$builddir/freebsd/release/$target/etc/ssh/"); + } + + logm("Configuring the installer image"); + target_cmd_build_root($ho, 30, $builddir, <> etc/ssh/sshd_config +mkdir -p root/.ssh +cat << ENDKEYS > root/.ssh/authorized_keys +$authkeys +ENDKEYS + +# Set host keys permissions +chown root:wheel etc/ssh/ssh_host_*_key* +chmod 0600 etc/ssh/ssh_host_*_key +chmod 0644 etc/ssh/ssh_host_*_key.pub + +# Setup serial console output for stage1 +printf "%s" "-h -S$bauds" >> boot.config +cat << ENDBOOT >> boot/loader.conf +# Serial console configuration +boot_serial="YES" +comconsole_speed="$bauds" +console="comconsole" +boot_verbose="YES" +beastie_disable="YES" + +# mfs boot parameters +mfs_load="YES" +mfs_type="mfs_root" +mfs_name="/mfsroot" +vfs.root.mountfrom="ufs:/dev/ufs/FreeBSD_Install" +ENDBOOT + +# Enable DHCP on all network interfaces +sysrc -f etc/rc.conf ifconfig_DEFAULT=DHCP + +# Remove the local script that launches the installer by default +rm -rf etc/rc.local + +# Create a temporary fstab with the root dir +echo '/dev/ufs/FreeBSD_Install / ufs rw 1 1' > etc/fstab + +# Remove the linked resolv.conf +rm -rf etc/resolv.conf +END + + logm("Create the installer"); + target_cmd_build_root($ho, 900, $builddir, <