• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (C) 2022 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18set -e
19set -u
20
21SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
22
23. $SCRIPT_DIR/bullseye-common.sh
24
25arch=$(uname -m)
26nvidia_arch=${arch}
27[ "${arch}" = "x86_64" ] && arch=amd64
28[ "${arch}" = "aarch64" ] && arch=arm64
29
30# Workaround for unnecessary firmware warning on ampere/gigabyte
31mkdir -p /lib/firmware
32touch /lib/firmware/ast_dp501_fw.bin
33
34setup_dynamic_networking "eth0" ""
35
36# NVIDIA driver needs dkms which requires /dev/fd
37if [ ! -d /dev/fd ]; then
38 ln -s /proc/self/fd /dev/fd
39fi
40
41update_apt_sources "bullseye bullseye-backports" "non-free"
42
43setup_cuttlefish_user
44
45# Install JRE
46apt-get install -y openjdk-17-jre
47
48# Ubuntu compatibility
49cat >>/etc/skel/.profile << EOF
50PATH="/usr/sbin:\$PATH"
51EOF
52
53# Get kernel and QEMU from backports
54for package in linux-image-${arch} qemu-system-arm qemu-system-x86; do
55  apt-get install -y -t bullseye-backports ${package}
56done
57
58# Install firmware package for AMD graphics
59apt-get install -y firmware-amd-graphics
60
61get_installed_packages >/root/originally-installed
62
63# Using "Depends:" is more reliable than "Version:", because it works for
64# backported ("bpo") kernels as well. NOTE: "Package" can be used instead
65# if we don't install the metapackage ("linux-image-${arch}") but a
66# specific version in the future
67kmodver=$(dpkg -s linux-image-${arch} | grep ^Depends: | \
68          cut -d: -f2 | cut -d" " -f2 | sed 's/linux-image-//')
69
70# Install headers from backports, to match the linux-image (removed below)
71apt-get install -y -t bullseye-backports $(echo linux-headers-${kmodver})
72
73# Dependencies for nvidia-installer (removed below)
74apt-get install -y dkms libglvnd-dev libc6-dev pkg-config
75
76nvidia_version=525.60.13
77wget -q https://us.download.nvidia.com/tesla/${nvidia_version}/NVIDIA-Linux-${nvidia_arch}-${nvidia_version}.run
78chmod a+x NVIDIA-Linux-${nvidia_arch}-${nvidia_version}.run
79./NVIDIA-Linux-${nvidia_arch}-${nvidia_version}.run -x
80cd NVIDIA-Linux-${nvidia_arch}-${nvidia_version}
81if [[ "${nvidia_arch}" = "x86_64" ]]; then
82  installer_flags="--no-install-compat32-libs"
83else
84  installer_flags=""
85fi
86./nvidia-installer ${installer_flags} --silent --no-backup --no-wine-files \
87                   --install-libglvnd --dkms -k "${kmodver}"
88cd -
89rm -rf NVIDIA-Linux-${nvidia_arch}-${nvidia_version}*
90
91get_installed_packages >/root/installed
92
93remove_installed_packages /root/originally-installed /root/installed
94
95setup_and_build_cuttlefish
96
97install_and_cleanup_cuttlefish
98
99# ttyAMA0 for ampere/gigabyte
100# ttyS0 for GCE t2a
101create_systemd_getty_symlinks ttyAMA0 ttyS0
102
103setup_grub "net.ifnames=0 console=ttyAMA0 8250.nr_uarts=1 console=ttyS0 loglevel=4 amdgpu.runpm=0 amdgpu.dc=0"
104
105# Set up NTP using Google time servers and switch to UTC for uniformity
106# NOTE: Installing ntp removes systemd-timesyncd
107apt-get install -y ntp
108sed -i -e 's,^\(pool .*debian.*\)$,# \1,' /etc/ntp.conf
109cat >>/etc/ntp.conf <<EOF
110pool time1.google.com iburst
111pool time2.google.com iburst
112pool time3.google.com iburst
113pool time4.google.com iburst
114# time.google.com as backup
115pool time.google.com iburst
116EOF
117timedatectl set-timezone UTC
118
119# Switch to NetworkManager. To disrupt the bootstrapping the least, do this
120# right at the end..
121rm -f /etc/network/interfaces.d/eth0.conf
122apt-get install -y network-manager
123apt-get purge -y vim-tiny
124bullseye_cleanup
125