Clear an environment variable passed through pdebuild

406 Views Asked by At

I'm using pdebuild to test my package on older versions of Ubuntu. However an environment variable, GOROOT is leaking through to the build from my environment.

debian/tmp/usr/lib/gocode/src/code.brandscreen.net/cortex/go/util/http.go:4:2: cannot find package "io" in any of:
    /home/mjoiner/src/go/src/pkg/io (from $GOROOT)
    /tmp/buildd/golang-brandscreen-0.0/debian/tmp/usr/lib/gocode/src/io (from $GOPATH)
    /usr/lib/gocode/src/io

How do I clear this (and other environment variables) when calling pdebuild?

2

There are 2 best solutions below

0
On

Normally, pdebuild runs pbuilder via sudo, so the easiest thing to do is to let sudo clear the environment for you. The general recommendation from a few different places, including the Debian pbuilder tricks page, is to use:

Defaults        env_reset,env_keep="DIST ARCH DEB_* BUILD* PATH"

in your sudo configuration so that you can still pass in a few of the environment variables that control pbuilder operations or are used by debhelper.

0
On

Does putting

GOROOT=""

or

unset GOROOT

in ~/.pbuilderrc have any effect?