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
f6854ae0
Commit
f6854ae0
authored
Jul 20, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: more flexible ISO removing
/cc @timsutton - This is a bit more flexible.
parent
55c82530
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
builder/vmware/step_clean_vmx.go
builder/vmware/step_clean_vmx.go
+22
-6
No files found.
builder/vmware/step_clean_vmx.go
View file @
f6854ae0
...
...
@@ -7,6 +7,7 @@ import (
"io/ioutil"
"log"
"os"
"regexp"
"strings"
)
...
...
@@ -22,10 +23,12 @@ import (
type
stepCleanVMX
struct
{}
func
(
s
stepCleanVMX
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
isoPath
:=
state
[
"iso_path"
]
.
(
string
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
vmxPath
:=
state
[
"vmx_path"
]
.
(
string
)
ui
.
Say
(
"Cleaning VMX prior to finishing up..."
)
vmxData
,
err
:=
s
.
readVMX
(
vmxPath
)
if
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
"Error reading VMX: %s"
,
err
)
...
...
@@ -34,7 +37,7 @@ func (s stepCleanVMX) Run(state map[string]interface{}) multistep.StepAction {
if
_
,
ok
:=
state
[
"floppy_path"
];
ok
{
// Delete the floppy0 entries so the floppy is no longer mounted
ui
.
Say
(
"Unmounting floppy from VMX..."
)
ui
.
Message
(
"Unmounting floppy from VMX..."
)
for
k
,
_
:=
range
vmxData
{
if
strings
.
HasPrefix
(
k
,
"floppy0."
)
{
log
.
Printf
(
"Deleting key: %s"
,
k
)
...
...
@@ -44,10 +47,23 @@ func (s stepCleanVMX) Run(state map[string]interface{}) multistep.StepAction {
vmxData
[
"floppy0.present"
]
=
"FALSE"
}
// Change the CD-ROM device back to auto-detect, ejecting the iso
ui
.
Say
(
"Detatching ISO from CD-ROM device..."
)
vmxData
[
"ide1:0.fileName"
]
=
"auto detect"
vmxData
[
"ide1:0.deviceType"
]
=
"cdrom-raw"
ui
.
Message
(
"Detatching ISO from CD-ROM device..."
)
devRe
:=
regexp
.
MustCompile
(
`^ide\d:\d\.`
)
for
k
,
_
:=
range
vmxData
{
match
:=
devRe
.
FindString
(
k
)
if
match
==
""
{
continue
}
filenameKey
:=
match
+
".filename"
if
filename
,
ok
:=
vmxData
[
filenameKey
];
ok
{
if
filename
==
isoPath
{
// Change the CD-ROM device back to auto-detect to eject
vmxData
[
filenameKey
]
=
"auto detect"
vmxData
[
match
+
".deviceType"
]
=
"cdrom-raw"
}
}
}
// Rewrite the VMX
if
err
:=
WriteVMX
(
vmxPath
,
vmxData
);
err
!=
nil
{
...
...
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