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
89e07b87
Commit
89e07b87
authored
Jul 07, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-processor/vagrant: properly close file handles [GH-100]
parent
87edf671
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
26 deletions
+27
-26
CHANGELOG.md
CHANGELOG.md
+2
-0
post-processor/vagrant/util.go
post-processor/vagrant/util.go
+21
-0
post-processor/vagrant/virtualbox.go
post-processor/vagrant/virtualbox.go
+2
-13
post-processor/vagrant/vmware.go
post-processor/vagrant/vmware.go
+2
-13
No files found.
CHANGELOG.md
View file @
89e07b87
...
...
@@ -22,6 +22,8 @@ BUG FIXES:
the output path.
*
vagrant: Properly configure the provider-specific post-processors so
things like
`vagrantfile_template`
work. [GH-129]
*
vagrant: Close filehandles when copying files so Windows can
rename files. [GH-100]
## 0.1.4 (July 2, 2013)
...
...
post-processor/vagrant/util.go
View file @
89e07b87
...
...
@@ -21,6 +21,27 @@ type OutputPathTemplate struct {
Provider
string
}
// Copies a file by copying the contents of the file to another place.
func
CopyContents
(
dst
,
src
string
)
error
{
srcF
,
err
:=
os
.
Open
(
src
)
if
err
!=
nil
{
return
err
}
defer
srcF
.
Close
()
dstF
,
err
:=
os
.
Create
(
dst
)
if
err
!=
nil
{
return
err
}
defer
dstF
.
Close
()
if
_
,
err
:=
io
.
Copy
(
dstF
,
srcF
);
err
!=
nil
{
return
err
}
return
nil
}
// DirToBox takes the directory and compresses it into a Vagrant-compatible
// box. This function does not perform checks to verify that dir is
// actually a proper box. This is an expected precondition.
...
...
post-processor/vagrant/virtualbox.go
View file @
89e07b87
...
...
@@ -5,7 +5,6 @@ import (
"fmt"
"github.com/mitchellh/mapstructure"
"github.com/mitchellh/packer/packer"
"io"
"io/ioutil"
"log"
"os"
...
...
@@ -66,19 +65,9 @@ func (p *VBoxBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifac
// Copy all of the original contents into the temporary directory
for
_
,
path
:=
range
artifact
.
Files
()
{
ui
.
Message
(
fmt
.
Sprintf
(
"Copying: %s"
,
path
))
src
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
defer
src
.
Close
()
dst
,
err
:=
os
.
Create
(
filepath
.
Join
(
dir
,
filepath
.
Base
(
path
)))
if
err
!=
nil
{
return
nil
,
false
,
err
}
defer
dst
.
Close
()
if
_
,
err
:=
io
.
Copy
(
dst
,
src
);
err
!=
nil
{
dstPath
:=
filepath
.
Join
(
dir
,
filepath
.
Base
(
path
))
if
err
:=
CopyContents
(
dstPath
,
path
);
err
!=
nil
{
return
nil
,
false
,
err
}
}
...
...
post-processor/vagrant/vmware.go
View file @
89e07b87
...
...
@@ -4,7 +4,6 @@ import (
"fmt"
"github.com/mitchellh/mapstructure"
"github.com/mitchellh/packer/packer"
"io"
"io/ioutil"
"os"
"path/filepath"
...
...
@@ -51,19 +50,9 @@ func (p *VMwareBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artif
// Copy all of the original contents into the temporary directory
for
_
,
path
:=
range
artifact
.
Files
()
{
ui
.
Message
(
fmt
.
Sprintf
(
"Copying: %s"
,
path
))
src
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
defer
src
.
Close
()
dst
,
err
:=
os
.
Create
(
filepath
.
Join
(
dir
,
filepath
.
Base
(
path
)))
if
err
!=
nil
{
return
nil
,
false
,
err
}
defer
dst
.
Close
()
if
_
,
err
:=
io
.
Copy
(
dst
,
src
);
err
!=
nil
{
dstPath
:=
filepath
.
Join
(
dir
,
filepath
.
Base
(
path
))
if
err
:=
CopyContents
(
dstPath
,
path
);
err
!=
nil
{
return
nil
,
false
,
err
}
}
...
...
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