From be2f06276732bf84e3b19bbfd707ddcc3e00f678 Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Mon, 12 Mar 2018 11:03:46 +1100 Subject: [PATCH 1/3] Fix test suite on FreeBSD 11 --- libc-test/build.rs | 1 + src/unix/bsd/freebsdlike/freebsd/mod.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index c2394c75559a8..a96bcfd4140f3 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -509,6 +509,7 @@ fn main() { "CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | + "NET_MAXID" | "USER_MAXID" if freebsd => true, // These constants were added in FreeBSD 11 diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 34d34d89ecd26..e7a312741cebc 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3,7 +3,7 @@ pub type clock_t = i32; pub type ino_t = u32; pub type lwpid_t = i32; pub type nlink_t = u16; -pub type blksize_t = u32; +pub type blksize_t = i32; pub type clockid_t = ::c_int; pub type sem_t = _sem; @@ -182,7 +182,9 @@ pub const EOWNERDEAD: ::c_int = 96; pub const ELAST: ::c_int = 96; pub const RLIMIT_NPTS: ::c_int = 11; pub const RLIMIT_SWAP: ::c_int = 12; -pub const RLIM_NLIMITS: ::rlim_t = 13; +pub const RLIMIT_KQUEUES: ::c_int = 13; +pub const RLIMIT_UMTXP: ::c_int = 14; +pub const RLIM_NLIMITS: ::rlim_t = 15; pub const Q_GETQUOTA: ::c_int = 0x700; pub const Q_SETQUOTA: ::c_int = 0x800; @@ -801,10 +803,10 @@ pub const SHUTDOWN_TIME: ::c_short = 8; pub const LC_COLLATE_MASK: ::c_int = (1 << 0); pub const LC_CTYPE_MASK: ::c_int = (1 << 1); -pub const LC_MESSAGES_MASK: ::c_int = (1 << 2); -pub const LC_MONETARY_MASK: ::c_int = (1 << 3); -pub const LC_NUMERIC_MASK: ::c_int = (1 << 4); -pub const LC_TIME_MASK: ::c_int = (1 << 5); +pub const LC_MONETARY_MASK: ::c_int =(1 << 2); +pub const LC_NUMERIC_MASK: ::c_int = (1 << 3); +pub const LC_TIME_MASK: ::c_int = (1 << 4); +pub const LC_MESSAGES_MASK: ::c_int = (1 << 5); pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK From d3e6651ff8bce60a68f66e79d858f81950d85de7 Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Thu, 15 Mar 2018 21:20:07 +1100 Subject: [PATCH 2/3] Update the instructions for building a FreeBSD CI image --- ci/README.md | 92 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 26 deletions(-) diff --git a/ci/README.md b/ci/README.md index aef6ef1db1829..28152e5d00b99 100644 --- a/ci/README.md +++ b/ci/README.md @@ -128,32 +128,72 @@ QEMU is available, and if so mount it, run a script (it'll specifically be `run-qemu.sh` in this folder which is copied into the generated image talked about above), and then shut down. -### QEMU setup - FreeBSD - -1. Download CD installer (most minimal is fine) -2. `qemu-img create -f qcow2 foo.qcow2 2G` -3. `qemu -cdrom foo.iso -drive if=virtio,file=foo.qcow2 -net nic,model=virtio -net user` -4. run installer -5. `echo 'console="comconsole"' >> /boot/loader.conf` -6. `echo 'autoboot_delay="0"' >> /boot/loader.conf` -7. look at /etc/ttys, see what getty argument is for ttyu0 -8. edit /etc/gettytab, look for ttyu0 argument, prepend `:al=root` to line - beneath - -(note that the current image has a `freebsd` user, but this isn't really -necessary) - -Once that's done, arrange for this script to run at login: - -``` -#!/bin/sh - -sudo kldload ext2fs -[ -e /dev/vtbd1 ] || exit 0 -sudo mount -t ext2fs /dev/vtbd1 /mnt -sh /mnt/run.sh /mnt -sudo poweroff -``` +### QEMU Setup - FreeBSD + +1. [Download the latest stable amd64-bootonly release ISO](https://www.freebsd.org/where.html). + E.g. FreeBSD-11.1-RELEASE-amd64-bootonly.iso +2. Create the disk image: `qemu-img create -f qcow2 FreeBSD-11.1-RELEASE-amd64.qcow2 2G` +3. Boot the machine: `qemu-system-x86_64 -cdrom FreeBSD-11.1-RELEASE-amd64-bootonly.iso -drive if=virtio,file=FreeBSD-11.1-RELEASE-amd64.qcow2 -net nic,model=virtio -net user` +4. Run the installer, and install FreeBSD: + 1. Install + 1. Continue with default keymap + 1. Set Hostname: freebsd-ci + 1. Distribution Select: + 1. Uncheck lib32 + 1. Uncheck ports + 1. Network Configuration: vtnet0 + 1. Configure IPv4? Yes + 1. DHCP? Yes + 1. Configure IPv6? No + 1. Resolver Configuration: Ok + 1. Mirror Selection: Main Site + 1. Partitioning: Auto (UFS) + 1. Partition: Entire Disk + 1. Partition Scheme: MBR + 1. App Partition: Ok + 1. Partition Editor: Finish + 1. Confirmation: Commit + 1. Wait for sets to install + 1. Set the root password to nothing (press enter twice) + 1. Set time zone to UTC + 1. Set Date: Skip + 1. Set Time: Skip + 1. System Configuration: + 1. Disable sshd + 1. Disable dumpdev + 1. System Hardening + 1. Disable Sendmail service + 1. Add User Accounts: No + 1. Final Configuration: Exit + 1. Manual Configuration: Yes + 1. `echo 'console="comconsole"' >> /boot/loader.conf` + 1. `echo 'autoboot_delay="0"' >> /boot/loader.conf` + 1. `echo 'ext2fs_load="YES"' >> /boot/loader.conf` + 1. Look at `/etc/ttys`, see what getty argument is for `ttyu0` (E.g. `3wire`) + 1. Edit `/etc/gettytab` (with `vi` for example), look for `ttyu0` argument, + prepend `:al=root` to the line beneath to have the machine auto-login as + root. E.g. + + 3wire:\ + :np:nc:sp#0: + becomes: + + 3wire:\ + :al=root:np:nc:sp#0: + + 1. Edit `/root/.login` and put this in it: + + [ -e /dev/vtbd1 ] || exit 0 + mount -t ext2fs /dev/vtbd1 /mnt + sh /mnt/run.sh /mnt + poweroff + + 1. Exit the post install shell: `exit` + 1. Back in in the installer choose Reboot + 1. If all went well the machine should reboot and show a login prompt. + If you switch to the serial console by choosing View > serial0 in + the qemu menu, you should be logged in as root. + 1. Shutdown the machine: `shutdown -p now` Helpful links From c1fa4b68a89abf8fc30115402a9eb1abf8bc0196 Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Fri, 16 Mar 2018 08:23:01 +1100 Subject: [PATCH 3/3] Update FreeBSD docker CI to use FreeBSD 11.1 image --- ci/docker/x86_64-unknown-freebsd/Dockerfile | 8 ++++---- ci/run.sh | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ci/docker/x86_64-unknown-freebsd/Dockerfile b/ci/docker/x86_64-unknown-freebsd/Dockerfile index 7ad3faff37c0f..35f1036575854 100644 --- a/ci/docker/x86_64-unknown-freebsd/Dockerfile +++ b/ci/docker/x86_64-unknown-freebsd/Dockerfile @@ -1,13 +1,13 @@ -FROM alexcrichton/port-prebuilt-freebsd:2017-09-16 +FROM wezm/port-prebuilt-freebsd11@sha256:43553e2265ec702ec72a63a765df333f50b1858b896e69385749e96d8624e9b0 RUN apt-get update RUN apt-get install -y --no-install-recommends \ - qemu genext2fs + qemu genext2fs xz-utils RUN apt-get install -y curl ca-certificates gcc ENTRYPOINT ["sh"] ENV PATH=$PATH:/rust/bin \ - QEMU=2016-11-06/freebsd.qcow2.gz \ + QEMU=2018-03-15/FreeBSD-11.1-RELEASE-amd64.qcow2.xz \ CAN_CROSS=1 \ - CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd10-gcc + CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd11-gcc diff --git a/ci/run.sh b/ci/run.sh index 8a1d10b29edb9..ff74899cbb830 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -24,6 +24,13 @@ if [ "$QEMU" != "" ]; then curl https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/$QEMU | \ gunzip -d > $tmpdir/$qemufile fi + elif [ -z "${QEMU#*.xz}" ]; then + # image is .xz : download and uncompress it + qemufile=$(echo ${QEMU%.xz} | sed 's/\//__/g') + if [ ! -f $tmpdir/$qemufile ]; then + curl https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/$QEMU | \ + unxz > $tmpdir/$qemufile + fi else # plain qcow2 image: just download it qemufile=$(echo ${QEMU} | sed 's/\//__/g')