From 9b52de086df4b7570861cf4b0babe8415e5b1dce Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Wed, 21 Dec 2016 07:17:30 -0600 Subject: [PATCH] Add bindep support Adds make targets bindep and .bindep (install bindep into a venv) Change-Id: Ie497d917e9149e56d8a1ed2570896b8b812da283 --- Makefile | 37 ++++++++++++++++++++++++++------ bindep.txt | 5 +++++ tools/install-distro-packages.sh | 24 +++++++++++++++++++++ 3 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 bindep.txt create mode 100755 tools/install-distro-packages.sh diff --git a/Makefile b/Makefile index c38edf2..2191219 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 0000000..5e3550e --- /dev/null +++ b/bindep.txt @@ -0,0 +1,5 @@ +pkg-config +build-essential +golang-go +golint +make diff --git a/tools/install-distro-packages.sh b/tools/install-distro-packages.sh new file mode 100755 index 0000000..c5801a3 --- /dev/null +++ b/tools/install-distro-packages.sh @@ -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