Perkify - Making Vagrant Boxes

Written by Rich Morin.

Contents: (hide) (show)

Path:  AreasContentOverviews

Precis:  notes on making Vagrant-based Perkify boxes

My current approach to making Vagrant-based Perkify boxes is a bit more manual than I’d prefer. If and when I understand Packer a bit better, I may start using it.

Background

The Perkify directory contains a set of files used in making a new box.

The _base sub-directory contains scripts and data files:

_base/
| bin/*                 convenience scripts for Perkify
| | apt_summ            generate an APT package summary
| | path_chk            check $PATH for name conflicts
| html/                 default directory for Apache
| | index.html          dummy "landing page" for Apache
| make/                 files used in making the image
| | add_ons             install add-on packages
| | add_ons.rb          helper for the add_ons script
| | add_ons.toml        specify Perkify add-on packages
| | apt_presets         APT configuration preset file
| | get_apt             get an APT package
| | get_gem             get a Ruby Gem
| | mpma                make perk-make attempt
| | pkg_list.rb         pkg_tbl.md generation script
| | setup_alsa          script to set up ALSA
| | setup_apache        script to set up Apache
| | setup_profile       script to set up ~/.profile
| | sizes_bis           List packages, by Installed-Size
| | sizes_rec           List packages, recursively
| | Vagrantfile.dist    configuration (distributed)
| | Vagrantfile.make_   configuration (for build)
| | Vagrantfile.test    configuration (for tests)
| | vf_common.rb        common code for Vagrantfiles

_save/                  file snapshots, etc.
| V_hax/*               Vagrantfile hack snaps

Procedure

This is a multi-step procedure and some of the steps are quite lengthy. All told, the process takes several hours.

Create a Virtual Machine

Create (if need be) and go to ~/perk-make, then run the mpma (make perk-make attempt) script:

$ mkdir ~/perk-make     # just in case
$ cd ~/perk-make        # get situated
$ mpma

This will:

Note: The “202001.16.0” version of “bento/ubuntu-19.10” got a 404 error. I worked around this by fudging the value of bv in mpma.

Update and Upgrade the VM

Start up an SSH session to the VM:

$ vagrant ssh
...
0 updates can be installed immediately.
0 of these updates are security updates.

Apply the available Ubuntu updates:

vagrant@perk-make:~$ sudo apt update && sudo apt upgrade -y
...

Run these commands again, for good measure:

vagrant@perk-make:~$ sudo apt update && sudo apt upgrade -y
...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Add the Perkify Packages

Fold in the Perkify add-on packages, then tidy up a bit:

vagrant@perk-make:~$ l /vagrant
bin/  html/  make/  Vagrantfile  Vagrantfile.dist  Vagrantfile.make

# Skip the next step to speed up testing. Instead, just:
vagrant@perk-make:~$ cp -R /vagrant _base

vagrant@perk-make:~$ sudo /vagrant/make/add_ons
   1  debian_apt_a11y R, Accerciser, accerciser, accessibility explorer
Tue 21 Jan 2020 09:26:17 PM PST     36.0   583
...
 200  ruby_gems       R, Xiki,       xiki,       text-based menus
Tue 21 Jan 2020 10:24:24 PM PST     29.2    76

Loading issues: none

Named packages:    200
Total packages:   3916
Duration: 3522.1 seconds (58.7 minutes)

Trim the image, then exit and halt the VM:

vagrant@perk-make:~$ sudo apt autoremove
vagrant@perk-make:~$ exit
$ vagrant halt

Bring the image back up, SSH in, kick the tires a bit, and exit…

$ vagrant up
$ vagrant ssh
vagrant@vagrant:~$ ...
vagrant@vagrant:~$ exit

Create and Try Out a Vagrant Package

Save the VM image as a package (aka box):

$ box=../perk_0_2_1.box; rm -f $box
$ vagrant package --output $box --vagrantfile Vagrantfile.dist

$ wc -c $box
8005535020 $box

$ shasum $box
9ce8113b5e40b0f8e94a7f94e584769f3c4faec2  ../perk_0_2_1.box

Try it out, largely per Perkify - Install:

$ rm -rf ~/perk-test                # remove any old working directory
$ mkdir  ~/perk-test                # create a working directory
$ cd     ~/perk-test                # go to the working directory

$ vagrant box add perk-test ../perk_0_2_1.box --force
...
$ vagrant init perk-test --minimal
...
$ vagrant up                        # load and boot the Perkify VM
...
$ vagrant ssh                       # start up an SSH session
...                                 # try things out a bit

Push it to Vagrant Cloud

Set up and populate a new version of Perkify on Vagrant Cloud. Note that we need to work out details for handling upgrades…

Download and try out, largely per Perkify - Install:

$ mkdir ~/perk-test                 # create a working directory
$ cd ~/perk-test                    # go to the working directory
$ vagrant destroy                   # kill off any running VM
$ rm -rf .vagrant *                 # remove cruft

$ vagrant init Rich_Morin/Perkify --box-version 0.2.1
$ vagrant up                        # download and boot the Perkify VM
... this will take about an hour ...

Revoke and/or Delete any old Perkify versions:

These notes are based (very loosely!) on How to Upload Vagrant Box to Vagrant Cloud.

Notes

The add_ons script puts most of its log output in /tmp/add_ons_log/* on the VM. These can be inspected for problems via vagrant ssh.

Resources

APT, OBS, etc.

Packer

Vagrant