Last active
February 21, 2021 10:30
-
-
Save mdaniel/6047290 to your computer and use it in GitHub Desktop.
Provision a virtual machine for building ChromeOS using Vagrant <http://www.vagrantup.com>. Just download this into a directory, name it ``Vagrantfile`` (if it isn't already), run ``vagrant up`` followed by ``vagrant ssh`` and you'll see two shell scripts there, ready to sync up the ChromeOS source code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "ubuntu1204_64" | |
# The url from where the 'config.vm.box' box will be fetched if it | |
# doesn't already exist on the user's system. | |
config.vm.box_url = "http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box" | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine. In the example below, | |
# accessing "localhost:8080" will access port 80 on the guest machine. | |
# config.vm.network :forwarded_port, guest: 80, host: 8080 | |
# Create a private network, which allows host-only access to the machine | |
# using a specific IP. | |
# config.vm.network :private_network, ip: "192.168.33.10" | |
# Create a public network, which generally matched to bridged network. | |
# Bridged networks make the machine appear as another physical device on | |
# your network. | |
config.vm.network :public_network | |
# If true, then any SSH connections made will enable agent forwarding. | |
# Default value: false | |
# config.ssh.forward_agent = true | |
# Share an additional folder to the guest VM. The first argument is | |
# the path on the host to the actual folder. The second argument is | |
# the path on the guest to mount the folder. And the optional third | |
# argument is a set of non-required options. | |
# config.vm.synced_folder "../data", "/vagrant_data" | |
# Provider-specific configuration so you can fine-tune various | |
# backing providers for Vagrant. These expose provider-specific options. | |
# Example for VirtualBox: | |
# | |
config.vm.provider :virtualbox do |vb| | |
vb.gui = true | |
## four cpus seems like a reasonable guess in modern times | |
vb.customize ["modifyvm", :id, "--memory", "8192", "--cpus", "4"] | |
end | |
# everything you see here came from the Pre-req section of the dev guide: | |
# http://dev.chromium.org/chromium-os/developer-guide#TOC-Prerequisites | |
$prov_git = <<PROV_GIT | |
set -e | |
set -x | |
## Vagrant runs this script as root, so be aware | |
echo "=== HELLO FROM $0 ===" | |
if test "$USER" == "root" | |
then | |
su - vagrant -c "$0" | |
exit 0 | |
fi | |
echo '=== USER INFO ===' | |
id -a | |
if test -d chromiumos | |
then | |
echo "You already have a chromiumos directory, which I will not modify." >&2 | |
exit 0 | |
fi | |
echo '=== INSTALL GIT ===' | |
sudo apt-get install -y git-core subversion curl | |
echo '=== INSTALL DEPOT TOOLS ===' | |
cd $HOME | |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git | |
## http://dev.chromium.org/developers/how-tos/install-depot-tools specifically | |
## says to put depot_tools at the end of the path | |
echo "PATH=\$PATH:\$HOME/depot_tools" >> $HOME/.bashrc | |
echo '=== FIX UP SUDO ===' | |
##http://www.chromium.org/tips-and-tricks-for-chromium-os-developers#TOC-Making-sudo-a-little-more-permissive | |
cat<<SUDO1 | sudo tee /etc/sudoers.d/relax_requirements | |
Defaults !tty_tickets # Entering your password in one shell affects all shells | |
Defaults timestamp_timeout=180 # Minutes between re-requesting your password | |
SUDO1 | |
sudo chmod 0440 /etc/sudoers.d/relax_requirements | |
echo '=== GENERATE CHROMIUM SSH KEY ===' | |
ssh-keygen -t rsa -b 1024 -C "$USER@$HOSTNAME" -f $HOME/.ssh/chromium -N '' | |
echo '=== INSTALL KEYCHAIN ===' | |
## TODO: is it better to follow their order, so folks know what's going on | |
## or better to batch up the apt-get instructions? | |
sudo apt-get install -y keychain | |
echo '=== FIX UMASK ===' | |
echo 'umask 022' >> $HOME/.bashrc | |
echo '=== CREATE ChromiumOS DIR ===' | |
mkdir -p $HOME/chromiumos | |
echo '=== GERRIT KNOWN HOSTS ===' | |
cat >> $HOME/.ssh/known_hosts<<SSH1 | |
[gerrit.chromium.org]:29418 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCfRn+J+e9mU0c4bxFD8v2rhhd3O9WPk435xEtG9FD8a8fOnIubJcpObvQJhfSgYkxVUQOKk97V8b2eGjf72AGBhDQVJMiaLQc8ZGomeNlK/7cWjkJFDoIKQHilHQidz/pgZc/Pu+7Tl2emVGd6425QRK1h47CYtT9IUPt3Jtdv4w== | |
SSH1 | |
echo '=== REPO CLONE SCRIPTS ===' | |
## now it's their turn: | |
cat > repo_sync_mini.sh<<REPO1 | |
#! /bin/sh | |
cd ${HOME}/chromiumos | |
repo init -u https://git.chromium.org/git/chromiumos/manifest.git -g minilayout --repo-url https://git.chromium.org/git/external/repo.git | |
repo sync | |
REPO1 | |
chmod a+x repo_sync_mini.sh | |
cat > repo_sync_full.sh<<REPO2 | |
#! /bin/sh | |
cd ${HOME}/chromiumos | |
repo init -u https://git.chromium.org/git/chromiumos/manifest.git --repo-url https://git.chromium.org/git/external/repo.git | |
repo sync | |
REPO2 | |
chmod a+x repo_sync_full.sh | |
echo '=== HAPPY HACKING TO YOU ===' | |
PROV_GIT | |
config.vm.provision :shell, :inline => $prov_git | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it not the same as https://github.com/bacongobbler/chromeos-vagrant?