aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-10-12 09:03:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-10-12 09:03:03 +0200
commitc15d3d5be4011f9bfc7e36fb1629529c1eb2e009 (patch)
treeb9795c693cbbd7d1ee2d6af666981ac861d57517
parent86f6a19d36b1738c1e9d4a95a1c7e7d310f9960c (diff)
Various fixes and cleanups for base upgrade
systemd 234 qemu 2.10 linux 4.13
-rwxr-xr-xbootstrap33
-rw-r--r--bootstrap.txt15
-rwxr-xr-xbuildos28
-rw-r--r--buildos.service4
-rwxr-xr-xinit12
5 files changed, 57 insertions, 35 deletions
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 <<EOF /usr/lib/systemd/system/buildos-setup.service
[Unit]
Description=build os setup
-After=default.target
+After=multi-user.target
Conflicts=console-getty.service
[Service]
@@ -327,12 +328,12 @@ TTYReset=yes
TTYVHangup=yes
[Install]
-WantedBy=default.target
+WantedBy=multi-user.target
EOF
- sudo mkdir -p "$root/usr/lib/systemd/system/default.target.wants"
+ sudo mkdir -p "$root/etc/systemd/system/multi-user.target.wants"
sudo ln -sf "$root/usr/lib/systemd/system/buildos-setup.service" \
- "$root/usr/lib/systemd/system/default.target.wants/buildos-setup.service"
+ "$root/etc/systemd/system/multi-user.target.wants/buildos-setup.service"
# Create the kernel build snapshot, write the script that does the build
# from within the installation and boot it up via systemd-nspawn --boot.
@@ -439,7 +440,7 @@ apt-get clean
# Clean up /bootstrap.
#
-rm /usr/lib/systemd/system/default.target.wants/buildos-setup.service
+rm /etc/systemd/system/multi-user.target.wants/buildos-setup.service
rm /usr/lib/systemd/system/buildos-setup.service
rm -r /bootstrap
@@ -496,9 +497,9 @@ if [ "$stage" -le "6" ]; then
#
sudo install -m 755 ./init "$root/"
sudo install -m 755 ./buildos "$root/usr/sbin/"
- sudo install -m 755 ./buildos.service "$root/usr/lib/systemd/system/"
+ sudo install -m 644 ./buildos.service "$root/usr/lib/systemd/system/"
sudo ln -sf "$root/usr/lib/systemd/system/buildos.service" \
- "$root/usr/lib/systemd/system/default.target.wants/buildos.service"
+ "$root/etc/systemd/system/multi-user.target.wants/buildos.service"
info "generating buildos-init.cpio.gz..."
@@ -509,7 +510,7 @@ usr/lib/os-release
init
usr/sbin/buildos
usr/lib/systemd/system/buildos.service
-usr/lib/systemd/system/default.target.wants/buildos.service
+etc/systemd/system/multi-user.target.wants/buildos.service
EOF
cd "$owd"
diff --git a/bootstrap.txt b/bootstrap.txt
new file mode 100644
index 0000000..91d4d9f
--- /dev/null
+++ b/bootstrap.txt
@@ -0,0 +1,15 @@
+* Packages to watch out for (new versions often cause upgrade issues):
+
+ - systemd
+ - qemu-system-x86
+ - linux-image-amd64
+
+* Examining init changes:
+
+ - Get the latest initramfs-tools-core and udev packages
+ - Extract /usr/share/initramfs-tools/{scripts,init} into new directory
+ - Compare:
+
+ diff -urw <old> <new>
+
+ 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 <<EOF >/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