From f070e9ec5b1ff2b9786946b6065853a2c95fe525 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Fri, 7 Mar 2014 23:34:09 -0300 Subject: [PATCH] Scaffold the new structure for building base boxes --- boxes/Makefile | 15 ++++++++++++ boxes/common/download.sh | 5 ++++ boxes/common/package.sh | 7 ++++++ boxes/common/prepare-vagrant-user.sh | 6 +++++ boxes/debian/clean.sh | 6 +++++ boxes/debian/install-extras.sh | 6 +++++ boxes/mk-ubuntu.sh | 36 ++++++++++++++++++++++++++++ 7 files changed, 81 insertions(+) create mode 100644 boxes/Makefile create mode 100755 boxes/common/download.sh create mode 100755 boxes/common/package.sh create mode 100755 boxes/common/prepare-vagrant-user.sh create mode 100755 boxes/debian/clean.sh create mode 100755 boxes/debian/install-extras.sh create mode 100755 boxes/mk-ubuntu.sh diff --git a/boxes/Makefile b/boxes/Makefile new file mode 100644 index 0000000..1193a58 --- /dev/null +++ b/boxes/Makefile @@ -0,0 +1,15 @@ +UBUNTU_BOXES= precise quantal raring saucy trusty +TODAY=$(shell date -u +"%Y-%m-%d") + +default: + +all: $(UBUNTU_BOXES) + +$(UBUNTU_BOXES): CONTAINER = "vagrant-lxc-base-${@}-amd64-${TODAY}" +$(UBUNTU_BOXES): PACKAGE = "output/$(CONTAINER).box" +$(UBUNTU_BOXES): + @sudo -E ./mk-ubuntu.sh $(@) amd64 $(CONTAINER) $(PACKAGE) + +clean: + @echo "Implement clean" + @exit 1 diff --git a/boxes/common/download.sh b/boxes/common/download.sh new file mode 100755 index 0000000..21cda38 --- /dev/null +++ b/boxes/common/download.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +echo " Will check if the '${CONTAINER}' exists and error if doesnt" +echo " Will create '${CONTAINER}'" diff --git a/boxes/common/package.sh b/boxes/common/package.sh new file mode 100755 index 0000000..7b75286 --- /dev/null +++ b/boxes/common/package.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +container_name=$1 +package=$2 + +echo " Will package '${container_name}' as '${package}'" diff --git a/boxes/common/prepare-vagrant-user.sh b/boxes/common/prepare-vagrant-user.sh new file mode 100755 index 0000000..c728668 --- /dev/null +++ b/boxes/common/prepare-vagrant-user.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +container_name=$1 + +echo " Will prepare the vagrant user on '${container_name}'" diff --git a/boxes/debian/clean.sh b/boxes/debian/clean.sh new file mode 100755 index 0000000..1197c50 --- /dev/null +++ b/boxes/debian/clean.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +container_name=$1 + +echo " Will cleanup '${container_name}'" diff --git a/boxes/debian/install-extras.sh b/boxes/debian/install-extras.sh new file mode 100755 index 0000000..0d97847 --- /dev/null +++ b/boxes/debian/install-extras.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +container_name=$1 + +echo " Will install extras for '${container_name}'" diff --git a/boxes/mk-ubuntu.sh b/boxes/mk-ubuntu.sh new file mode 100755 index 0000000..62d07a7 --- /dev/null +++ b/boxes/mk-ubuntu.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -e + +if [ "$(id -u)" != "0" ]; then + echo "You should run this script as root (sudo)." + exit 1 +fi + +export NO_COLOR='\033[0m' +export OK_COLOR='\033[32;01m' +export ERROR_COLOR='\033[31;01m' +export WARN_COLOR='\033[33;01m' + +export DISTRIBUTION="ubuntu" +export RELEASE=$1 +export ARCH=$2 +export CONTAINER=$3 +export PACKAGE=$4 + +if [ -f ${PACKAGE} ]; then + echo -e "${WARN_COLOR}==> The box '${PACKAGE}' already exists, skipping...${NO_COLOR}" + echo + exit +fi + +echo -e "${OK_COLOR}==> Building '${RELEASE} (${ARCH})' to '${PACKAGE}'...${NO_COLOR}" + +./common/download.sh ubuntu ${RELEASE} ${ARCH} ${CONTAINER} +./common/prepare-vagrant-user.sh ${CONTAINER} +./debian/install-extras.sh ${CONTAINER} +./debian/clean.sh ${CONTAINER} +./common/package.sh ${CONTAINER} ${PACKAGE} +touch $PACKAGE + +echo -e "${OK_COLOR}==> Finished building '${RELEASE} (${ARCH})' to '${PACKAGE}'...${NO_COLOR}" +echo