Add bindep support

Adds make targets bindep and .bindep (install bindep into a venv)

Change-Id: Ie497d917e9149e56d8a1ed2570896b8b812da283
This commit is contained in:
Dean Troyer 2016-12-21 07:17:30 -06:00
parent d38d3def62
commit 9b52de086d
3 changed files with 59 additions and 7 deletions

View File

@ -7,19 +7,24 @@
GIT_HOST = git.openstack.org
PWD := $(shell pwd)
TOP_DIR := $(shell basename $(PWD))
export GOPATH := $(PWD)-gopath
DEST := $(GOPATH)/src/$(GIT_HOST)/openstack/$(TOP_DIR).git
BASE_DIR := $(shell basename $(PWD))
# Keep an existing GOPATH, make a private one if it is undefined
GOPATH_DEFAULT := $(PWD)/.go
export GOPATH ?= $(GOPATH_DEFAULT)
DEST := $(GOPATH)/src/$(GIT_HOST)/openstack/$(BASE_DIR).git
env:
@echo "PWD: $(PWD)"
@echo "TOP_DIR: $(TOP_DIR)"
@echo "BASE_DIR: $(BASE_DIR)"
@echo "GOPATH: $(GOPATH)"
@echo "DEST: $(DEST)"
work: $(GOPATH)
work: $(GOPATH) $(DEST)
$(GOPATH):
mkdir -p $(GOPATH)
$(DEST): $(GOPATH)
mkdir -p $(shell dirname $(DEST))
ln -s $(PWD) $(DEST)
@ -29,8 +34,8 @@ get: work
test: get
cd $(DEST); go test -tags=unit ./...
fmt:
cd $(DEST); go fmt ./...
fmt: work
cd $(DEST) && go fmt ./...
cover:
@echo "$@ not yet implemented"
@ -43,3 +48,21 @@ relnotes:
translation:
@echo "$@ not yet implemented"
.bindep:
virtualenv .bindep
.bindep/bin/pip install bindep
bindep: .bindep
@.bindep/bin/bindep -b -f bindep.txt || true
install-distro-packages:
tools/install-distro-packages.sh
clean:
rm -rf .bindep
if [ "$(GOPATH)" = "$(GOPATH_DEFAULT)" ]; then \
rm -rf $(GOPATH); \
fi
.PHONY: bindep clean

5
bindep.txt Normal file
View File

@ -0,0 +1,5 @@
pkg-config
build-essential
golang-go
golint
make

View File

@ -0,0 +1,24 @@
#!/bin/bash -xe
# Local version to install bindep packages
# Suitable for use for development
function is_fedora {
[ -f /usr/bin/yum ] && cat /etc/*release | grep -q -e "Fedora"
}
PACKAGES=$(make bindep || true)
# inspired from project-config install-distro-packages.sh
if apt-get -v >/dev/null 2>&1 ; then
sudo apt-get -qq update
sudo PATH=/usr/sbin:/sbin:$PATH DEBIAN_FRONTEND=noninteractive \
apt-get -q --option "Dpkg::Options::=--force-confold" \
--assume-yes install $PACKAGES
elif emerge --version >/dev/null 2>&1 ; then
sudo emerge -uDNq --jobs=4 @world
sudo PATH=/usr/sbin:/sbin:$PATH emerge -q --jobs=4 $PACKAGES
else
is_fedora && YUM=dnf || YUM=yum
sudo PATH=/usr/sbin:/sbin:$PATH $YUM install -y $PACKAGES
fi