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
f6f9cca7
Commit
f6f9cca7
authored
Jun 09, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2189 from mitchellh/b-download-extension
common: StepDownload can force an extension
parents
b31534d5
9ea34d4e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
builder/virtualbox/iso/builder.go
builder/virtualbox/iso/builder.go
+1
-0
common/step_download.go
common/step_download.go
+19
-2
No files found.
builder/virtualbox/iso/builder.go
View file @
f6f9cca7
...
...
@@ -230,6 +230,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Description
:
"ISO"
,
ResultKey
:
"iso_path"
,
Url
:
b
.
config
.
ISOUrls
,
Extension
:
"iso"
,
},
&
vboxcommon
.
StepOutputDir
{
Force
:
b
.
config
.
PackerForce
,
...
...
common/step_download.go
View file @
f6f9cca7
package
common
import
(
"crypto/sha1"
"encoding/hex"
"fmt"
"log"
...
...
@@ -36,6 +37,12 @@ type StepDownload struct {
// A list of URLs to attempt to download this thing.
Url
[]
string
// Extension is the extension to force for the file that is downloaded.
// Some systems require a certain extension. If this isn't set, the
// extension on the URL is used. Otherwise, this will be forced
// on the downloaded file for every URL.
Extension
string
}
func
(
s
*
StepDownload
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
...
...
@@ -60,9 +67,19 @@ func (s *StepDownload) Run(state multistep.StateBag) multistep.StepAction {
targetPath
:=
s
.
TargetPath
if
targetPath
==
""
{
// Determine a cache key. This is normally just the URL but
// if we force a certain extension we hash the URL and add
// the extension to force it.
cacheKey
:=
url
if
s
.
Extension
!=
""
{
hash
:=
sha1
.
Sum
([]
byte
(
url
))
cacheKey
=
fmt
.
Sprintf
(
"%s.%s"
,
hex
.
EncodeToString
(
hash
[
:
]),
s
.
Extension
)
}
log
.
Printf
(
"Acquiring lock to download: %s"
,
url
)
targetPath
=
cache
.
Lock
(
url
)
defer
cache
.
Unlock
(
url
)
targetPath
=
cache
.
Lock
(
cacheKey
)
defer
cache
.
Unlock
(
cacheKey
)
}
config
:=
&
DownloadConfig
{
...
...
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