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 AOSP customized kernel package and extra Debian packages 59if [ -e /root/extradeb.tar.gz ]; then 60 tar --one-top-level=/root/extra_deb -zxvf /root/extradeb.tar.gz 61 apt -o APT::Color=0 -o DPkgPM::Progress-Fancy=0 install /root/extra_deb/*.deb 62 rm -rf /root/extra_deb 63 rm -f /root/extradeb.tar.gz 64fi 65 66# Install firmware package for AMD graphics 67apt-get install -y firmware-amd-graphics 68 69get_installed_packages >/root/originally-installed 70 71# Using "Depends:" is more reliable than "Version:", because it works for 72# backported ("bpo") kernels as well. NOTE: "Package" can be used instead 73# if we don't install the metapackage ("linux-image-${arch}") but a 74# specific version in the future 75kmodver=$(dpkg -s linux-image-${arch} | grep ^Depends: | \ 76 cut -d: -f2 | cut -d" " -f2 | sed 's/linux-image-//') 77 78# Install headers from backports, to match the linux-image (removed below) 79apt-get install -y -t bullseye-backports $(echo linux-headers-${kmodver}) 80 81# Dependencies for nvidia-installer (removed below) 82apt-get install -y dkms libglvnd-dev libc6-dev pkg-config 83 84nvidia_version=525.60.13 85wget -q https://us.download.nvidia.com/tesla/${nvidia_version}/NVIDIA-Linux-${nvidia_arch}-${nvidia_version}.run 86chmod a+x NVIDIA-Linux-${nvidia_arch}-${nvidia_version}.run 87./NVIDIA-Linux-${nvidia_arch}-${nvidia_version}.run -x 88cd NVIDIA-Linux-${nvidia_arch}-${nvidia_version} 89if [[ "${nvidia_arch}" = "x86_64" ]]; then 90 installer_flags="--no-install-compat32-libs" 91else 92 installer_flags="" 93fi 94./nvidia-installer ${installer_flags} --silent --no-backup --no-wine-files \ 95 --install-libglvnd --dkms -k "${kmodver}" 96cd - 97rm -rf NVIDIA-Linux-${nvidia_arch}-${nvidia_version}* 98 99get_installed_packages >/root/installed 100 101remove_installed_packages /root/originally-installed /root/installed 102 103setup_and_build_cuttlefish 104 105install_and_cleanup_cuttlefish 106 107# ttyAMA0 for ampere/gigabyte 108# ttyS0 for GCE t2a 109create_systemd_getty_symlinks ttyAMA0 ttyS0 110 111setup_grub "net.ifnames=0 console=ttyAMA0 8250.nr_uarts=1 console=ttyS0 loglevel=4 amdgpu.runpm=0 amdgpu.dc=0" 112 113# Set up NTP using Google time servers and switch to UTC for uniformity 114# NOTE: Installing ntp removes systemd-timesyncd 115apt-get install -y ntp 116sed -i -e 's,^\(pool .*debian.*\)$,# \1,' /etc/ntp.conf 117cat >>/etc/ntp.conf <<EOF 118pool time1.google.com iburst 119pool time2.google.com iburst 120pool time3.google.com iburst 121pool time4.google.com iburst 122# time.google.com as backup 123pool time.google.com iburst 124EOF 125timedatectl set-timezone UTC 126 127# Switch to NetworkManager. To disrupt the bootstrapping the least, do this 128# right at the end.. 129rm -f /etc/network/interfaces.d/eth0.conf 130apt-get install -y network-manager 131apt-get purge -y vim-tiny 132bullseye_cleanup 133