Skip to content

Instantly share code, notes, and snippets.

@lalyos
Last active August 29, 2015 14:07
Show Gist options
  • Save lalyos/f8cc8dd77f1e1ab5e628 to your computer and use it in GitHub Desktop.
Save lalyos/f8cc8dd77f1e1ab5e628 to your computer and use it in GitHub Desktop.
boot2docker OSX installer, selecting pacakages

The OSX installer of boot2docker is one single pkg file over 100MB. It containes the follwoing 7 subpackages:

  • DockerCLI : Installs the Docker for Mac OS X client into /usr/local/bin/
  • Boot2DockerCLI : Installs the Boot2Docker management tool into /usr/local/bin/
  • Boot2DockerISO : Installs the boot2docker.iso into /usr/local/share/
  • Boot2DockerAPP : Installs the boot2docker Quick-start applet into /Applications/
  • VBoxKEXTs : Installs the Oracle VM VirtualBox Kernel Extensions into /Library/Application Support/VirtualBox.
  • VBox : Installs the Oracle VM VirtualBox application into /Applications.
  • VBoxCLI : Installs the Oracle VM VirtualBox command line utilities into /usr/bin.

This information was harvested via: installer -package ~/Downloads/Boot2Docker-1.3.0.pkg -showChoicesXML -target /

One-liner

To download the package, select single subpackages, and install them, type this:

curl -Lo /tmp/b2d-130 j.mp/b2d-130 && . /tmp/b2d-130

TL;DR

If you want to know the details the script does read on:

  • it download Boot2Docker-1.3.0.pkg if missing
  • selects sub-packages to install
  • creates a choiceChangesXML with your selection
  • does the installation in verbose mode

Download the pkg

curl -Lo ~/Downloads/Boot2Docker-1.3.0.pkg  https://github.com/boot2docker/osx-installer/releases/download/v1.3.0/Boot2Docker-1.3.0.pkg

Specify Choices

To avoid the GUI, and instal from cli you can use the osx tool: installer. To selectively install packages,You need to create a choiceChangesXML. To create a template chices file use the -showChoiceChangesXML option:

installer -package ~/Downloads/Boot2Docker-1.3.0.pkg  -target / -showChoiceChangesXML
sudo installer -package ~/Downloads/Boot2Docker-1.3.0.pkg \
  -target / \
  -applyChoiceChangesXML /tmp/b2d-single-pack.plist \
  -dumplog

References

#!/bin/bash
cat <<"USAGE"
This script is downloading Boot2Docker-1.3.0.pkg which
contains 7 subpackages:
DockerCLI Boot2DockerCLI Boot2DockerISO Boot2DockerAPP VBoxKEXTs VBox VBoxCLI
You will have a choice, to select which to install
Usage:
=======================================================
curl -Lo /tmp/b2d-130 j.mp/b2d-130 && . /tmp/b2d-130
=======================================================
README: https://gist.github.com/lalyos/f8cc8dd77f1e1ab5e628
USAGE
: ${B2D_PKD:=~/Downloads/Boot2Docker-1.3.0.pkg}
if [ -f $B2D_PKD ]; then
echo [INFO] PKG already downloaded: $B2D_PKD
else
echo [INFO] Downloading PKG to: $B2D_PKD
echo [INFO] It will take a couple of minutes, meanwhile read: https://gist.github.com/lalyos/f8cc8dd77f1e1ab5e628
open https://gist.github.com/lalyos/f8cc8dd77f1e1ab5e628
curl -Lo $B2D_PKD https://github.com/boot2docker/osx-installer/releases/download/v1.3.0/Boot2Docker-1.3.0.pkg
fi
PACKAGES="DockerCLI Boot2DockerCLI Boot2DockerISO Boot2DockerAPP VBoxKEXTs VBox VBoxCLI"
pkg-reset() {
for var in $PACKAGES; do
eval ${var}=0
done
}
pkg-show() {
echo -n '[ '
for var in $PACKAGES; do
echo -n "${var}:${!var} "
done
echo ']'
}
pkg-choose() {
cat <<USAGE
========================================
choose which package you want to install
1-7: togles the package
q: finish selecting
========================================
USAGE
select pack in $PACKAGES; do
[[ "$REPLY" == "q" || "$REPLY" == "x" || "$REPLY" == "quit" ]] && break
echo togle: $pack
eval ${pack}=$(( 1 - ${!pack} ))
pkg-show
done
}
pkg-create-choice-file() {
cat > /tmp/b2d-single-pack.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>attributeSetting</key>
<integer>${DockerCLI}</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceDockerCLI</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>${Boot2DockerCLI}</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceBoot2DockerCLI</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>${Boot2DockerISO}</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceBoot2DockerISO</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>${Boot2DockerAPP}</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceBoot2DockerAPP</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>${VBoxKEXTs}</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceVBoxKEXTs</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>${VBox}</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceVBox</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>${VBoxCLI}</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceVBoxCLI</string>
</dict>
</array>
</plist>
EOF
}
fix-up() {
echo [INFO] fix boot2docker.iso localtion
cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ 2>/dev/null
# checks which profiles exists
if [ -f ~/.bash_profile ] ; then
PRO_FILE=~/.bash_profile
else
PRO_FILE=~/.profile
fi
# updates profile to use the default virtualenv
cat >>$PRO_FILE <<"ENDOFPROFILE"
# Docker settings
$(boot2docker shellinit)
ENDOFPROFILE
}
pkg-reset
pkg-choose
pkg-create-choice-file
echo [INFO] the installer need sudo rights, please enter you password
sudo installer -package $B2D_PKD -target / -applyChoiceChangesXML /tmp/b2d-single-pack.plist -dumplog
fix-up
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>attributeSetting</key>
<integer>1</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceDockerCLI</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceBoot2DockerCLI</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceBoot2DockerISO</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceBoot2DockerAPP</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceVBoxKEXTs</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceVBox</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choiceVBoxCLI</string>
</dict>
</array>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment