summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2021-04-09 12:02:05 -0700
committerAlistair Delva <adelva@google.com>2021-06-29 18:19:30 +0000
commit17eec518e354dc478a4db7aa2175f7e252304ddf (patch)
treec4c5c126ab1712fc720a05d2791f5e4931b29267
parent71e4ec7e540150161c3e936d4b24ffe6b66a5bf3 (diff)
downloadtests-17eec518e354dc478a4db7aa2175f7e252304ddf.tar.gz
Add bullseye variant with cuttlefish-common
This variant has some more tools which make the rootfs more useful for development. This rootfs can be used to run cuttlefish (say on GCE, or under QEMU) or nested under cuttlefish itself. The cuttlefish-common package is preinstalled to support creating cuttlefish instances. Change-Id: I1602d2a4ef4501c37616e67862a17902b1e40695
-rwxr-xr-xnet/test/build_rootfs.sh5
-rw-r--r--net/test/rootfs/bullseye-common.sh25
-rw-r--r--net/test/rootfs/bullseye-cuttlefish.list13
-rwxr-xr-xnet/test/rootfs/bullseye-cuttlefish.sh48
-rw-r--r--net/test/rootfs/common.sh44
5 files changed, 133 insertions, 2 deletions
diff --git a/net/test/build_rootfs.sh b/net/test/build_rootfs.sh
index 01a0f07..d6a2d91 100755
--- a/net/test/build_rootfs.sh
+++ b/net/test/build_rootfs.sh
@@ -28,8 +28,9 @@ unset LANG LANGUAGE \
export LC_ALL=C
usage() {
- echo -n "usage: $0 [-h] [-s bullseye] [-a i386|amd64|armhf|arm64] "
- echo "[-m http://mirror/debian] [-n rootfs] [-r initrd]"
+ echo -n "usage: $0 [-h] [-s bullseye|bullseye-cuttlefish] "
+ echo -n "[-a i386|amd64|armhf|arm64] "
+ echo -n "[-m http://mirror/debian] [-n rootfs] [-r initrd]"
exit 1
}
diff --git a/net/test/rootfs/bullseye-common.sh b/net/test/rootfs/bullseye-common.sh
index 3fbb809..180371e 100644
--- a/net/test/rootfs/bullseye-common.sh
+++ b/net/test/rootfs/bullseye-common.sh
@@ -19,6 +19,7 @@
iptables=iptables-1.8.7
debian_iptables=1.8.7-1
+cuttlefish=android-cuttlefish
setup_and_build_iptables() {
# Install everything needed from bullseye to build iptables
@@ -88,6 +89,30 @@ install_and_cleanup_iptables() {
cd -
}
+setup_and_build_cuttlefish() {
+ # Install everything needed from bullseye to build cuttlefish-common
+ apt-get install -y \
+ cdbs \
+ config-package-dev \
+ debhelper \
+ dpkg-dev \
+ git
+
+ # Fetch cuttlefish and build it for cuttlefish-common
+ git clone https://github.com/google/android-cuttlefish.git /usr/src/$cuttlefish
+ cd /usr/src/$cuttlefish
+ dpkg-buildpackage -d -uc -us
+ cd -
+}
+
+install_and_cleanup_cuttlefish() {
+ # Install and clean up cuttlefish-common
+ cd /usr/src
+ apt-get install -y -f ./cuttlefish-common_*.deb
+ rm -rf $cuttlefish cuttlefish*.{buildinfo,changes,deb,dsc}
+ cd -
+}
+
bullseye_cleanup() {
# SELinux is supported by our kernels, but we don't install the policy files
# which causes an error to be printed by systemd. Disable selinux.
diff --git a/net/test/rootfs/bullseye-cuttlefish.list b/net/test/rootfs/bullseye-cuttlefish.list
new file mode 100644
index 0000000..c5ff165
--- /dev/null
+++ b/net/test/rootfs/bullseye-cuttlefish.list
@@ -0,0 +1,13 @@
+#include "bullseye.list"
+libegl1-mesa
+libgles1
+libgles2
+libpam-systemd
+locales
+lsof
+lzop
+ntpdate
+openssh-server
+resolvconf
+sudo
+vim
diff --git a/net/test/rootfs/bullseye-cuttlefish.sh b/net/test/rootfs/bullseye-cuttlefish.sh
new file mode 100755
index 0000000..a4a909b
--- /dev/null
+++ b/net/test/rootfs/bullseye-cuttlefish.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+set -e
+set -u
+
+SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
+
+. $SCRIPT_DIR/bullseye-common.sh
+
+setup_dynamic_networking "eth0" "br0"
+
+update_apt_sources bullseye
+
+setup_cuttlefish_user
+
+get_installed_packages >/root/originally-installed
+
+setup_and_build_cuttlefish
+setup_and_build_iptables
+
+get_installed_packages >/root/installed
+
+remove_installed_packages /root/originally-installed /root/installed
+
+install_and_cleanup_cuttlefish
+sed -i "s,^#\(bridge_interface=\),\1br0," /etc/default/cuttlefish-common
+
+install_and_cleanup_iptables
+
+create_systemd_getty_symlinks ttyS0 hvc1
+
+apt-get purge -y vim-tiny
+bullseye_cleanup
diff --git a/net/test/rootfs/common.sh b/net/test/rootfs/common.sh
index 35e5745..3c9d8d7 100644
--- a/net/test/rootfs/common.sh
+++ b/net/test/rootfs/common.sh
@@ -54,6 +54,50 @@ setup_static_networking() {
echo "nameserver 8.8.4.4" >>/etc/resolv.conf
}
+# $1 - Network interface for bridge (or NetworkManager DHCP)
+# $2 - Bridge name. If set to the empty string, NetworkManager is used
+setup_dynamic_networking() {
+ # So isc-dhcp-client can work with a read-only rootfs..
+ cat >>/etc/fstab <<EOF
+tmpfs /var/lib/dhcp tmpfs defaults 0 0
+EOF
+
+ # Bring up networking one time with dhclient
+ mount /var/lib/dhcp
+ dhclient eth0
+ echo "nameserver 8.8.8.8" >/run/resolvconf/resolv.conf
+ echo "nameserver 8.8.4.4" >>/run/resolvconf/resolv.conf
+
+ # Set up automatic DHCP for *future* boots
+ if [ -z "$2" ]; then
+ cat >/etc/systemd/network/dhcp.network <<EOF
+[Match]
+Name=$1
+
+[Network]
+DHCP=yes
+EOF
+ # Mask the NetworkManager-wait-online service to prevent hangs
+ systemctl mask NetworkManager-wait-online.service
+ else
+ cat >/etc/network/interfaces.d/$2.conf <<EOF
+auto $2
+iface $2 inet dhcp
+ bridge_ports $1
+ bridge_stp off
+ bridge_fd 0
+EOF
+ fi
+}
+
+setup_cuttlefish_user() {
+ # Add a default user and put them in the right group
+ addgroup --system cvdnetwork
+ useradd -m -G cvdnetwork,kvm,render,sudo,video \
+ -d /home/vsoc-01 --shell /bin/bash vsoc-01
+ echo -e "cuttlefish\ncuttlefish" | passwd vsoc-01
+}
+
# $* - One or more device names for getty spawns
create_systemd_getty_symlinks() {
for device in $*; do