diff options
author | Ilias Apalodimas <ilias.apalodimas@linaro.org> | 2017-08-26 15:27:10 +0300 |
---|---|---|
committer | Ilias Apalodimas <ilias.apalodimas@linaro.org> | 2017-08-26 15:27:10 +0300 |
commit | 8a3e8b01a74a22826ea844422928cceb40eec425 (patch) | |
tree | e84e31cd62cc4ff55cdd8bc62760881e12b7fd2c |
Initial commit
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | README.md | 10 | ||||
-rwxr-xr-x | netmap/build.sh | 10 | ||||
-rw-r--r-- | netmap/debian-9.0.0-x64.json | 68 | ||||
-rw-r--r-- | netmap/http/preseed.cfg | 76 | ||||
-rwxr-xr-x | netmap/scripts/netmap.sh | 7 | ||||
-rwxr-xr-x | netmap/scripts/odp.sh | 13 |
7 files changed, 189 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a6c0960 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# Cache objects +**/packer_cache/ + +# For built images +**/output-* diff --git a/README.md b/README.md new file mode 100644 index 0000000..45989b2 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +## Synopsis +Create VM images using packer.io + +## Installation + +1. Install packer <https://www.packer.io/> +2. Got to the selected directory and run build.sh some-file.json. cd netmap ./build.sh debian-9.0.0.json + +## Generated images boot examples +1. `qemu-system-x86_64 -m 4G -smp 4 -drive file="replace-generated-image",if=virtio -enable-kvm -cpu host` diff --git a/netmap/build.sh b/netmap/build.sh new file mode 100755 index 0000000..c0e4b27 --- /dev/null +++ b/netmap/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +[ $# -lt 1 ] && echo "No build recipe specifid. Exiting" && exit 1 + +# Enable logging +#export PACKER_LOG="yes" +#export PACKER_LOG_PATH="build_output.log" +what=$1 + +packer build $what diff --git a/netmap/debian-9.0.0-x64.json b/netmap/debian-9.0.0-x64.json new file mode 100644 index 0000000..1d13758 --- /dev/null +++ b/netmap/debian-9.0.0-x64.json @@ -0,0 +1,68 @@ +{ + "variables": { + "cur_home": "{{env `HOME`}}", + "user": "packer", + "password": "packer", + "disk_size": "32768", + "domain": "testing.lan", + "debian_version": "9.0.0" + }, + "builders": [ + { + "name": "tester", + "vm_name": "tester", + + "iso_url": "http://cdimage.debian.org/cdimage/archive/{{user `debian_version`}}/amd64/iso-cd/debian-{{user `debian_version`}}-amd64-netinst.iso", + "iso_checksum_url": "http://cdimage.debian.org/cdimage/archive/{{user `debian_version`}}/amd64/iso-cd/SHA512SUMS", + "iso_checksum_type": "sha512", + + "type": "qemu", + "format": "qcow2", + "accelerator": "kvm", + "qemuargs": [[ "-m", "2048M" ],[ "-smp", "4" ]], + "headless": false, + + "communicator": "ssh", + "ssh_pty": "true", + + "ssh_username": "{{user `user`}}", + "ssh_password": "{{user `password`}}", + "ssh_wait_timeout": "60m", + + "shutdown_command": "echo 'packer' | sudo -S shutdown -P now", + + "disk_interface": "virtio", + "disk_size": 32768, + "http_directory" : "http", + + "boot_wait": "10s", + "boot_command" : [ + "<esc><wait>", + "install <wait>", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg <wait>", + "debian-installer=en_US <wait>", + "auto <wait>", + "locale=en_US <wait>", + "kbd-chooser/method=us <wait>", + "keyboard-configuration/xkb-keymap=us <wait>", + "netcfg/get_hostname={{ .Name }} <wait>", + "netcfg/get_domain={{ user `domain`}} <wait>", + "fb=false <wait>", + "debconf/frontend=noninteractive <wait>", + "console-setup/ask_detect=false <wait>", + "console-keymaps-at/keymap=us <wait>", + "<enter><wait>" + ] + } + ], + + "provisioners": [ + { + "type": "shell", + "scripts": [ + "scripts/netmap.sh", + "scripts/odp.sh" + ] + } + ] +} diff --git a/netmap/http/preseed.cfg b/netmap/http/preseed.cfg new file mode 100644 index 0000000..730b249 --- /dev/null +++ b/netmap/http/preseed.cfg @@ -0,0 +1,76 @@ +choose-mirror-bin mirror/http/proxy string +d-i apt-setup/use_mirror boolean true +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/bootdev string default +d-i grub-installer/only_debian boolean true +d-i grub-installer/with_other_os boolean true + +d-i keymap select us + +d-i mirror/country string manual +d-i mirror/http/directory string /debian +d-i mirror/http/hostname string http.debian.net +d-i mirror/http/proxy string + +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 + +d-i passwd/root-login boolean true +d-i passwd/root-password-again password root +d-i passwd/root-password password root +d-i passwd/user-fullname string tester +d-i passwd/username string packer +d-i passwd/user-uid string 1001 +d-i passwd/user-password password packer +d-i passwd/user-password-again password packer + +#include common/non-free +d-i apt-setup/non-free boolean true +d-i apt-setup/contrib boolean true +# include packages +d-i pkgsel/include string sudo git make linux-headers-$(uname -r) ethtool \ + build-essential vim automake libtool libssl-dev asciidoctor asciidoctor-doc \ + libcunit1 libcunit1-dev + +d-i pkgsel/install-language-support boolean false +d-i pkgsel/update-policy select unattended-upgrades + +# Update system +# d-i pkgsel/upgrade select full-upgrade + +# Prevent packaged version of VirtualBox Guest Additions being installed: +d-i preseed/early_command string sed -i \ + '/in-target/idiscover(){/sbin/discover|grep -v VirtualBox;}' \ + /usr/lib/pre-pkgsel.d/20install-hwpackages + +d-i time/zone string UTC + +d-i user-setup/allow-password-weak boolean true +d-i user-setup/encrypt-home boolean false + +d-i preseed/late_command string sed -i '/^deb cdrom:/s/^/#/' /target/etc/apt/sources.list + +apt-cdrom-setup apt-setup/cdrom/set-first boolean false +apt-mirror-setup apt-setup/use_mirror boolean true + +popularity-contest popularity-contest/participate boolean false +tasksel tasksel/first multiselect standard, ssh-server + +# Install cpe-tester on sudoers, will be deleted after installation +d-i preseed/late_command string \ + echo "packer ALL=(ALL:ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/packer && chmod 0440 /target/etc/sudoers.d/packer diff --git a/netmap/scripts/netmap.sh b/netmap/scripts/netmap.sh new file mode 100755 index 0000000..08c7aef --- /dev/null +++ b/netmap/scripts/netmap.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +git clone https://github.com/luigirizzo/netmap +cd netmap +./configure +make -j24 +sudo make install diff --git a/netmap/scripts/odp.sh b/netmap/scripts/odp.sh new file mode 100755 index 0000000..dcfefe5 --- /dev/null +++ b/netmap/scripts/odp.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +git clone https://github.com/Linaro/odp.git +cd odp +./bootstrap +#./configure --prefix=$HOME/odp-install --enable-test-cpp --enable-test-vald \ + #--enable-test-helper --enable-test-perf --enable-user-guides \ + #--enable-test-perf-proc --enable-test-example \ + #--with-netmap-path=`pwd`/netmap --enable-debug #--with-cunit-path=$HOME/cunit-install/$CROSS_ARCH $CONF + +./configure --prefix=$HOME/odp-install --with-netmap-path=`pwd`/netmap --enable-debug +make -j 24 +make install |