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
1c34e355
Commit
1c34e355
authored
Jul 30, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/chroot: mount the root device
parent
ec526d97
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+1
-0
builder/amazon/chroot/step_mount_device.go
builder/amazon/chroot/step_mount_device.go
+71
-0
No files found.
builder/amazon/chroot/builder.go
View file @
1c34e355
...
...
@@ -96,6 +96,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
StepSourceAMIInfo
{},
&
StepCreateVolume
{},
&
StepAttachVolume
{},
&
StepMountDevice
{},
}
// Run!
...
...
builder/amazon/chroot/step_mount_device.go
0 → 100644
View file @
1c34e355
package
chroot
import
(
"bytes"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log"
"os"
"os/exec"
)
// StepMountDevice mounts the attached device.
//
// Produces:
// mount_path string - The location where the volume was mounted.
type
StepMountDevice
struct
{
mountPath
string
}
func
(
s
*
StepMountDevice
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
Config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
device
:=
state
[
"device"
]
.
(
string
)
mountPath
:=
config
.
MountPath
log
.
Printf
(
"Mount path: %s"
,
mountPath
)
if
err
:=
os
.
MkdirAll
(
mountPath
,
0755
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error creating mount directory: %s"
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
ui
.
Say
(
"Mounting the root device..."
)
stderr
:=
new
(
bytes
.
Buffer
)
cmd
:=
exec
.
Command
(
"mount"
,
device
,
mountPath
)
cmd
.
Stderr
=
stderr
if
err
:=
cmd
.
Run
();
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error mounting root volume: %s
\n
Stderr: %s"
,
err
,
stderr
.
String
())
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
return
multistep
.
ActionContinue
}
func
(
s
*
StepMountDevice
)
Cleanup
(
state
map
[
string
]
interface
{})
{
if
s
.
mountPath
==
""
{
return
}
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
.
Say
(
"Unmounting the root device..."
)
path
,
err
:=
exec
.
LookPath
(
"umount"
)
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error umounting root device: %s"
,
err
))
return
}
cmd
:=
exec
.
Command
(
path
,
s
.
mountPath
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error unmounting root device: %s"
,
err
))
return
}
}
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