Commit 69f96aa3 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Begin work on the dist.sh script to create the distribution

parent 70c4753f
#!/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
package packer package packer
import "fmt" import (
"bytes"
"fmt"
)
// The version of packer. // 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 type versionCommand byte
...@@ -15,7 +23,13 @@ command-line flags for this command.` ...@@ -15,7 +23,13 @@ command-line flags for this command.`
} }
func (versionCommand) Run(env Environment, args []string) int { 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 return 0
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment