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
15f191de
Commit
15f191de
authored
Jun 23, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: Copy ISO because VirtualBox can't recognize
parent
d52cd1ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
4 deletions
+42
-4
builder/virtualbox/step_download_iso.go
builder/virtualbox/step_download_iso.go
+42
-4
No files found.
builder/virtualbox/step_download_iso.go
View file @
15f191de
...
...
@@ -7,7 +7,11 @@ import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/builder/common"
"github.com/mitchellh/packer/packer"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
"time"
)
...
...
@@ -20,9 +24,11 @@ import (
//
// Produces:
// iso_path string
type
stepDownloadISO
struct
{}
type
stepDownloadISO
struct
{
isoCopyDir
string
}
func
(
s
stepDownloadISO
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
func
(
s
*
stepDownloadISO
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
cache
:=
state
[
"cache"
]
.
(
packer
.
Cache
)
config
:=
state
[
"config"
]
.
(
*
config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
...
...
@@ -81,10 +87,42 @@ DownloadWaitLoop:
}
}
// VirtualBox is really dumb and can't figure out that the file is an
// ISO unless it has a ".iso" extension. We can't modify the cache
// filenames so we just do a copy.
tempdir
,
err
:=
ioutil
.
TempDir
(
""
,
"packer"
)
if
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
"Error copying ISO: %s"
,
err
)
return
multistep
.
ActionHalt
}
s
.
isoCopyDir
=
tempdir
f
,
err
:=
os
.
Create
(
filepath
.
Join
(
tempdir
,
"image.iso"
))
if
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
"Error copying ISO: %s"
,
err
)
return
multistep
.
ActionHalt
}
defer
f
.
Close
()
sourceF
,
err
:=
os
.
Open
(
cachePath
)
if
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
"Error copying ISO: %s"
,
err
)
return
multistep
.
ActionHalt
}
if
_
,
err
:=
io
.
Copy
(
f
,
sourceF
);
err
!=
nil
{
state
[
"error"
]
=
fmt
.
Errorf
(
"Error copying ISO: %s"
,
err
)
return
multistep
.
ActionHalt
}
log
.
Printf
(
"Path to ISO on disk: %s"
,
cachePath
)
state
[
"iso_path"
]
=
cachePath
state
[
"iso_path"
]
=
f
.
Name
()
return
multistep
.
ActionContinue
}
func
(
stepDownloadISO
)
Cleanup
(
map
[
string
]
interface
{})
{}
func
(
s
*
stepDownloadISO
)
Cleanup
(
map
[
string
]
interface
{})
{
if
s
.
isoCopyDir
!=
""
{
os
.
RemoveAll
(
s
.
isoCopyDir
)
}
}
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