Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
8516e03e
Commit
8516e03e
authored
Nov 18, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scripts: update to use gox
parent
7e5a5eee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
42 deletions
+84
-42
scripts/compile.sh
scripts/compile.sh
+52
-0
scripts/devcompile.sh
scripts/devcompile.sh
+25
-0
scripts/dist.sh
scripts/dist.sh
+7
-42
No files found.
scripts/
build
.sh
→
scripts/
compile
.sh
View file @
8516e03e
#!/bin/bash
#
# This script only builds the application from source.
# This script compiles Packer for various platforms (specified by the
# PACKER_OS and PACKER_ARCH environmental variables).
set
-e
NO_COLOR
=
"
\x
1b[0m"
...
...
@@ -20,82 +21,32 @@ cd $DIR
GIT_COMMIT
=
$(
git rev-parse HEAD
)
GIT_DIRTY
=
$(
test
-n
"
`
git status
--porcelain
`
"
&&
echo
"+CHANGES"
||
true
)
# If we're building on Windows, specify an extension
EXTENSION
=
""
if
[
"
$(
go
env
GOOS
)
"
=
"windows"
]
;
then
EXTENSION
=
".exe"
fi
# Determine the arch/os combos we're building for
XC_ARCH
=
${
XC_ARCH
:-
"386 amd64 arm"
}
XC_OS
=
${
XC_OS
:-
linux
darwin windows freebsd openbsd
}
# Make sure that if we're killed, we kill all our subprocseses
trap
"kill 0"
SIGINT SIGTERM EXIT
# If we're building a race-enabled build, then set that up.
if
[
!
-z
$PACKER_RACE
]
;
then
echo
-e
"
${
OK_COLOR
}
--> Building with race detection enabled
${
NO_COLOR
}
"
PACKER_RACE
=
"-race"
fi
echo
-e
"
${
OK_COLOR
}
--> Installing dependencies to speed up builds...
${
NO_COLOR
}
"
echo
-e
"
${
OK_COLOR
}
==> Installing dependencies to speed up builds...
${
NO_COLOR
}
"
go get ./...
# This function waits for all background tasks to complete
waitAll
()
{
RESULT
=
0
for
job
in
`
jobs
-p
`
;
do
wait
$job
if
[
$?
-ne
0
]
;
then
RESULT
=
1
fi
done
if
[
$RESULT
-ne
0
]
;
then
exit
$RESULT
fi
}
waitSingle
()
{
if
[
!
-z
$PACKER_NO_BUILD_PARALLEL
]
;
then
waitAll
fi
}
if
[
-z
$PACKER_NO_BUILD_PARALLEL
]
;
then
echo
-e
"
${
OK_COLOR
}
--> NOTE: Compilation of components "
\
"will be done in parallel.
${
NO_COLOR
}
"
fi
# Compile the main Packer app
echo
-e
"
${
OK_COLOR
}
--> Compiling Packer
${
NO_COLOR
}
"
(
go build
\
${
PACKER_RACE
}
\
echo
-e
"
${
OK_COLOR
}
==> Beginning compile...
${
NO_COLOR
}
"
rm
-rf
pkg/
gox
\
-os
=
"
${
XC_OS
}
"
\
-arch
=
"
${
XC_ARCH
}
"
\
-ldflags
"-X github.com/mitchellh/packer/packer.GitCommit
${
GIT_COMMIT
}${
GIT_DIRTY
}
"
\
-v
\
-o
bin/packer
${
EXTENSION
}
.
cp
bin/packer
${
EXTENSION
}
${
GOPATH
}
/bin
)
&
waitSingle
# Go over each plugin and build it
for
PLUGIN
in
$(
find ./plugin
-mindepth
1
-maxdepth
1
-type
d
)
;
do
PLUGIN_NAME
=
$(
basename
${
PLUGIN
}
)
echo
-e
"
${
OK_COLOR
}
--> Compiling Plugin:
${
PLUGIN_NAME
}${
NO_COLOR
}
"
(
go build
\
${
PACKER_RACE
}
\
-ldflags
"-X github.com/mitchellh/packer/packer.GitCommit
${
GIT_COMMIT
}${
GIT_DIRTY
}
"
\
-v
\
-o
bin/packer-
${
PLUGIN_NAME
}${
EXTENSION
}
${
PLUGIN
}
cp
bin/packer-
${
PLUGIN_NAME
}${
EXTENSION
}
${
GOPATH
}
/bin
)
&
waitSingle
-output
"pkg/{{.OS}}_{{.Arch}}/packer-{{.Dir}}"
\
./...
# Make sure "packer-packer" is renamed properly
for
PLATFORM
in
$(
find ./pkg
-mindepth
1
-maxdepth
1
-type
d
)
;
do
set
+e
mv
${
PLATFORM
}
/packer-packer
${
PLATFORM
}
/packer 2>/dev/null
mv
${
PLATFORM
}
/packer-packer.exe
${
PLATFORM
}
/packer.exe 2>/dev/null
set
-e
done
waitAll
# Reset signal trapping to avoid "Terminated: 15" at the end
trap
- SIGINT SIGTERM EXIT
scripts/devcompile.sh
0 → 100755
View file @
8516e03e
#!/bin/bash
#
# This script only builds the application from source.
set
-e
NO_COLOR
=
"
\x
1b[0m"
OK_COLOR
=
"
\x
1b[32;01m"
ERROR_COLOR
=
"
\x
1b[31;01m"
WARN_COLOR
=
"
\x
1b[33;01m"
# Get the parent directory of where this script is.
SOURCE
=
"
${
BASH_SOURCE
[0]
}
"
while
[
-h
"
$SOURCE
"
]
;
do
SOURCE
=
"
$(
readlink
"
$SOURCE
"
)
"
;
done
DIR
=
"
$(
cd
-P
"
$(
dirname
"
$SOURCE
"
)
/.."
&&
pwd
)
"
# Change into that directory
cd
$DIR
# Compile the thing
export
XC_ARCH
=
$(
go
env
GOARCH
)
export
XC_OS
=
$(
go
env
GOOS
)
./scripts/compile.sh
# Move all the compiled things to the PATH
cp
pkg/
${
XC_OS
}
_
${
XC_ARCH
}
/
*
${
GOPATH
}
/bin
scripts/dist.sh
View file @
8516e03e
...
...
@@ -19,28 +19,6 @@ if [ ! -z $PREVERSION ]; then
VERSIONDIR
=
"
${
VERSIONDIR
}
-
${
PREVERSION
}
"
fi
echo
"Version:
${
VERSION
}
${
PREVERSION
}
"
# Determine the arch/os combos we're building for
XC_ARCH
=
${
XC_ARCH
:-
"386 amd64 arm"
}
XC_OS
=
${
XC_OS
:-
linux
darwin windows freebsd openbsd
}
echo
"Arch:
${
XC_ARCH
}
"
echo
"OS:
${
XC_OS
}
"
# This function builds whatever directory we're in...
xc
()
{
goxc
\
-arch
=
"
$XC_ARCH
"
\
-os
=
"
$XC_OS
"
\
-d
=
"
${
DIR
}
/pkg"
\
-pv
=
"
${
VERSION
}
"
\
-pr
=
"
${
PREVERSION
}
"
\
$XC_OPTS
\
go-install
\
xc
}
# This function waits for all background tasks to complete
waitAll
()
{
RESULT
=
0
...
...
@@ -56,28 +34,15 @@ waitAll() {
fi
}
# Compile the main project
./scripts/compile.sh
# Make sure that if we're killed, we kill all our subprocseses
trap
"kill 0"
SIGINT SIGTERM EXIT
# 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
}
)
find ./pkg
\
-type
f
\
-name
${
PLUGIN_NAME
}
\
-execdir
mv
${
PLUGIN_NAME
}
packer-
${
PLUGIN_NAME
}
';'
find ./pkg
\
-type
f
\
-name
${
PLUGIN_NAME
}
.exe
\
-execdir
mv
${
PLUGIN_NAME
}
.exe packer-
${
PLUGIN_NAME
}
.exe
';'
done
# Zip all the packages
mkdir
-p
./pkg/
${
VERSIONDIR
}
/
dist
for
PLATFORM
in
$(
find ./pkg
/
${
VERSIONDIR
}
-mindepth
1
-maxdepth
1
-type
d
)
;
do
mkdir
-p
./pkg/dist
for
PLATFORM
in
$(
find ./pkg
-mindepth
1
-maxdepth
1
-type
d
)
;
do
PLATFORM_NAME
=
$(
basename
${
PLATFORM
}
)
ARCHIVE_NAME
=
"
${
VERSIONDIR
}
_
${
PLATFORM_NAME
}
"
...
...
@@ -87,7 +52,7 @@ for PLATFORM in $(find ./pkg/${VERSIONDIR} -mindepth 1 -maxdepth 1 -type d); do
(
pushd
${
PLATFORM
}
zip
${
DIR
}
/pkg/
${
VERSIONDIR
}
/
dist/
${
ARCHIVE_NAME
}
.zip ./
*
zip
${
DIR
}
/pkg/dist/
${
ARCHIVE_NAME
}
.zip ./
*
popd
)
&
done
...
...
@@ -95,7 +60,7 @@ done
waitAll
# Make the checksums
pushd
./pkg/
${
VERSIONDIR
}
/
dist
pushd
./pkg/dist
shasum
-a256
*
>
./
${
VERSIONDIR
}
_SHA256SUMS
popd
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment