From: Roger Pau Monne Date: Wed, 13 Jun 2018 07:40:15 +0000 (+0200) Subject: osstest: introduce a FreeBSD build script X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=55e096b528b6147663c67d00b973254818fce49e;p=people%2Froyger%2Fosstest.git osstest: introduce a FreeBSD build script 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é Acked-by: Ian Jackson --- Changes since v4: - Remove some useless comments. - Use qw(git) instead of 'git'. - Replace unicode nonbreaking space. - Remove trail ','. - Improve the way to fetch the version number. 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, qw(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 + +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 + +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, <