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
0b63f4f9
Commit
0b63f4f9
authored
May 06, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1132 from rasa/1123-use-local-vboxguestadditions-iso
virtualbox: use local VBoxGuestAdditions.iso by default
parents
34834057
7736151a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
15 deletions
+67
-15
builder/virtualbox/common/driver.go
builder/virtualbox/common/driver.go
+3
-0
builder/virtualbox/common/driver_4_2.go
builder/virtualbox/common/driver_4_2.go
+29
-0
builder/virtualbox/common/driver_mock.go
builder/virtualbox/common/driver_mock.go
+8
-0
builder/virtualbox/common/step_download_guest_additions.go
builder/virtualbox/common/step_download_guest_additions.go
+24
-13
website/source/docs/builders/virtualbox-iso.html.markdown
website/source/docs/builders/virtualbox-iso.html.markdown
+3
-2
No files found.
builder/virtualbox/common/driver.go
View file @
0b63f4f9
...
...
@@ -25,6 +25,9 @@ type Driver interface {
// Import a VM
Import
(
string
,
string
,
string
)
error
// The complete path to the Guest Additions ISO
Iso
()
(
string
,
error
)
// Checks if the VM with the given name is running.
IsRunning
(
string
)
(
bool
,
error
)
...
...
builder/virtualbox/common/driver_4_2.go
View file @
0b63f4f9
...
...
@@ -40,6 +40,35 @@ func (d *VBox42Driver) Delete(name string) error {
return
d
.
VBoxManage
(
"unregistervm"
,
name
,
"--delete"
)
}
func
(
d
*
VBox42Driver
)
Iso
()
(
string
,
error
)
{
var
stdout
bytes
.
Buffer
cmd
:=
exec
.
Command
(
d
.
VBoxManagePath
,
"list"
,
"systemproperties"
)
cmd
.
Stdout
=
&
stdout
if
err
:=
cmd
.
Run
();
err
!=
nil
{
return
""
,
err
}
DefaultGuestAdditionsRe
:=
regexp
.
MustCompile
(
"Default Guest Additions ISO:(.*)"
)
for
_
,
line
:=
range
strings
.
Split
(
stdout
.
String
(),
"
\n
"
)
{
// Need to trim off CR character when running in windows
line
=
strings
.
TrimRight
(
line
,
"
\r
"
)
matches
:=
DefaultGuestAdditionsRe
.
FindStringSubmatch
(
line
)
if
matches
==
nil
{
continue
}
isoname
:=
strings
.
Trim
(
matches
[
1
],
"
\r\n
"
)
log
.
Printf
(
"Found Default Guest Additions ISO: %s"
,
isoname
)
return
isoname
,
nil
}
return
""
,
fmt
.
Errorf
(
"Cannot find
\"
Default Guest Additions ISO
\"
in vboxmanage output"
)
}
func
(
d
*
VBox42Driver
)
Import
(
name
,
path
,
opts
string
)
error
{
args
:=
[]
string
{
"import"
,
path
,
...
...
builder/virtualbox/common/driver_mock.go
View file @
0b63f4f9
...
...
@@ -19,6 +19,9 @@ type DriverMock struct {
ImportOpts
string
ImportErr
error
IsoCalled
bool
IsoErr
error
IsRunningName
string
IsRunningReturn
bool
IsRunningErr
error
...
...
@@ -60,6 +63,11 @@ func (d *DriverMock) Import(name, path, opts string) error {
return
d
.
ImportErr
}
func
(
d
*
DriverMock
)
Iso
()
(
string
,
error
)
{
d
.
IsoCalled
=
true
return
""
,
d
.
IsoErr
}
func
(
d
*
DriverMock
)
IsRunning
(
name
string
)
(
bool
,
error
)
{
d
.
Lock
()
defer
d
.
Unlock
()
...
...
builder/virtualbox/common/step_download_guest_additions.go
View file @
0b63f4f9
...
...
@@ -62,14 +62,7 @@ func (s *StepDownloadGuestAdditions) Run(state multistep.StateBag) multistep.Ste
// Use provided version or get it from virtualbox.org
var
checksum
string
if
s
.
GuestAdditionsSHA256
!=
""
{
checksum
=
s
.
GuestAdditionsSHA256
}
else
{
checksum
,
action
=
s
.
downloadAdditionsSHA256
(
state
,
version
,
additionsName
)
if
action
!=
multistep
.
ActionContinue
{
return
action
}
}
checksumType
:=
"sha256"
// Use the provided source (URL or file path) or generate it
url
:=
s
.
GuestAdditionsURL
...
...
@@ -86,10 +79,28 @@ func (s *StepDownloadGuestAdditions) Run(state multistep.StateBag) multistep.Ste
return
multistep
.
ActionHalt
}
}
else
{
url
=
fmt
.
Sprintf
(
"http://download.virtualbox.org/virtualbox/%s/%s"
,
version
,
additionsName
)
url
,
err
=
driver
.
Iso
()
if
err
==
nil
{
checksumType
=
"none"
}
else
{
ui
.
Error
(
err
.
Error
())
url
=
fmt
.
Sprintf
(
"http://download.virtualbox.org/virtualbox/%s/%s"
,
version
,
additionsName
)
}
}
if
checksumType
!=
"none"
{
if
s
.
GuestAdditionsSHA256
!=
""
{
checksum
=
s
.
GuestAdditionsSHA256
}
else
{
checksum
,
action
=
s
.
downloadAdditionsSHA256
(
state
,
version
,
additionsName
)
if
action
!=
multistep
.
ActionContinue
{
return
action
}
}
}
url
,
err
=
common
.
DownloadableURL
(
url
)
...
...
@@ -104,7 +115,7 @@ func (s *StepDownloadGuestAdditions) Run(state multistep.StateBag) multistep.Ste
downStep
:=
&
common
.
StepDownload
{
Checksum
:
checksum
,
ChecksumType
:
"sha256"
,
ChecksumType
:
checksumType
,
Description
:
"Guest additions"
,
ResultKey
:
"guest_additions_path"
,
Url
:
[]
string
{
url
},
...
...
website/source/docs/builders/virtualbox-iso.html.markdown
View file @
0b63f4f9
...
...
@@ -121,8 +121,9 @@ each category, the available options are alphabetized and described.
*
`guest_additions_url`
(string) - The URL to the guest additions ISO
to upload. This can also be a file URL if the ISO is at a local path.
By default the VirtualBox builder will go and download the proper
guest additions ISO from the internet.
By default, the VirtualBox builder will attempt to find the guest additions
ISO on the local file system. If it is not available locally, the builder
will download the proper guest additions ISO from the internet.
*
`guest_os_type`
(string) - The guest OS type being installed. By default
this is "other", but you can get _dramatic_ performance improvements by
...
...
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