mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-27 10:14:01 -04:00
Determine current user without CGO.
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -122,12 +121,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if p.config.User == "" {
|
if p.config.User == "" {
|
||||||
u, err := user.Current()
|
p.config.User = os.Getenv("USER")
|
||||||
if err != nil {
|
}
|
||||||
errs = packer.MultiErrorAppend(errs, err)
|
if p.config.User == "" {
|
||||||
} else {
|
errs = packer.MultiErrorAppend(errs, fmt.Errorf("user: could not determine current user from environment."))
|
||||||
p.config.User = u.Username
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if errs != nil && len(errs.Errors) > 0 {
|
if errs != nil && len(errs.Errors) > 0 {
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ mkdir -p bin/
|
|||||||
echo "==> Building..."
|
echo "==> Building..."
|
||||||
set +e
|
set +e
|
||||||
gox \
|
gox \
|
||||||
-cgo \
|
|
||||||
-os="${XC_OS}" \
|
-os="${XC_OS}" \
|
||||||
-arch="${XC_ARCH}" \
|
-arch="${XC_ARCH}" \
|
||||||
-ldflags "-X main.GitCommit ${GIT_COMMIT}${GIT_DIRTY}" \
|
-ldflags "-X main.GitCommit ${GIT_COMMIT}${GIT_DIRTY}" \
|
||||||
|
|||||||
Reference in New Issue
Block a user