From b37c171676533c3ff30e624e0da8b3b5b4f3f7b5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 19 Jun 2013 22:20:52 -0700 Subject: [PATCH] Begin work on the dist.sh script to create the distribution --- dist.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ packer/version.go | 20 +++++++++++++++++--- 2 files changed, 60 insertions(+), 3 deletions(-) create mode 100755 dist.sh diff --git a/dist.sh b/dist.sh new file mode 100755 index 000000000..b29c54fde --- /dev/null +++ b/dist.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -e + +# Get the directory where this script is. This will also resolve +# any symlinks in the directory/script, so it will be the fully +# resolved path. +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + +# Determine the version that we're building based on the contents +# of packer/version.go. +VERSION=$(grep "const Version " packer/version.go | sed -E 's/.*"(.+)"$/\1/') +PREVERSION=$(grep "const VersionPrerelease " packer/version.go | sed -E 's/.*"(.+)"$/\1/') +if [ ! -z $PREVERSION ]; then + PREVERSION="${PREVERSION}.$(date -u +%s)" +fi + +echo "Version: ${VERSION} ${PREVERSION}" + +# This function builds whatever directory we're in... +xc() { + goxc \ + -arch="386 amd64 arm" \ + -os="linux darwin windows freebsd openbsd" \ + -d="${DIR}/pkg" \ + -pv="${VERSION}" \ + -pr="${PREVERSION}" \ + go-install \ + xc +} + +# Build our root project +xc + +# Build all the plugins +for PLUGIN in $(find ./plugin -mindepth 1 -maxdepth 1 -type d); do + PLUGIN_NAME=$(basename ${PLUGIN}) + pushd ${PLUGIN} + xc + popd + find ./pkg -type f -name ${PLUGIN_NAME} -execdir mv ${PLUGIN_NAME} packer-${PLUGIN_NAME} ';' +done diff --git a/packer/version.go b/packer/version.go index 70aeabef8..a0b365d28 100644 --- a/packer/version.go +++ b/packer/version.go @@ -1,9 +1,17 @@ package packer -import "fmt" +import ( + "bytes" + "fmt" +) // The version of packer. -const Version = "0.1.0.dev" +const Version = "0.1.0" + +// Any pre-release marker for the version. If this is "" (empty string), +// then it means that it is a final release. Otherwise, this is the +// pre-release marker. +const VersionPrerelease = "dev" type versionCommand byte @@ -15,7 +23,13 @@ command-line flags for this command.` } func (versionCommand) Run(env Environment, args []string) int { - env.Ui().Say(fmt.Sprintf("Packer v%v", Version)) + var versionString bytes.Buffer + fmt.Fprintf(&versionString, "Packer v%s", Version) + if VersionPrerelease != "" { + fmt.Fprintf(&versionString, ".%s", VersionPrerelease) + } + + env.Ui().Say(versionString.String()) return 0 }