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
b8724487
Commit
b8724487
authored
Aug 15, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: switch to common download step
parent
0d152f54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
93 deletions
+7
-93
builder/vmware/builder.go
builder/vmware/builder.go
+7
-1
builder/vmware/step_download_iso.go
builder/vmware/step_download_iso.go
+0
-92
No files found.
builder/vmware/builder.go
View file @
b8724487
...
...
@@ -298,7 +298,13 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
steps
:=
[]
multistep
.
Step
{
&
stepPrepareTools
{},
&
stepDownloadISO
{},
&
common
.
StepDownload
{
Checksum
:
b
.
config
.
ISOChecksum
,
ChecksumType
:
b
.
config
.
ISOChecksumType
,
Description
:
"ISO"
,
ResultKey
:
"iso_path"
,
Url
:
[]
string
{
b
.
config
.
ISOUrl
},
},
&
stepPrepareOutputDir
{},
&
common
.
StepCreateFloppy
{
Files
:
b
.
config
.
FloppyFiles
,
...
...
builder/vmware/step_download_iso.go
deleted
100644 → 0
View file @
0d152f54
package
vmware
import
(
"encoding/hex"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
"log"
"time"
)
// This step downloads the ISO specified.
//
// Uses:
// cache packer.Cache
// config *config
// ui packer.Ui
//
// Produces:
// iso_path string
type
stepDownloadISO
struct
{}
func
(
s
stepDownloadISO
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
cache
:=
state
[
"cache"
]
.
(
packer
.
Cache
)
config
:=
state
[
"config"
]
.
(
*
config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
checksum
,
err
:=
hex
.
DecodeString
(
config
.
ISOChecksum
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error parsing checksum: %s"
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
log
.
Printf
(
"Acquiring lock to download the ISO."
)
cachePath
:=
cache
.
Lock
(
config
.
ISOUrl
)
defer
cache
.
Unlock
(
config
.
ISOUrl
)
downloadConfig
:=
&
common
.
DownloadConfig
{
Url
:
config
.
ISOUrl
,
TargetPath
:
cachePath
,
CopyFile
:
false
,
Hash
:
common
.
HashForType
(
config
.
ISOChecksumType
),
Checksum
:
checksum
,
}
download
:=
common
.
NewDownloadClient
(
downloadConfig
)
downloadCompleteCh
:=
make
(
chan
error
,
1
)
go
func
()
{
ui
.
Say
(
"Copying or downloading ISO. Progress will be reported periodically."
)
cachePath
,
err
=
download
.
Get
()
downloadCompleteCh
<-
err
}()
progressTicker
:=
time
.
NewTicker
(
5
*
time
.
Second
)
defer
progressTicker
.
Stop
()
DownloadWaitLoop
:
for
{
select
{
case
err
:=
<-
downloadCompleteCh
:
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error downloading ISO: %s"
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
break
DownloadWaitLoop
case
<-
progressTicker
.
C
:
progress
:=
download
.
PercentProgress
()
if
progress
>=
0
{
ui
.
Message
(
fmt
.
Sprintf
(
"Download progress: %d%%"
,
progress
))
}
case
<-
time
.
After
(
1
*
time
.
Second
)
:
if
_
,
ok
:=
state
[
multistep
.
StateCancelled
];
ok
{
ui
.
Say
(
"Interrupt received. Cancelling download..."
)
return
multistep
.
ActionHalt
}
}
}
log
.
Printf
(
"Path to ISO on disk: %s"
,
cachePath
)
state
[
"iso_path"
]
=
cachePath
return
multistep
.
ActionContinue
}
func
(
stepDownloadISO
)
Cleanup
(
map
[
string
]
interface
{})
{}
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