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
39c3051a
Commit
39c3051a
authored
Sep 27, 2013
by
Matthew Hooker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
building but there's an exec error.
parent
d2f9ba0d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
22 deletions
+26
-22
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+12
-0
builder/amazon/chroot/communicator.go
builder/amazon/chroot/communicator.go
+1
-1
builder/amazon/chroot/copy_files.go
builder/amazon/chroot/copy_files.go
+1
-1
builder/amazon/chroot/copy_files_test.go
builder/amazon/chroot/copy_files_test.go
+1
-0
builder/amazon/chroot/step_chroot_provision.go
builder/amazon/chroot/step_chroot_provision.go
+3
-18
builder/amazon/chroot/step_mount_device.go
builder/amazon/chroot/step_mount_device.go
+7
-1
builder/amazon/chroot/step_mount_extra.go
builder/amazon/chroot/step_mount_extra.go
+1
-1
No files found.
builder/amazon/chroot/builder.go
View file @
39c3051a
...
...
@@ -13,6 +13,7 @@ import (
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
"log"
"os/exec"
"runtime"
)
...
...
@@ -160,12 +161,23 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
ec2conn
:=
ec2
.
New
(
auth
,
region
)
wrappedCommand
:=
func
(
command
string
)
*
exec
.
Cmd
{
wrapped
,
err
:=
b
.
config
.
tpl
.
Process
(
b
.
config
.
CommandWrapper
,
&
WrappedCommandTemplate
{
Command
:
command
,
})
if
err
!=
nil
{
ui
.
Error
(
err
.
Error
())
}
return
ShellCommand
(
wrapped
)
}
// Setup the state bag and initial state for the steps
state
:=
new
(
multistep
.
BasicStateBag
)
state
.
Put
(
"config"
,
&
b
.
config
)
state
.
Put
(
"ec2"
,
ec2conn
)
state
.
Put
(
"hook"
,
hook
)
state
.
Put
(
"ui"
,
ui
)
state
.
Put
(
"wrappedCommand"
,
Command
(
wrappedCommand
))
// Build the steps
steps
:=
[]
multistep
.
Step
{
...
...
builder/amazon/chroot/communicator.go
View file @
39c3051a
...
...
@@ -21,7 +21,7 @@ type Command func(string) *exec.Cmd
type
Communicator
struct
{
Chroot
string
ChrootCmd
Command
w
rappedCommand
Command
W
rappedCommand
Command
}
func
(
c
*
Communicator
)
Start
(
cmd
*
packer
.
RemoteCmd
)
error
{
...
...
builder/amazon/chroot/copy_files.go
View file @
39c3051a
...
...
@@ -13,6 +13,6 @@ func ChrootCommand(chroot string, command string) *exec.Cmd {
func
ShellCommand
(
command
string
)
*
exec
.
Cmd
{
cmd
:=
exec
.
Command
(
"/bin/sh"
,
"-c"
,
command
)
log
.
Printf
(
"
Wrapped
Command(%s) -> #%v"
,
command
,
cmd
.
Args
)
log
.
Printf
(
"
Shell
Command(%s) -> #%v"
,
command
,
cmd
.
Args
)
return
cmd
}
builder/amazon/chroot/copy_files_test.go
View file @
39c3051a
package
chroot
import
(
"fmt"
"io/ioutil"
"os"
"testing"
...
...
builder/amazon/chroot/step_chroot_provision.go
View file @
39c3051a
...
...
@@ -4,7 +4,6 @@ import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log"
"os/exec"
)
// StepChrootProvision provisions the instance within a chroot.
...
...
@@ -19,29 +18,15 @@ type WrappedCommandTemplate struct {
func
(
s
*
StepChrootProvision
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
hook
:=
state
.
Get
(
"hook"
)
.
(
packer
.
Hook
)
mountPath
:=
state
.
Get
(
"mount_path"
)
.
(
string
)
config
:=
state
.
Get
(
"config"
)
.
(
*
Config
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
chrootCmd
:=
func
(
command
string
)
*
exec
.
Cmd
{
return
ChrootCommand
(
mountPath
,
command
)
}
wrappedCommand
:=
func
(
command
string
)
*
exec
.
Cmd
{
wrapped
,
err
:=
config
.
tpl
.
Process
(
config
.
CommandWrapper
,
&
WrappedCommandTemplate
{
Command
:
command
,
})
if
err
!=
nil
{
ui
.
Error
(
err
.
Error
())
}
return
ShellCommand
(
wrapped
)
}
state
.
Put
(
"chrootCmd"
,
chrootCmd
)
state
.
Put
(
"wrappedCommand"
,
wrappedCommand
)
wrappedCommand
:=
state
.
Get
(
"wrappedCommand"
)
.
(
Command
)
chrootCmd
:=
state
.
Get
(
"chrootCmd"
)
.
(
Command
)
// Create our communicator
comm
:=
&
Communicator
{
Chroot
:
mountPath
,
ChrootCmd
:
chrootCmd
,
w
rappedCommand
:
wrappedCommand
,
W
rappedCommand
:
wrappedCommand
,
}
// Provision
...
...
builder/amazon/chroot/step_mount_device.go
View file @
39c3051a
...
...
@@ -7,6 +7,7 @@ import (
"github.com/mitchellh/packer/packer"
"log"
"os"
"os/exec"
"path/filepath"
)
...
...
@@ -56,10 +57,15 @@ func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
}
chrootCmd
:=
func
(
command
string
)
*
exec
.
Cmd
{
return
ChrootCommand
(
mountPath
,
command
)
}
state
.
Put
(
"chrootCmd"
,
Command
(
chrootCmd
))
ui
.
Say
(
"Mounting the root device..."
)
stderr
:=
new
(
bytes
.
Buffer
)
mountCommand
:=
fmt
.
Sprintf
(
"mount %s %s"
,
device
,
mountPath
)
wrappedCommand
:=
state
.
Get
(
"wrappedCommand"
)
.
(
*
Command
)
wrappedCommand
:=
state
.
Get
(
"wrappedCommand"
)
.
(
Command
)
cmd
:=
wrappedCommand
(
mountCommand
)
cmd
.
Stderr
=
stderr
if
err
:=
cmd
.
Run
();
err
!=
nil
{
...
...
builder/amazon/chroot/step_mount_extra.go
View file @
39c3051a
...
...
@@ -83,7 +83,7 @@ func (s *StepMountExtra) CleanupFunc(state multistep.StateBag) error {
var
path
string
lastIndex
:=
len
(
s
.
mounts
)
-
1
path
,
s
.
mounts
=
s
.
mounts
[
lastIndex
],
s
.
mounts
[
:
lastIndex
]
unmountCommand
:=
fmt
.
Sprintf
(
"u
n
mount %s"
,
path
)
unmountCommand
:=
fmt
.
Sprintf
(
"umount %s"
,
path
)
stderr
:=
new
(
bytes
.
Buffer
)
cmd
:=
wrappedCommand
(
unmountCommand
)
...
...
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