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
831d5caa
Commit
831d5caa
authored
Sep 27, 2013
by
Matthew Hooker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move wrapper definitions around.
parent
39c3051a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
15 deletions
+12
-15
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+5
-1
builder/amazon/chroot/communicator.go
builder/amazon/chroot/communicator.go
+2
-2
builder/amazon/chroot/step_chroot_provision.go
builder/amazon/chroot/step_chroot_provision.go
+4
-5
builder/amazon/chroot/step_copy_files.go
builder/amazon/chroot/step_copy_files.go
+1
-1
builder/amazon/chroot/step_mount_device.go
builder/amazon/chroot/step_mount_device.go
+0
-6
No files found.
builder/amazon/chroot/builder.go
View file @
831d5caa
...
...
@@ -37,6 +37,10 @@ type Config struct {
tpl
*
packer
.
ConfigTemplate
}
type
wrappedCommandTemplate
struct
{
Command
string
}
type
Builder
struct
{
config
Config
runner
multistep
.
Runner
...
...
@@ -162,7 +166,7 @@ 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
,
&
W
rappedCommandTemplate
{
wrapped
,
err
:=
b
.
config
.
tpl
.
Process
(
b
.
config
.
CommandWrapper
,
&
w
rappedCommandTemplate
{
Command
:
command
,
})
if
err
!=
nil
{
...
...
builder/amazon/chroot/communicator.go
View file @
831d5caa
...
...
@@ -66,7 +66,7 @@ func (c *Communicator) Upload(dst string, r io.Reader) error {
}
defer
os
.
Remove
(
tf
.
Name
())
io
.
Copy
(
tf
,
r
)
cpCmd
:=
fmt
.
Sprintf
(
"cp %s %s"
,
dst
,
tf
.
Name
()
)
cpCmd
:=
fmt
.
Sprintf
(
"cp %s %s"
,
tf
.
Name
(),
dst
)
return
(
*
c
.
ChrootCmd
(
cpCmd
))
.
Run
()
}
...
...
@@ -90,7 +90,7 @@ func (c *Communicator) UploadDir(dst string, src string, exclude []string) error
chrootDest
:=
filepath
.
Join
(
c
.
Chroot
,
dst
,
path
)
log
.
Printf
(
"Uploading to chroot dir: %s"
,
dst
)
cpCmd
:=
fmt
.
Sprintf
(
"cp %s %s"
,
chrootDest
,
fullPath
)
cpCmd
:=
fmt
.
Sprintf
(
"cp %s %s"
,
fullPath
,
chrootDest
)
return
c
.
ChrootCmd
(
cpCmd
)
.
Run
()
}
...
...
builder/amazon/chroot/step_chroot_provision.go
View file @
831d5caa
...
...
@@ -4,6 +4,7 @@ import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log"
"os/exec"
)
// StepChrootProvision provisions the instance within a chroot.
...
...
@@ -11,16 +12,14 @@ type StepChrootProvision struct {
mounts
[]
string
}
type
WrappedCommandTemplate
struct
{
Command
string
}
func
(
s
*
StepChrootProvision
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
hook
:=
state
.
Get
(
"hook"
)
.
(
packer
.
Hook
)
mountPath
:=
state
.
Get
(
"mount_path"
)
.
(
string
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
wrappedCommand
:=
state
.
Get
(
"wrappedCommand"
)
.
(
Command
)
chrootCmd
:=
state
.
Get
(
"chrootCmd"
)
.
(
Command
)
chrootCmd
:=
func
(
command
string
)
*
exec
.
Cmd
{
return
ChrootCommand
(
mountPath
,
command
)
}
// Create our communicator
comm
:=
&
Communicator
{
...
...
builder/amazon/chroot/step_copy_files.go
View file @
831d5caa
...
...
@@ -31,7 +31,7 @@ func (s *StepCopyFiles) Run(state multistep.StateBag) multistep.StepAction {
chrootPath
:=
filepath
.
Join
(
mountPath
,
path
)
log
.
Printf
(
"Copying '%s' to '%s'"
,
path
,
chrootPath
)
cmd
:=
fmt
.
Sprintf
(
"cp %s %s"
,
chrootPath
,
p
ath
)
cmd
:=
fmt
.
Sprintf
(
"cp %s %s"
,
path
,
chrootP
ath
)
if
err
:=
wrappedCommand
(
cmd
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error copying file: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
...
...
builder/amazon/chroot/step_mount_device.go
View file @
831d5caa
...
...
@@ -7,7 +7,6 @@ import (
"github.com/mitchellh/packer/packer"
"log"
"os"
"os/exec"
"path/filepath"
)
...
...
@@ -57,11 +56,6 @@ 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
)
...
...
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