Skip to content

Commit

Permalink
Use Make GVPROXY_PATH to locate gvproxy
Browse files Browse the repository at this point in the history
Presented as an alternative to PR #11449

Rather than do backflips in the code to locate `gvproxy`, use a
build-time variable to set the location.  That variable can default to
`/usr/libexec` but other build packages (_e.g._ Homebrew) can set it to
something of their liking.

I'll take no offense if the consensus is that we do not want to pollute
the build, but we should likely add a runtime configuration parameter as an
alternative in that case.

Fixes: #11226

Signed-off-by: Jonathan Springer <[email protected]>
  • Loading branch information
jonpspri committed Sep 9, 2021
1 parent 32eaf34 commit 5170c5c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ETCDIR ?= ${PREFIX}/etc
TMPFILESDIR ?= ${PREFIX}/lib/tmpfiles.d
SYSTEMDDIR ?= ${PREFIX}/lib/systemd/system
USERSYSTEMDDIR ?= ${PREFIX}/lib/systemd/user
GVPROXY_PATH ?= /usr/libexec/gvproxy
REMOTETAGS ?= remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp
BUILDTAGS ?= \
$(shell hack/apparmor_tag.sh) \
Expand Down Expand Up @@ -90,11 +91,13 @@ else
BUILD_INFO ?= $(shell date "+$(DATE_FMT)")
ISODATE ?= $(shell date --iso-8601)
endif
LIBPOD := ${PROJECT}/v3/libpod
MODULE ?= $(shell grep -m1 ^module go.mod | cut -d\ -f2)
LIBPOD := ${MODULE}/libpod
GOFLAGS ?= -trimpath
LDFLAGS_PODMAN ?= \
-X $(LIBPOD)/define.gitCommit=$(GIT_COMMIT) \
-X $(LIBPOD)/define.buildInfo=$(BUILD_INFO) \
-X $(MODULE)/pkg/machine.ForwarderBinaryPath=$(GVPROXY_PATH) \
-X $(LIBPOD)/config._installPrefix=$(PREFIX) \
-X $(LIBPOD)/config._etcDir=$(ETCDIR) \
$(EXTRA_LDFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion pkg/machine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
ErrVMAlreadyExists = errors.New("VM already exists")
ErrVMAlreadyRunning = errors.New("VM already running")
ErrMultipleActiveVM = errors.New("only one VM can be active at a time")
ForwarderBinaryName = "gvproxy"
ForwarderBinaryPath string // Populated by Makefile
)

type Download struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/machine/qemu/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,10 @@ func CheckActiveVM() (bool, string, error) {
// startHostNetworking runs a binary on the host system that allows users
// to setup port forwarding to the podman virtual machine
func (v *MachineVM) startHostNetworking() error {
// TODO we may wish to configure the directory in containers common
binary := filepath.Join("/usr/libexec/podman/", machine.ForwarderBinaryName)

binary := machine.ForwarderBinaryPath
if _, err := os.Stat(binary); err != nil {
fmt.Println("Failed to find " + binary + ". Perhaps build using `make GVPROXY+PATH=...`")
return err
}

Expand Down

0 comments on commit 5170c5c

Please sign in to comment.