Merge pull request #13316 from aabadie/pr/tools/packer_update
tools/packer: update vagrant image to Ubuntu 18.04 + refactoring
This commit is contained in:
commit
47a5c86f86
34
Vagrantfile
vendored
34
Vagrantfile
vendored
@ -5,28 +5,20 @@ require 'fileutils'
|
|||||||
|
|
||||||
RIOTBASE ||= "./"
|
RIOTBASE ||= "./"
|
||||||
|
|
||||||
Vagrant.configure(2) do |config|
|
Vagrant.configure("2") do |config|
|
||||||
# For a complete reference, please see the online documentation at https://docs.vagrantup.com.
|
config.vm.define "RIOT-VM"
|
||||||
|
config.vm.box = "RIOT/ubuntu1804"
|
||||||
|
config.ssh.username = "user"
|
||||||
|
config.vm.synced_folder RIOTBASE, "/home/user/RIOT"
|
||||||
|
|
||||||
config.vm.box = "RIOT/ubuntu1604"
|
if File.exists?(File.join(Dir.home, ".gitconfig"))
|
||||||
|
config.vm.provision "file", source: File.join(Dir.home, ".gitconfig"), destination: ".gitconfig"
|
||||||
|
end
|
||||||
|
|
||||||
config.vm.provider "virtualbox" do |vb|
|
config.vm.provider :virtualbox do |v, override|
|
||||||
vb.name = "RIOT-VM"
|
v.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-on-restore", 0]
|
||||||
|
|
||||||
vb.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-interval", 10000]
|
# additional USB passthrough entries
|
||||||
vb.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-min-adjust", 100]
|
# v.customize ['usbfilter', 'add', '0', '--target', :id, '--name', '<custom_name>', '--vendorid', '<vID>', '--productid', '<pID>']
|
||||||
vb.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-on-restore", 1]
|
end
|
||||||
vb.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]
|
|
||||||
|
|
||||||
# additional USB passthrough entries
|
|
||||||
# vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', '<custom_name>', '--vendorid', '<vID>', '--productid', '<pID>']
|
|
||||||
end
|
|
||||||
|
|
||||||
config.vm.synced_folder RIOTBASE, "/home/vagrant/RIOT"
|
|
||||||
|
|
||||||
if File.exists?(File.join(Dir.home, ".gitconfig"))
|
|
||||||
config.vm.provision "file", source: File.join(Dir.home, ".gitconfig"), destination: ".gitconfig"
|
|
||||||
end
|
|
||||||
# use a custom provisioning script
|
|
||||||
# config.vm.provision "shell", path: "dist/tools/vagrant/bootstrap.sh"
|
|
||||||
end
|
end
|
||||||
|
|||||||
1
dist/tools/packer/.gitignore
vendored
1
dist/tools/packer/.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
packer_cache
|
packer_cache
|
||||||
|
output-*-virtualbox-iso/
|
||||||
*.box
|
*.box
|
||||||
|
|||||||
2
dist/tools/packer/README.md
vendored
2
dist/tools/packer/README.md
vendored
@ -13,4 +13,4 @@ A simple build of the vagrant box can be done by:
|
|||||||
packer build riot.json
|
packer build riot.json
|
||||||
```
|
```
|
||||||
This command must be executed in the packer directory [RIOT/dist/tools/packer](https://github.com/RIOT-OS/RIOT/tree/master/dist/tools/packer).
|
This command must be executed in the packer directory [RIOT/dist/tools/packer](https://github.com/RIOT-OS/RIOT/tree/master/dist/tools/packer).
|
||||||
Note that the build process might take several minutes.
|
Note that the build process might take several minutes.
|
||||||
|
|||||||
43
dist/tools/packer/http/preseed.cfg
vendored
Normal file
43
dist/tools/packer/http/preseed.cfg
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#choose-mirror-bin mirror/http/proxy string
|
||||||
|
d-i base-installer/kernel/override-image string linux-server
|
||||||
|
d-i clock-setup/utc boolean true
|
||||||
|
d-i clock-setup/utc-auto boolean true
|
||||||
|
d-i finish-install/reboot_in_progress note
|
||||||
|
d-i grub-installer/only_debian boolean true
|
||||||
|
d-i grub-installer/with_other_os boolean true
|
||||||
|
d-i partman-auto-lvm/guided_size string max
|
||||||
|
d-i partman-auto/choose_recipe select atomic
|
||||||
|
d-i partman-auto/method string lvm
|
||||||
|
d-i partman-lvm/confirm boolean true
|
||||||
|
d-i partman-lvm/confirm boolean true
|
||||||
|
d-i partman-lvm/confirm_nooverwrite boolean true
|
||||||
|
d-i partman-lvm/device_remove_lvm boolean true
|
||||||
|
d-i partman/choose_partition select finish
|
||||||
|
d-i partman/confirm boolean true
|
||||||
|
d-i partman/confirm_nooverwrite boolean true
|
||||||
|
d-i partman/confirm_write_new_label boolean true
|
||||||
|
|
||||||
|
# Default mirror
|
||||||
|
d-i mirror/country string FR
|
||||||
|
d-i mirror/http/hostname string ftp.fr.debian.org
|
||||||
|
d-i mirror/http/directory string /ubuntu
|
||||||
|
d-i mirror/http/proxy string
|
||||||
|
d-i mirror/http/mirror string ftp.fr.debian.org
|
||||||
|
|
||||||
|
# Default user
|
||||||
|
d-i passwd/user-fullname string user
|
||||||
|
d-i passwd/username string user
|
||||||
|
d-i passwd/user-password password user
|
||||||
|
d-i passwd/user-password-again password user
|
||||||
|
d-i passwd/username string user
|
||||||
|
|
||||||
|
# Minimum packages (see postinstall.sh)
|
||||||
|
d-i pkgsel/include string openssh-server
|
||||||
|
d-i pkgsel/install-language-support boolean true
|
||||||
|
d-i pkgsel/update-policy select none
|
||||||
|
d-i pkgsel/upgrade select none
|
||||||
|
|
||||||
|
d-i time/zone string UTC
|
||||||
|
d-i user-setup/allow-password-weak boolean true
|
||||||
|
d-i user-setup/encrypt-home boolean false
|
||||||
|
tasksel tasksel/first multiselect standard, ubuntu-server
|
||||||
35
dist/tools/packer/preseed.cfg
vendored
35
dist/tools/packer/preseed.cfg
vendored
@ -1,35 +0,0 @@
|
|||||||
choose-mirror-bin mirror/http/proxy string
|
|
||||||
d-i base-installer/kernel/override-image string linux-server
|
|
||||||
d-i clock-setup/utc boolean true
|
|
||||||
d-i clock-setup/utc-auto boolean true
|
|
||||||
d-i finish-install/reboot_in_progress note
|
|
||||||
d-i grub-installer/only_debian boolean true
|
|
||||||
d-i grub-installer/with_other_os boolean true
|
|
||||||
d-i partman-auto-lvm/guided_size string max
|
|
||||||
d-i partman-auto/choose_recipe select atomic
|
|
||||||
d-i partman-auto/method string lvm
|
|
||||||
d-i partman-lvm/confirm boolean true
|
|
||||||
d-i partman-lvm/confirm_nooverwrite boolean true
|
|
||||||
d-i partman-lvm/device_remove_lvm boolean true
|
|
||||||
d-i partman/choose_partition select finish
|
|
||||||
d-i partman/confirm boolean true
|
|
||||||
d-i partman/confirm_nooverwrite boolean true
|
|
||||||
d-i partman/confirm_write_new_label boolean true
|
|
||||||
d-i user-setup/allow-password-weak boolean true
|
|
||||||
d-i user-setup/encrypt-home boolean false
|
|
||||||
d-i passwd/user-default-groups string adm cdrom dialout lxd plugdev sudo
|
|
||||||
|
|
||||||
d-i pkgsel/include string openssh-server ntp curl nfs-common build-essential \
|
|
||||||
linux-headers-$(uname -r) perl dkms pcregrep libpcre3 python3 git vim \
|
|
||||||
gcc-arm-none-eabi gcc-msp430 unzip qemu-system-x86 g++-multilib \
|
|
||||||
gcc-multilib gcc-avr binutils-avr avr-libc avrdude doxygen cppcheck \
|
|
||||||
python-setuptools libusb-1.0-0 libusb-1.0-0-dev libudev-dev libftdi1 \
|
|
||||||
libftdi-dev libftdipp1-dev libftdipp1-2v5 libhidapi-dev libhidapi-hidraw0 \
|
|
||||||
libhidapi-libusb0 cmake autotools-dev autoconf pkg-config jimsh libtool \
|
|
||||||
valgrind openocd python-serial python3-serial xsltproc dfu-util
|
|
||||||
|
|
||||||
d-i pkgsel/install-language-support boolean false
|
|
||||||
d-i pkgsel/update-policy select none
|
|
||||||
d-i pkgsel/upgrade select full-upgrade
|
|
||||||
d-i time/zone string UTC
|
|
||||||
tasksel tasksel/first multiselect standard, server
|
|
||||||
107
dist/tools/packer/riot.json
vendored
107
dist/tools/packer/riot.json
vendored
@ -1,25 +1,34 @@
|
|||||||
{
|
{
|
||||||
"_comment": "Build with `packer build riot.json`",
|
|
||||||
"builders": [
|
"builders": [
|
||||||
{
|
{
|
||||||
|
"type": "virtualbox-iso",
|
||||||
"boot_command": [
|
"boot_command": [
|
||||||
"{{ user `boot_command_prefix` }}",
|
"<esc><wait>",
|
||||||
"/install/vmlinuz noapic ",
|
"<esc><wait>",
|
||||||
"initrd=/install/initrd.gz ",
|
"<enter><wait>",
|
||||||
"file=/floppy/{{ user `preseed` }} ",
|
"/install/vmlinuz<wait>",
|
||||||
"debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
|
" auto<wait>",
|
||||||
"hostname={{ user `hostname` }} ",
|
" console-setup/ask_detect=false<wait>",
|
||||||
"fb=false debconf/frontend=noninteractive ",
|
" console-setup/layoutcode=us<wait>",
|
||||||
"keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
|
" console-setup/modelcode=pc105<wait>",
|
||||||
"keyboard-configuration/variant=USA console-setup/ask_detect=false ",
|
" debconf/frontend=noninteractive<wait>",
|
||||||
"passwd/user-fullname={{ user `ssh_fullname` }} ",
|
" debian-installer=en_US<wait>",
|
||||||
"passwd/user-password={{ user `ssh_password` }} ",
|
" fb=false<wait>",
|
||||||
"passwd/user-password-again={{ user `ssh_password` }} ",
|
" initrd=/install/initrd.gz<wait>",
|
||||||
"passwd/username={{ user `ssh_username` }} ",
|
" kbd-chooser/method=us<wait>",
|
||||||
"-- <enter>"
|
" keyboard-configuration/layout=USA<wait>",
|
||||||
|
" keyboard-configuration/variant=USA<wait>",
|
||||||
|
" locale=en_US<wait>",
|
||||||
|
" netcfg/get_domain=vm<wait>",
|
||||||
|
" netcfg/get_hostname={{ user `hostname` }}<wait>",
|
||||||
|
" grub-installer/bootdev=/dev/sda<wait>",
|
||||||
|
" noapic<wait>",
|
||||||
|
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
|
||||||
|
" -- <wait>",
|
||||||
|
"<enter><wait>"
|
||||||
],
|
],
|
||||||
|
"boot_wait": "10s",
|
||||||
"disk_size": "{{ user `disk_size` }}",
|
"disk_size": "{{ user `disk_size` }}",
|
||||||
"floppy_files": [ "{{ user `preseed` }}" ],
|
|
||||||
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
|
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
|
||||||
"guest_os_type": "{{ user `virtualbox_guest_os_type` }}",
|
"guest_os_type": "{{ user `virtualbox_guest_os_type` }}",
|
||||||
"headless": "{{ user `headless` }}",
|
"headless": "{{ user `headless` }}",
|
||||||
@ -27,30 +36,35 @@
|
|||||||
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
|
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
|
||||||
"iso_urls": [ "{{ user `iso_path` }}/{{ user `iso_name` }}", "{{ user `iso_url` }}" ],
|
"iso_urls": [ "{{ user `iso_path` }}/{{ user `iso_name` }}", "{{ user `iso_url` }}" ],
|
||||||
"output_directory": "output-{{ user `vm_name` }}-virtualbox-iso",
|
"output_directory": "output-{{ user `vm_name` }}-virtualbox-iso",
|
||||||
|
"http_directory": "http",
|
||||||
"shutdown_command": "echo '{{ user `ssh_password` }}'|sudo -S shutdown -P now",
|
"shutdown_command": "echo '{{ user `ssh_password` }}'|sudo -S shutdown -P now",
|
||||||
"ssh_password": "{{ user `ssh_password` }}",
|
|
||||||
"ssh_username": "{{ user `ssh_username` }}",
|
"ssh_username": "{{ user `ssh_username` }}",
|
||||||
|
"ssh_password": "{{ user `ssh_password` }}",
|
||||||
|
"ssh_port": 22,
|
||||||
"ssh_wait_timeout": "10000s",
|
"ssh_wait_timeout": "10000s",
|
||||||
"type": "virtualbox-iso",
|
|
||||||
"vboxmanage": [
|
"vboxmanage": [
|
||||||
[ "modifyvm", "{{.Name}}", "--memory", "{{ user `memory` }}" ],
|
[ "modifyvm", "{{.Name}}", "--memory", "{{ user `memory` }}" ],
|
||||||
[ "modifyvm", "{{.Name}}", "--cpus", "{{ user `cpus` }}" ],
|
[ "modifyvm", "{{.Name}}", "--cpus", "{{ user `cpus` }}" ],
|
||||||
[ "modifyvm", "{{.Name}}", "--usb", "on" ],
|
[ "modifyvm", "{{.Name}}", "--usb", "on" ],
|
||||||
[ "modifyvm", "{{.Name}}", "--usbxhci", "on" ],
|
|
||||||
[ "modifyvm", "{{.Name}}", "--audio", "none"],
|
[ "modifyvm", "{{.Name}}", "--audio", "none"],
|
||||||
[ "modifyvm", "{{.Name}}", "--ioapic", "on"],
|
[ "modifyvm", "{{.Name}}", "--ioapic", "on"],
|
||||||
[ "modifyvm", "{{.Name}}", "--rtcuseutc", "on"],
|
[ "modifyvm", "{{.Name}}", "--rtcuseutc", "on"],
|
||||||
[ "modifyvm", "{{.Name}}", "--clipboard", "bidirectional"],
|
|
||||||
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "FTDI USB-TTL", "--vendorid", "0x0403", "--productid", "0x6001"],
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "FTDI USB-TTL", "--vendorid", "0x0403", "--productid", "0x6001"],
|
||||||
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "CP2102 USB to UART", "--vendorid", "0x10c4", "--productid", "0xea60"],
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "CP2102 USB to UART", "--vendorid", "0x10c4", "--productid", "0xea60"],
|
||||||
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "STM32 STLink", "--vendorid", "0x0483", "--productid", "0x3748"],
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "STM32 STLink", "--vendorid", "0x0483", "--productid", "0x3748"],
|
||||||
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "STM32 STLink", "--vendorid", "0x0483", "--productid", "0x374b"],
|
||||||
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "USBasp", "--vendorid", "0x16c0", "--productid", "0x05dc"],
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "USBasp", "--vendorid", "0x16c0", "--productid", "0x05dc"],
|
||||||
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "iotlab-m3", "--vendorid", "0x0403", "--productid", "0x6010"],
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "iotlab-m3", "--vendorid", "0x0403", "--productid", "0x6010"],
|
||||||
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "samr21-xpro", "--vendorid", "0x03eb", "--productid", "0x2111"],
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "iotlab-m3-cn", "--vendorid", "0x0403", "--productid", "0x6011"],
|
||||||
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "Arduino Mega 2560", "--vendorid", "0x2341", "--productid", "0x0042"],
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "CMSIS-DAP", "--vendorid", "0x03eb", "--productid", "0x2111"],
|
||||||
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "Arduino UNO", "--vendorid", "0x2341", "--productid", "0x0042"],
|
||||||
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "Arduino Mega 2560", "--vendorid", "0x2a03", "--productid", "0x0042"],
|
||||||
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "Phytec phyWAVE KW22", "--vendorid", "0x0d28", "--productid", "0x0204"],
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "Phytec phyWAVE KW22", "--vendorid", "0x0d28", "--productid", "0x0204"],
|
||||||
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "Bluepill", "--vendorid", "0x1d50", "--productid", "0x6017"],
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "Bluepill", "--vendorid", "0x1d50", "--productid", "0x6017"],
|
||||||
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "Bluepill", "--vendorid", "0x1d50", "--productid", "0x6018"]
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "Bluepill", "--vendorid", "0x1d50", "--productid", "0x6018"],
|
||||||
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "JLink", "--vendorid", "0x1366", "--productid", "0x1015"],
|
||||||
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "Arduino Zero", "--vendorid", "0x03eb", "--productid", "0x2157"],
|
||||||
|
["usbfilter", "add", "0", "--target", "{{.Name}}", "--name", "DAPLink", "--vendorid", "0x0d28", "--productid", "0x0204"]
|
||||||
],
|
],
|
||||||
"virtualbox_version_file": ".vbox_version",
|
"virtualbox_version_file": ".vbox_version",
|
||||||
"vm_name": "{{user `vm_name`}}"
|
"vm_name": "{{user `vm_name`}}"
|
||||||
@ -68,36 +82,39 @@
|
|||||||
],
|
],
|
||||||
"provisioners": [
|
"provisioners": [
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "shell",
|
||||||
"source": "./udev_rules",
|
|
||||||
"destination": "/tmp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"environment_vars": [
|
"environment_vars": [
|
||||||
"SSH_USERNAME={{user `ssh_username`}}",
|
"SSH_USERNAME={{ user `ssh_username` }}"
|
||||||
"SSH_PASSWORD={{user `ssh_password`}}"
|
|
||||||
],
|
],
|
||||||
"execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
|
"execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||||
"scripts": [ "setup.sh" ],
|
"override": {
|
||||||
"type": "shell"
|
"virtualbox-iso": {
|
||||||
|
"scripts": [
|
||||||
|
"scripts/base.sh",
|
||||||
|
"scripts/vagrant.sh",
|
||||||
|
"scripts/riot.sh",
|
||||||
|
"scripts/toolchains.sh",
|
||||||
|
"scripts/udev_rules.sh",
|
||||||
|
"scripts/virtualbox.sh",
|
||||||
|
"scripts/cleanup.sh"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"variables": {
|
"variables": {
|
||||||
"boot_command_prefix": "<enter><wait><f6><esc><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
"cpus": "2",
|
||||||
"cpus": "1",
|
"disk_size": "10240",
|
||||||
"disk_size": "65536",
|
|
||||||
"headless": "true",
|
"headless": "true",
|
||||||
"iso_checksum": "a06cd926f5855d4f21fb4bc9978a35312f815fbda0d0ef7fdc846861f4fc4600",
|
"iso_checksum": "e2ecdace33c939527cbc9e8d23576381c493b071107207d2040af72595f8990b",
|
||||||
"iso_checksum_type": "sha256",
|
"iso_checksum_type": "sha256",
|
||||||
"iso_name": "ubuntu-16.04.3-server-amd64.iso",
|
"iso_name": "ubuntu-18.04.4-server-amd64.iso",
|
||||||
"iso_path": "/Volumes/Storage/software/ubuntu",
|
"iso_path": "iso",
|
||||||
"iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.3-server-amd64.iso",
|
"iso_url": "http://cdimage.ubuntu.com/ubuntu/releases/bionic/release/ubuntu-18.04.4-server-amd64.iso",
|
||||||
"memory": "1024",
|
"memory": "1024",
|
||||||
"preseed" : "preseed.cfg",
|
"hostname": "riot-vm",
|
||||||
"hostname": "vagrant",
|
"ssh_username": "user",
|
||||||
"ssh_fullname": "vagrant",
|
"ssh_password": "user",
|
||||||
"ssh_password": "vagrant",
|
|
||||||
"ssh_username": "vagrant",
|
|
||||||
"vagrantfile_template": "vagrantfile.tpl",
|
"vagrantfile_template": "vagrantfile.tpl",
|
||||||
"virtualbox_guest_os_type": "Ubuntu_64",
|
"virtualbox_guest_os_type": "Ubuntu_64",
|
||||||
"vm_name": "RIOT-VM"
|
"vm_name": "RIOT-VM"
|
||||||
|
|||||||
14
dist/tools/packer/scripts/base.sh
vendored
Normal file
14
dist/tools/packer/scripts/base.sh
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
apt-get update
|
||||||
|
apt-get -y upgrade
|
||||||
|
apt-get -y install linux-headers-$(uname -r)
|
||||||
|
|
||||||
|
# Fix locale setup
|
||||||
|
locale-gen
|
||||||
|
localectl set-locale LANG="en_US.UTF-8"
|
||||||
|
|
||||||
|
# Allow usage of serial port
|
||||||
|
adduser ${SSH_USERNAME} dialout
|
||||||
|
|
||||||
|
echo '%sudo ALL=(ALL:ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||||
|
|
||||||
|
echo "UseDNS no" >> /etc/ssh/sshd_config
|
||||||
91
dist/tools/packer/scripts/cleanup.sh
vendored
Normal file
91
dist/tools/packer/scripts/cleanup.sh
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
apt-get -y upgrade
|
||||||
|
apt-get -y autoremove
|
||||||
|
apt-get -y clean
|
||||||
|
|
||||||
|
echo "cleaning up guest additions"
|
||||||
|
rm -rf VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.?
|
||||||
|
|
||||||
|
echo "cleaning permissions"
|
||||||
|
chown -R ${SSH_USERNAME}:${SSH_USERNAME} /home/${SSH_USERNAME}
|
||||||
|
|
||||||
|
# Remove some packages to get a minimal install
|
||||||
|
echo "==> Removing all linux kernels except the current one"
|
||||||
|
dpkg --list | awk '{ print $2 }' | grep 'linux-image-*-generic' | grep -v $(uname -r) | xargs apt-get -y purge
|
||||||
|
echo "==> Removing linux source"
|
||||||
|
dpkg --list | awk '{ print $2 }' | grep linux-source | xargs apt-get -y purge
|
||||||
|
echo "==> Removing documentation"
|
||||||
|
dpkg --list | awk '{ print $2 }' | grep -- '-doc$' | xargs apt-get -y purge
|
||||||
|
echo "==> Removing default system Ruby"
|
||||||
|
apt-get -y purge ruby ri doc
|
||||||
|
echo "==> Removing obsolete networking components"
|
||||||
|
apt-get -y purge ppp pppconfig pppoeconf
|
||||||
|
echo "==> Removing other oddities"
|
||||||
|
apt-get -y purge popularity-contest installation-report landscape-common wireless-tools wpasupplicant
|
||||||
|
|
||||||
|
# Clean up the apt cache
|
||||||
|
apt-get -y autoremove --purge
|
||||||
|
apt-get -y autoclean
|
||||||
|
apt-get -y clean
|
||||||
|
|
||||||
|
echo "removing man pages"
|
||||||
|
rm -rf /usr/share/man/*
|
||||||
|
echo "removing APT files"
|
||||||
|
find /var/lib/apt -type f | xargs rm -f
|
||||||
|
echo "removing any docs"
|
||||||
|
rm -rf /usr/share/doc/*
|
||||||
|
echo "removing caches"
|
||||||
|
find /var/cache -type f -exec rm -rf {} \;
|
||||||
|
|
||||||
|
echo "cleaning up tmp"
|
||||||
|
rm -rf /tmp/*
|
||||||
|
|
||||||
|
# Remove Bash history
|
||||||
|
unset HISTFILE
|
||||||
|
rm -f /root/.bash_history
|
||||||
|
rm -f ${SSH_USER_HOME}/.bash_history
|
||||||
|
|
||||||
|
# Clean up log files
|
||||||
|
find /var/log -type f | while read f; do echo -ne '' > "${f}"; done;
|
||||||
|
|
||||||
|
echo "clearing last login information"
|
||||||
|
>/var/log/lastlog
|
||||||
|
>/var/log/wtmp
|
||||||
|
>/var/log/btmp
|
||||||
|
|
||||||
|
echo "whiteout /"
|
||||||
|
count=$(df --sync -kP / | tail -n1 | awk -F ' ' '{print $4}')
|
||||||
|
let count--
|
||||||
|
dd if=/dev/zero of=/tmp/whitespace bs=1024 count=$count
|
||||||
|
rm /tmp/whitespace
|
||||||
|
|
||||||
|
echo "whiteout /boot"
|
||||||
|
count=$(df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}')
|
||||||
|
let count--
|
||||||
|
dd if=/dev/zero of=/boot/whitespace bs=1024 count=$count
|
||||||
|
rm /boot/whitespace
|
||||||
|
|
||||||
|
echo "clear out swap and disable until reboot"
|
||||||
|
set +e
|
||||||
|
swapuuid=$(/sbin/blkid -o value -l -s UUID -t TYPE=swap)
|
||||||
|
case "$?" in
|
||||||
|
2|0) ;;
|
||||||
|
*) exit 1 ;;
|
||||||
|
esac
|
||||||
|
set -e
|
||||||
|
if [ "x${swapuuid}" != "x" ]; then
|
||||||
|
# Whiteout the swap partition to reduce box size
|
||||||
|
# Swap is disabled till reboot
|
||||||
|
swappart=$(readlink -f /dev/disk/by-uuid/$swapuuid)
|
||||||
|
/sbin/swapoff "${swappart}"
|
||||||
|
dd if=/dev/zero of="${swappart}" bs=1M || echo "dd exit code $? is suppressed"
|
||||||
|
/sbin/mkswap -U "${swapuuid}" "${swappart}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "whiteout free space"
|
||||||
|
dd if=/dev/zero of=/EMPTY bs=1M || echo "dd exit code $? is suppressed"
|
||||||
|
rm -f /EMPTY
|
||||||
|
|
||||||
|
sync
|
||||||
|
|
||||||
|
echo "disk usage"
|
||||||
|
df -h
|
||||||
41
dist/tools/packer/scripts/riot.sh
vendored
Normal file
41
dist/tools/packer/scripts/riot.sh
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
apt-get update
|
||||||
|
apt-get install -y ccache clang cmake curl git build-essential vim python-setuptools \
|
||||||
|
python-argparse python3-pip python-pip mosquitto-clients socat g++-multilib \
|
||||||
|
net-tools pcregrep libpcre3 gcc-avr binutils-avr avr-libc \
|
||||||
|
avrdude doxygen cppcheck valgrind coccinelle \
|
||||||
|
gcc-msp430 mspdebug unzip pkg-config jimsh libtool \
|
||||||
|
#
|
||||||
|
|
||||||
|
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -y tshark
|
||||||
|
|
||||||
|
# Add .local/bin to PATH
|
||||||
|
# Required for Python packages installed in user home directory
|
||||||
|
echo "export PATH=\$PATH:/home/${SSH_USERNAME}/.local/bin" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
|
||||||
|
# IoT-LAB CLI tools
|
||||||
|
sudo -u /${SSH_USERNAME} pip3 install --user iotlabwscli iotlabsshcli iotlabcli
|
||||||
|
|
||||||
|
# Python tools
|
||||||
|
sudo -u /${SSH_USERNAME} pip3 install --user aiocoap pyocd paho-mqtt pyserial flake8 tox \
|
||||||
|
pyasn1 ecdsa pexpect pycrypto ed25519 cbor cryptography \
|
||||||
|
scapy codespell protobuf jupyterlab \
|
||||||
|
#
|
||||||
|
|
||||||
|
# OpenOCD
|
||||||
|
apt-get install -y build-essential libftdi-dev libhidapi-dev \
|
||||||
|
libusb-1.0-0-dev libudev-dev autoconf libsqlite3-dev \
|
||||||
|
libpopt-dev libxml2-dev ruby libtool pkg-config
|
||||||
|
|
||||||
|
git clone https://github.com/ntfreak/openocd openocd && \
|
||||||
|
cd openocd && \
|
||||||
|
git checkout 09ac9ab135ed35c846bcec4f7d468c3656852f26 && \
|
||||||
|
./bootstrap && ./configure && \
|
||||||
|
make && \
|
||||||
|
make install && \
|
||||||
|
cd .. && rm -rf openocd
|
||||||
|
|
||||||
|
# JLink
|
||||||
|
JLINK_PKG_DEB="JLink_Linux_V644g_x86_64.deb"
|
||||||
|
wget -nv http://demo-fit.saclay.inria.fr/vms/utils/${JLINK_PKG_DEB} && \
|
||||||
|
dpkg -i ${JLINK_PKG_DEB} && \
|
||||||
|
rm -f ${JLINK_PKG_DEB}
|
||||||
104
dist/tools/packer/scripts/toolchains.sh
vendored
Normal file
104
dist/tools/packer/scripts/toolchains.sh
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
# Install ARM GNU Embedded toolchain
|
||||||
|
ARM_GCC_URL="https://developer.arm.com/-/media/Files/downloads/gnu-rm"
|
||||||
|
ARM_GCC_VERSION="9-2019q4"
|
||||||
|
ARM_GCC_ARCHIVE="gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2"
|
||||||
|
ARM_GCC_ARCHIVE_URL="${ARM_GCC_URL}/${ARM_GCC_VERSION}/${ARM_GCC_ARCHIVE}"
|
||||||
|
|
||||||
|
cd /opt && wget -nv -O - "${ARM_GCC_ARCHIVE_URL}" | tar -jxf -
|
||||||
|
|
||||||
|
echo "export PATH=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin:\$PATH" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
|
||||||
|
# Install MIPS toolchain
|
||||||
|
MIPS_VERSION=2018.09-03
|
||||||
|
curl -L "https://codescape.mips.com/components/toolchain/${MIPS_VERSION}/Codescape.GNU.Tools.Package.${MIPS_VERSION}.for.MIPS.MTI.Bare.Metal.CentOS-6.x86_64.tar.gz" -o - \
|
||||||
|
| tar -C /opt -zx
|
||||||
|
rm -rf /opt/mips-mti-elf/*/share/{doc,info,man,locale}
|
||||||
|
cd /opt/mips-mti-elf/*/mips-mti-elf/bin
|
||||||
|
for f in *; do test -f "../../bin/mips-mti-elf-$f" && ln -f "../../bin/mips-mti-elf-$f" "$f"; done
|
||||||
|
cd -
|
||||||
|
|
||||||
|
echo "export MIPS_ELF_ROOT=/opt/mips-mti-elf/${MIPS_VERSION}" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
echo "export PATH=\$MIPS_ELF_ROOT/bin:\$PATH" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
|
||||||
|
# Install MSP430 toolchain
|
||||||
|
MSP430_URL=https://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/latest/exports
|
||||||
|
MSP430_VERSION=8.3.0.16_linux64
|
||||||
|
wget -q ${MSP430_URL}/msp430-gcc-${MSP430_VERSION}.tar.bz2 -O- | tar -C /opt -xj
|
||||||
|
echo "export PATH=\$PATH:/opt/msp430-gcc-${MSP430_VERSION}/bin" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
|
||||||
|
# Install RISC-V
|
||||||
|
RISCV_VERSION=8.2.0-2.2-20190521
|
||||||
|
RISCV_BUILD=0004
|
||||||
|
wget -q https://github.com/gnu-mcu-eclipse/riscv-none-gcc/releases/download/v${RISCV_VERSION}/gnu-mcu-eclipse-riscv-none-gcc-${RISCV_VERSION}-${RISCV_BUILD}-centos64.tgz -O- \
|
||||||
|
| tar -C /opt -xz
|
||||||
|
rm -rf /opt/gnu-mcu-eclipse/riscv-none-gcc/*/share/doc
|
||||||
|
cd /opt/gnu-mcu-eclipse/riscv-none-gcc/*/riscv-none-embed/bin
|
||||||
|
for f in *; do test -f "../../bin/riscv-none-embed-$f" && \
|
||||||
|
ln -f "../../bin/riscv-none-embed-$f" "$f"; \
|
||||||
|
done
|
||||||
|
cd -
|
||||||
|
|
||||||
|
echo "export PATH=/opt/gnu-mcu-eclipse/riscv-none-gcc/${RISCV_VERSION}-${RISCV_BUILD}/bin:\$PATH" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
|
||||||
|
# Install ESP32 toolchain
|
||||||
|
echo 'Installing ESP32 toolchain'
|
||||||
|
mkdir -p /opt/esp
|
||||||
|
cd /opt/esp
|
||||||
|
git clone https://github.com/espressif/esp-idf.git
|
||||||
|
cd esp-idf
|
||||||
|
git checkout -q f198339ec09e90666150672884535802304d23ec
|
||||||
|
git submodule update --init --recursive
|
||||||
|
rm -rf .git* docs examples make tools
|
||||||
|
rm -f add_path.sh CONTRIBUTING.rst Kconfig Kconfig.compiler
|
||||||
|
cd components
|
||||||
|
rm -rf app_trace app_update aws_iot bootloader bt coap console cxx \
|
||||||
|
esp_adc_cal espcoredump esp_http_client esp-tls expat fatfs \
|
||||||
|
freertos idf_test jsmn json libsodium log lwip mbedtls mdns \
|
||||||
|
micro-ecc nghttp openssl partition_table pthread sdmmc spiffs \
|
||||||
|
tcpip_adapter ulp vfs wear_levelling xtensa-debug-module && \
|
||||||
|
find . -name '*.[csS]' -exec rm {} \;
|
||||||
|
cd /opt/esp
|
||||||
|
git clone https://github.com/gschorcht/xtensa-esp32-elf.git && \
|
||||||
|
cd xtensa-esp32-elf
|
||||||
|
git checkout -q ca40fb4c219accf8e7c8eab68f58a7fc14cadbab
|
||||||
|
|
||||||
|
echo "export PATH=/opt/esp/xtensa-esp32-elf/bin:\$PATH" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
|
||||||
|
# Install ESP8266 toolchain
|
||||||
|
# Install complete ESP8266 toolchain in /opt/esp (146 MB after cleanup)
|
||||||
|
echo 'Installing ESP8266 toolchain' >&2 && \
|
||||||
|
cd /opt && \
|
||||||
|
git clone https://github.com/gschorcht/RIOT-Xtensa-ESP8266-toolchain.git esp && \
|
||||||
|
cd esp && \
|
||||||
|
git checkout -q df38b06 && \
|
||||||
|
rm -rf .git
|
||||||
|
|
||||||
|
echo "export PATH=\$PATH:/opt/esp/esp-open-sdk/xtensa-lx106-elf/bin" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
echo "export ESP8266_SDK_DIR=/opt/esp/esp-open-sdk/sdk" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
echo "export ESP8266_NEWLIB_DIR=/opt/esp/newlib-xtensa" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
|
||||||
|
# Install complete ESP8266 toolchain in /opt/esp (139 MB after cleanup)
|
||||||
|
# remember https://github.com/RIOT-OS/RIOT/pull/10801 when updating
|
||||||
|
# NOTE: We install the toolchain for the RTOS SDK in parallel in the first
|
||||||
|
# step and remove the old version as soon as the RIOT port for the ESP8266
|
||||||
|
# RTOS SDK has been merged.
|
||||||
|
echo 'Installing ESP8266 toolchain' >&2 && \
|
||||||
|
mkdir -p /opt/esp && \
|
||||||
|
cd /opt/esp && \
|
||||||
|
git clone https://github.com/gschorcht/xtensa-esp8266-elf && \
|
||||||
|
cd xtensa-esp8266-elf && \
|
||||||
|
git checkout -q 696257c2b43e2a107d3108b2c1ca6d5df3fb1a6f && \
|
||||||
|
rm -rf .git && \
|
||||||
|
cd /opt/esp && \
|
||||||
|
git clone https://github.com/gschorcht/RIOT-Xtensa-ESP8266-RTOS-SDK.git ESP8266_RTOS_SDK && \
|
||||||
|
cd ESP8266_RTOS_SDK/ && \
|
||||||
|
git checkout -q f074414c0705715a44b8e59d53b03d90b7630382 && \
|
||||||
|
rm -rf .git* docs examples make tools && \
|
||||||
|
cd components && \
|
||||||
|
rm -rf app_update aws_iot bootloader cjson coap espos esp-tls freertos \
|
||||||
|
jsmn libsodium log mdns mqtt newlib partition_table pthread \
|
||||||
|
smartconfig_ack spiffs ssl tcpip_adapter vfs && \
|
||||||
|
find . -name '*.[csS]' -exec rm {} \;
|
||||||
|
|
||||||
|
echo "export PATH=\$PATH:/opt/esp/xtensa-esp8266-elf/bin" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
|
echo "export ESP8266_RTOS_SDK_DIR=/opt/esp/ESP8266_RTOS_SDK" >> /home/${SSH_USERNAME}/.bashrc
|
||||||
50
dist/tools/packer/scripts/udev_rules.sh
vendored
Normal file
50
dist/tools/packer/scripts/udev_rules.sh
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Udev rules
|
||||||
|
# JLink
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", MODE="0664", GROUP="dialout"' \
|
||||||
|
> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
|
||||||
|
# ST-Link
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE="0664", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="0666", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
|
||||||
|
# UBSASP
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", MODE="0666", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
|
||||||
|
# USBTTL
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0666", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
|
||||||
|
# ATmega32u4
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0036", MODE="0666", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
|
||||||
|
# ATmega2560
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0042", MODE="0666", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
|
||||||
|
# CMSIS-DAP (EDBG)
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE="0664", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
echo 'KERNEL=="hidraw*", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE="664", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
|
||||||
|
# Arduino Zero
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2157", MODE="0664", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
echo 'KERNEL=="hidraw*", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2157", MODE="664", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
|
||||||
|
# DAPLink
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0d28", ATTRS{idProduct}=="0204", MODE="0664", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
echo 'KERNEL=="hidraw*", ATTRS{idVendor}=="0d28", ATTRS{idProduct}=="0204", MODE="664", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
|
||||||
|
# IoT-LAB M3
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTR{idProduct}=="6010", ATTR{idVendor}=="0403", MODE="0664", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
|
echo 'SUBSYSTEM=="usb", ATTR{idProduct}=="6011", ATTR{idVendor}=="0403", MODE="0664", GROUP="dialout"' \
|
||||||
|
>> /etc/udev/rules.d/riot-dev.rules
|
||||||
10
dist/tools/packer/scripts/vagrant.sh
vendored
Normal file
10
dist/tools/packer/scripts/vagrant.sh
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
date > /etc/vagrant_box_build_time
|
||||||
|
|
||||||
|
mkdir /home/${SSH_USERNAME}/.ssh
|
||||||
|
wget --no-check-certificate \
|
||||||
|
'https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub' \
|
||||||
|
-O /home/${SSH_USERNAME}/.ssh/authorized_keys
|
||||||
|
chown -R user /home/${SSH_USERNAME}/.ssh
|
||||||
|
chmod -R go-rwsx /home/${SSH_USERNAME}/.ssh
|
||||||
|
# Create SSH key pair
|
||||||
|
yes y | ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa
|
||||||
7
dist/tools/packer/scripts/virtualbox.sh
vendored
Normal file
7
dist/tools/packer/scripts/virtualbox.sh
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
mkdir /tmp/virtualbox
|
||||||
|
VERSION=$(cat /home/${SSH_USERNAME}/.vbox_version)
|
||||||
|
mount -o loop /home/${SSH_USERNAME}/VBoxGuestAdditions_$VERSION.iso /tmp/virtualbox
|
||||||
|
sh /tmp/virtualbox/VBoxLinuxAdditions.run
|
||||||
|
umount /tmp/virtualbox
|
||||||
|
rmdir /tmp/virtualbox
|
||||||
|
rm /home/${SSH_USERNAME}/*.iso
|
||||||
159
dist/tools/packer/setup.sh
vendored
159
dist/tools/packer/setup.sh
vendored
@ -1,159 +0,0 @@
|
|||||||
#!/usr/bin/env bash -eux
|
|
||||||
|
|
||||||
# inspired by https://github.com/boxcutter/ubuntu
|
|
||||||
|
|
||||||
echo "==> Disabling the release upgrader"
|
|
||||||
sed -i.bak 's/^Prompt=.*$/Prompt=never/' /etc/update-manager/release-upgrades
|
|
||||||
|
|
||||||
systemctl disable apt-daily.service
|
|
||||||
systemctl disable apt-daily.timer
|
|
||||||
|
|
||||||
echo "==> Updating list of repositories"
|
|
||||||
apt-get -y update
|
|
||||||
|
|
||||||
echo "==> Performing dist-upgrade (all packages and kernel)"
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
|
|
||||||
|
|
||||||
SSH_USER=${SSH_USERNAME:-vagrant}
|
|
||||||
SSH_PASS=${SSH_PASSWORD:-vagrant}
|
|
||||||
SSH_USER_HOME=${SSH_USER_HOME:-/home/${SSH_USER}}
|
|
||||||
VAGRANT_INSECURE_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
|
|
||||||
|
|
||||||
echo "==> Giving ${SSH_USER} sudo powers"
|
|
||||||
echo "${SSH_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
|
|
||||||
chmod 440 /etc/sudoers.d/vagrant
|
|
||||||
|
|
||||||
if grep -q -E "^mesg n$" /root/.profile && sed -i "s/^mesg n$/tty -s \\&\\& mesg n/g" /root/.profile; then
|
|
||||||
echo "==> Fixed stdin not being a tty."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "==> Installing vagrant key"
|
|
||||||
mkdir $SSH_USER_HOME/.ssh
|
|
||||||
chmod 700 $SSH_USER_HOME/.ssh
|
|
||||||
|
|
||||||
# https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub
|
|
||||||
echo "${VAGRANT_INSECURE_KEY}" > $SSH_USER_HOME/.ssh/authorized_keys
|
|
||||||
chmod 600 $SSH_USER_HOME/.ssh/authorized_keys
|
|
||||||
chown -R $SSH_USER:$SSH_USER $SSH_USER_HOME/.ssh
|
|
||||||
|
|
||||||
echo "UseDNS no" >> /etc/ssh/sshd_config
|
|
||||||
|
|
||||||
if [[ $PACKER_BUILDER_TYPE =~ virtualbox ]]; then
|
|
||||||
echo "==> Installing VirtualBox guest additions"
|
|
||||||
VBOX_VERSION=$(cat ${SSH_USER_HOME}/.vbox_version)
|
|
||||||
mount -o loop ${SSH_USER_HOME}/VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
|
|
||||||
sh /mnt/VBoxLinuxAdditions.run
|
|
||||||
umount /mnt
|
|
||||||
rm ${SSH_USER_HOME}/VBoxGuestAdditions_$VBOX_VERSION.iso
|
|
||||||
rm ${SSH_USER_HOME}/.vbox_version
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "==> Install stlink"
|
|
||||||
wget -qO - https://github.com/texane/stlink/archive/master.tar.gz | tar xz
|
|
||||||
mkdir stlink-master/build && cd stlink-master/build && cmake .. && make && make install
|
|
||||||
cd ../.. && rm -rf stlink.git
|
|
||||||
|
|
||||||
echo "==> Install cli-tools"
|
|
||||||
wget -qO - https://github.com/iot-lab/cli-tools/archive/2.1.0.tar.gz | tar xz
|
|
||||||
cd cli-tools-* && python setup.py install && cd .. && rm -rf cli-tools-*
|
|
||||||
|
|
||||||
# Remove some packages to get a minimal install
|
|
||||||
echo "==> Removing all linux kernels except the current one"
|
|
||||||
dpkg --list | awk '{ print $2 }' | grep 'linux-image-*-generic' | grep -v $(uname -r) | xargs apt-get -y purge
|
|
||||||
echo "==> Removing linux source"
|
|
||||||
dpkg --list | awk '{ print $2 }' | grep linux-source | xargs apt-get -y purge
|
|
||||||
echo "==> Removing documentation"
|
|
||||||
dpkg --list | awk '{ print $2 }' | grep -- '-doc$' | xargs apt-get -y purge
|
|
||||||
echo "==> Removing default system Ruby"
|
|
||||||
apt-get -y purge ruby ri doc
|
|
||||||
echo "==> Removing X11 libraries"
|
|
||||||
apt-get -y purge libx11-data xauth libxmuu1 libxcb1 libx11-6 libxext6
|
|
||||||
echo "==> Removing obsolete networking components"
|
|
||||||
apt-get -y purge ppp pppconfig pppoeconf
|
|
||||||
echo "==> Removing other oddities"
|
|
||||||
apt-get -y purge popularity-contest installation-report landscape-common wireless-tools wpasupplicant
|
|
||||||
|
|
||||||
# Clean up the apt cache
|
|
||||||
apt-get -y autoremove --purge
|
|
||||||
apt-get -y autoclean
|
|
||||||
apt-get -y clean
|
|
||||||
|
|
||||||
# Clean up orphaned packages with deborphan
|
|
||||||
apt-get -y install deborphan
|
|
||||||
while [ -n "$(deborphan --guess-all --no-guesspython --libdevel)" ]; do
|
|
||||||
deborphan --guess-all --no-guess-python --libdevel | xargs apt-get -y purge
|
|
||||||
done
|
|
||||||
apt-get -y purge deborphan dialog
|
|
||||||
|
|
||||||
echo "==> Removing man pages"
|
|
||||||
rm -rf /usr/share/man/*
|
|
||||||
echo "==> Removing APT files"
|
|
||||||
find /var/lib/apt -type f | xargs rm -f
|
|
||||||
echo "==> Removing any docs"
|
|
||||||
rm -rf /usr/share/doc/*
|
|
||||||
echo "==> Removing caches"
|
|
||||||
find /var/cache -type f -exec rm -rf {} \;
|
|
||||||
|
|
||||||
echo "==> Cleaning up leftover dhcp leases"
|
|
||||||
if [ -d "/var/lib/dhcp" ]; then
|
|
||||||
rm /var/lib/dhcp/*
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add delay to prevent "vagrant reload" from failing
|
|
||||||
echo "pre-up sleep 2" >> /etc/network/interfaces
|
|
||||||
|
|
||||||
mv /tmp/udev_rules/* /etc/udev/rules.d/
|
|
||||||
|
|
||||||
echo "==> Cleaning up tmp"
|
|
||||||
rm -rf /tmp/*
|
|
||||||
|
|
||||||
# Remove Bash history
|
|
||||||
unset HISTFILE
|
|
||||||
rm -f /root/.bash_history
|
|
||||||
rm -f ${SSH_USER_HOME}/.bash_history
|
|
||||||
|
|
||||||
# Clean up log files
|
|
||||||
find /var/log -type f | while read f; do echo -ne '' > "${f}"; done;
|
|
||||||
|
|
||||||
echo "==> Clearing last login information"
|
|
||||||
>/var/log/lastlog
|
|
||||||
>/var/log/wtmp
|
|
||||||
>/var/log/btmp
|
|
||||||
|
|
||||||
echo "==> whiteout /"
|
|
||||||
count=$(df --sync -kP / | tail -n1 | awk -F ' ' '{print $4}')
|
|
||||||
let count--
|
|
||||||
dd if=/dev/zero of=/tmp/whitespace bs=1024 count=$count
|
|
||||||
rm /tmp/whitespace
|
|
||||||
|
|
||||||
echo "==> whiteout /boot"
|
|
||||||
count=$(df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}')
|
|
||||||
let count--
|
|
||||||
dd if=/dev/zero of=/boot/whitespace bs=1024 count=$count
|
|
||||||
rm /boot/whitespace
|
|
||||||
|
|
||||||
echo '==> Clear out swap and disable until reboot'
|
|
||||||
set +e
|
|
||||||
swapuuid=$(/sbin/blkid -o value -l -s UUID -t TYPE=swap)
|
|
||||||
case "$?" in
|
|
||||||
2|0) ;;
|
|
||||||
*) exit 1 ;;
|
|
||||||
esac
|
|
||||||
set -e
|
|
||||||
if [ "x${swapuuid}" != "x" ]; then
|
|
||||||
# Whiteout the swap partition to reduce box size
|
|
||||||
# Swap is disabled till reboot
|
|
||||||
swappart=$(readlink -f /dev/disk/by-uuid/$swapuuid)
|
|
||||||
/sbin/swapoff "${swappart}"
|
|
||||||
dd if=/dev/zero of="${swappart}" bs=1M || echo "dd exit code $? is suppressed"
|
|
||||||
/sbin/mkswap -U "${swapuuid}" "${swappart}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "==> whiteout free space"
|
|
||||||
dd if=/dev/zero of=/EMPTY bs=1M || echo "dd exit code $? is suppressed"
|
|
||||||
rm -f /EMPTY
|
|
||||||
|
|
||||||
sync
|
|
||||||
|
|
||||||
echo "==> Disk usage"
|
|
||||||
df -h
|
|
||||||
4
dist/tools/packer/vagrantfile.tpl
vendored
4
dist/tools/packer/vagrantfile.tpl
vendored
@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.define "RIOT-VM"
|
config.vm.define "RIOT-VM"
|
||||||
config.vm.box = "RIOT/ubuntu1604"
|
config.vm.box = "RIOT/ubuntu1804"
|
||||||
|
config.ssh.username = "user"
|
||||||
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||||
|
|
||||||
config.vm.provider :virtualbox do |v, override|
|
config.vm.provider :virtualbox do |v, override|
|
||||||
v.gui = false
|
v.gui = false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user