Add makefile, run tests during package build
Change-Id: Ia3c65b34ba31aa1d4fea10e6ef7971b7c12fc851
This commit is contained in:
parent
82b446bfc4
commit
1eedfdf13e
|
@ -0,0 +1,26 @@
|
||||||
|
DESTDIR=/
|
||||||
|
SALTENVDIR=/usr/share/salt-formulas/env
|
||||||
|
RECLASSDIR=/usr/share/salt-formulas/reclass
|
||||||
|
FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-]*')
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo "make install - Install into DESTDIR"
|
||||||
|
@echo "make test - Run tests"
|
||||||
|
@echo "make clean - Cleanup after tests run"
|
||||||
|
|
||||||
|
install:
|
||||||
|
# Formula
|
||||||
|
[ -d $(DESTDIR)/$(SALTENVDIR) ] || mkdir -p $(DESTDIR)/$(SALTENVDIR)
|
||||||
|
cp -a $(FORMULANAME) $(DESTDIR)/$(SALTENVDIR)/
|
||||||
|
[ ! -d _modules ] || cp -a _modules $(DESTDIR)/$(SALTENVDIR)/
|
||||||
|
[ ! -d _states ] || cp -a _states $(DESTDIR)/$(SALTENVDIR)/ || true
|
||||||
|
# Metadata
|
||||||
|
[ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
|
||||||
|
cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
|
||||||
|
|
||||||
|
test:
|
||||||
|
[ ! -d tests ] || (cd tests; ./run_tests.sh)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
[ ! -d tests/build ] || rm -rf tests/build
|
||||||
|
[ ! -d build ] || rm -rf build
|
|
@ -2,7 +2,7 @@ Source: salt-formula-ceilometer
|
||||||
Maintainer: Jakub Pavlik <jakub.pavlik@tcpcloud.eu>
|
Maintainer: Jakub Pavlik <jakub.pavlik@tcpcloud.eu>
|
||||||
Section: admin
|
Section: admin
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Build-Depends: debhelper (>= 9)
|
Build-Depends: salt-master, python, python-yaml, debhelper (>= 9)
|
||||||
Standards-Version: 3.9.6
|
Standards-Version: 3.9.6
|
||||||
Homepage: https://wiki.openstack.org/wiki/OpenStackSalt
|
Homepage: https://wiki.openstack.org/wiki/OpenStackSalt
|
||||||
Vcs-Browser: https://github.com/openstack/salt-formula-ceilometer
|
Vcs-Browser: https://github.com/openstack/salt-formula-ceilometer
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
ceilometer/* /usr/share/salt-formulas/env/ceilometer/
|
|
||||||
metadata/service/* /usr/share/salt-formulas/reclass/service/ceilometer/
|
|
|
@ -0,0 +1 @@
|
||||||
|
python-yaml
|
|
@ -69,6 +69,7 @@ file_roots:
|
||||||
base:
|
base:
|
||||||
- ${SALT_FILE_DIR}
|
- ${SALT_FILE_DIR}
|
||||||
- ${CURDIR}/..
|
- ${CURDIR}/..
|
||||||
|
- /usr/share/salt-formulas/env
|
||||||
|
|
||||||
pillar_roots:
|
pillar_roots:
|
||||||
base:
|
base:
|
||||||
|
@ -78,16 +79,17 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch_dependency() {
|
fetch_dependency() {
|
||||||
dep_root="${DEPSDIR}/$(basename $1 .git)"
|
dep_name="$(echo $1|cut -d : -f 1)"
|
||||||
|
dep_source="$(echo $1|cut -d : -f 2-)"
|
||||||
|
dep_root="${DEPSDIR}/$(basename $dep_source .git)"
|
||||||
dep_metadata="${dep_root}/metadata.yml"
|
dep_metadata="${dep_root}/metadata.yml"
|
||||||
|
|
||||||
[ -d $dep_root ] && log_info "Dependency $1 already fetched" && return 0
|
[ -d /usr/share/salt-formulas/env/${dep_name} ] && log_info "Dependency $dep_name already present in system-wide salt env" && return 0
|
||||||
|
[ -d $dep_root ] && log_info "Dependency $dep_name already fetched" && return 0
|
||||||
|
|
||||||
log_info "Fetching dependency $1"
|
log_info "Fetching dependency $dep_name"
|
||||||
[ ! -d ${DEPSDIR} ] && mkdir -p ${DEPSDIR}
|
[ ! -d ${DEPSDIR} ] && mkdir -p ${DEPSDIR}
|
||||||
git clone $1 ${DEPSDIR}/$(basename $1 .git)
|
git clone $dep_source ${DEPSDIR}/$(basename $dep_source .git)
|
||||||
|
|
||||||
dep_name=$(cat $dep_metadata | python -c "import sys,yaml; print yaml.load(sys.stdin)['name']")
|
|
||||||
ln -s ${dep_root}/${dep_name} ${SALT_FILE_DIR}/${dep_name}
|
ln -s ${dep_root}/${dep_name} ${SALT_FILE_DIR}/${dep_name}
|
||||||
|
|
||||||
METADATA="${dep_metadata}" install_dependencies
|
METADATA="${dep_metadata}" install_dependencies
|
||||||
|
@ -98,7 +100,7 @@ install_dependencies() {
|
||||||
(python - | while read dep; do fetch_dependency "$dep"; done) << EOF
|
(python - | while read dep; do fetch_dependency "$dep"; done) << EOF
|
||||||
import sys,yaml
|
import sys,yaml
|
||||||
for dep in yaml.load(open('${METADATA}', 'ro'))['dependencies']:
|
for dep in yaml.load(open('${METADATA}', 'ro'))['dependencies']:
|
||||||
print dep["source"]
|
print '%s:%s' % (dep["name"], dep["source"])
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,14 +110,14 @@ clean() {
|
||||||
}
|
}
|
||||||
|
|
||||||
salt_run() {
|
salt_run() {
|
||||||
source ${VENV_DIR}/bin/activate
|
[ -e ${VEN_DIR}/bin/activate ] && source ${VENV_DIR}/bin/activate
|
||||||
salt-call ${SALT_OPTS} $*
|
salt-call ${SALT_OPTS} $*
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
[ -d ${BUILDDIR} ] && mkdir -p ${BUILDDIR}
|
[ -d ${BUILDDIR} ] && mkdir -p ${BUILDDIR}
|
||||||
|
|
||||||
setup_virtualenv
|
which salt-call || setup_virtualenv
|
||||||
setup_pillar
|
setup_pillar
|
||||||
setup_salt
|
setup_salt
|
||||||
install_dependencies
|
install_dependencies
|
||||||
|
|
Loading…
Reference in New Issue