From c15d3d5be4011f9bfc7e36fb1629529c1eb2e009 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 12 Oct 2017 09:03:03 +0200 Subject: Various fixes and cleanups for base upgrade systemd 234 qemu 2.10 linux 4.13 --- bootstrap | 33 +++++++++++++++++---------------- bootstrap.txt | 15 +++++++++++++++ buildos | 28 +++++++++++++++------------- buildos.service | 4 ++-- init | 12 ++++++++---- 5 files changed, 57 insertions(+), 35 deletions(-) create mode 100644 bootstrap.txt diff --git a/bootstrap b/bootstrap index 63ebd32..380ae5e 100755 --- a/bootstrap +++ b/bootstrap @@ -28,10 +28,9 @@ usage="usage: $0" id="$(id -un)" btrfs=/btrfs -release="testing" +release="unstable" mirror="https://deb.debian.org/debian/" -passwd="123" #@@ TMP root passwd. -macaddr="de:ad:be:ef:b8:da" # Mac address for testing. +macaddr="de:ad:be:ef:b8:da" # Mac address for testing. root="$btrfs/$id/buildos" @@ -166,6 +165,8 @@ if [ "$stage" -eq "1" ]; then pkgs+=",intel-microcode,amd64-microcode" + #pkgs+=",lsof,auditd" + pkgs+=",hdparm,btrfs-progs" pkgs+=",net-tools,iproute2,iptables,isc-dhcp-client" @@ -179,7 +180,7 @@ if [ "$stage" -eq "1" ]; then pkgs+=",qemu-kvm,qemu-utils,socat" - pkgs+=",g++,pkg-config" + pkgs+=",g++,make,pkg-config" sudo debootstrap \ --foreign \ @@ -193,10 +194,10 @@ if [ "$stage" -eq "1" ]; then # Post-phase 1 fixups. # - # Set the initial hostname to '(none)'. This value is detected and + # Set the initial hostname to 'localhost'. This value is detected and # overriden by /sbin/dhclient-script if the DHCP server sends host-name. # - write <<<'(none)' /etc/hostname + write <<<'localhost' /etc/hostname # Set timezone to UTC (picked up by tzdata package during stage 2). # @@ -264,9 +265,9 @@ Welcome to Build OS 0.6.0 (https://build2.org)! EOF1 -# Set root password. +# Make root login passwordless (we disable SSH root login in init). # -chpasswd <<<'root:$passwd' +passwd -d root # Enable IPv4 forwarding (used for private bridge NAT). # @@ -311,7 +312,7 @@ if [ "$stage" -le "3" ]; then write < + + We currently only use init plus udev in scripts/init-{top,bottom} diff --git a/buildos b/buildos index 3657603..875733f 100755 --- a/buildos +++ b/buildos @@ -29,12 +29,21 @@ function error () exit 1 } -# Network timeouts: 30 seconds to connect, 10 minutes to complete. Note that -# the toolchain archives can be quite sizable. +# Network timeouts: 60 seconds to connect, 10 minutes to complete, 4 retries +# (5 attempts total). These are similar to bbot timeouts. Note that the +# toolchain archives can be quite sizable. # -curl=(curl -f -L -s -S --connect-timeout 30 --max-time 600) -bpkg=(bpkg --fetch curl --fetch-option --connect-timeout --fetch-option 30 \ - --fetch-option --max-time --fetch-option 600) +curl=(curl -f -L -s -S \ + --retry 4 \ + --retry-max-time 600 \ + --max-time 600 \ + --connect-timeout 60) + +bpkg=(bpkg --fetch curl \ + --fetch-option --retry --fetch-option 4 \ + --fetch-option --retry-max-time --fetch-option 600 \ + --fetch-option --max-time --fetch-option 600 \ + --fetch-option --connect-timeout --fetch-option 60) info "starting build os monitor..." @@ -99,14 +108,6 @@ for v in "${cmdline[@]}"; do fi done -# Make sure /dev/kvm has correct permissions (while all the udev scripts seem -# to be there, it does not work for some reason). -# -if sudo test -c /dev/kvm; then - sudo chgrp kvm /dev/kvm - sudo chmod 0660 /dev/kvm -fi - hname="$(hostname)" # Get the build id. @@ -950,6 +951,7 @@ EOF fi tp="${toolchains["$tn"]}" + tr="$(toolchain_value "$tp" toolchain_root)" # Or those that have no controllers (maybe it would have been better # to build it but not start). diff --git a/buildos.service b/buildos.service index d4b1950..ed64494 100644 --- a/buildos.service +++ b/buildos.service @@ -1,6 +1,6 @@ [Unit] Description=build os monitor -After=default.target +After=multi-user.target Conflicts=getty@tty1.service [Service] @@ -19,4 +19,4 @@ Group=build WorkingDirectory=~ [Install] -WantedBy=default.target +WantedBy=multi-user.target diff --git a/init b/init index 031b015..bbc0343 100755 --- a/init +++ b/init @@ -3,7 +3,7 @@ # Init script for build2 Build OS. # # Loosely based on the one that comes in Debian initrd.img (since we are -# using its kernel image as is). +# using its kernel image). # trap "exit 1" ERR set -o errtrace # Trap in functions. @@ -52,8 +52,7 @@ mount -t tmpfs -o "nodev,nosuid,size=10%,mode=1777" tmpfs /tmp # Start udev. # -# Based on Debian initrd's init-top/udev. Note that we don't stop it at -# at the end of init. +# Based on Debian initrd's init-{top,bottom}/udev # info "starting udev..." @@ -63,7 +62,8 @@ fi SYSTEMD_LOG_LEVEL=info /lib/systemd/systemd-udevd --daemon --resolve-names=never -udevadm trigger --action=add +udevadm trigger --type=subsystems --action=add +udevadm trigger --type=devices --action=add udevadm settle || true # Initialize KVM. @@ -467,6 +467,10 @@ cat </etc/systemd/system/getty@tty1.service.d/noclear.conf TTYVTDisallocate=no EOF +# Stop udev daemon (systemd will start its own). +# +udevadm control --exit + # Get rid of klibc tools. # export PATH=/sbin:/usr/sbin:/bin:/usr/bin -- cgit v1.1