bd5b793c86a676f7ec5b0171c849dd093138d386
[openstack-build/cinder-build.git] / trusty / debian / rules
1 #!/usr/bin/make -f
2
3 include /usr/share/openstack-pkg-tools/pkgos.make
4 export OSLO_PACKAGE_VERSION=$(shell dpkg-parsechangelog | grep Version: | cut -d' ' -f2 | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//' -e 's/~/.0/' | head -n 1)
5
6 export DH_VERBOSE=1
7
8 %:
9         dh $@ --buildsystem=python_distutils --with python2,systemd,sphinxdoc
10
11 override_dh_auto_test:
12 ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
13         @echo "===> Running tests"
14         set -e ; set -x ; for i in 2.7 ; do \
15                 PYMAJOR=`echo $$i | cut -d'.' -f1` ; \
16                 echo "===> Testing with python$$i (python$$PYMAJOR)" ; \
17                 rm -rf .testrepository ; \
18                 testr-python$$PYMAJOR init ; \
19                 TEMP_REZ=`mktemp -t` ; \
20                 PYTHONPATH=$(CURDIR) PYTHON=python$$i testr-python$$PYMAJOR run --subunit | tee $$TEMP_REZ | subunit2pyunit ; \
21                 cat $$TEMP_REZ | subunit-filter -s --no-passthrough | subunit-stats ; \
22                 rm -f $$TEMP_REZ ; \
23                 testr-python$$PYMAJOR slowest ; \
24         done
25 endif
26
27 override_dh_clean:
28         dh_clean -O--buildsystem=python_distutils
29         rm -f debian/cinder-common.config debian/cinder-common.postinst debian/cinder-api.config debian/cinder-api.postinst debian/cinder-volume.postinst
30         rm -rf debian/*.upstart debian/*.service
31
32 override_dh_install:
33         dh_install --fail-missing -Xbin/cinder-all
34         install -D -m 0440 debian/cinder-common.sudoers $(CURDIR)/debian/cinder-common/etc/sudoers.d/cinder-common
35
36         mkdir -p $(CURDIR)/debian/cinder-common/usr/share/cinder-common
37         $(CURDIR)/tools/config/generate_sample.sh from_tox
38 #       PYTHONPATH=. oslo-config-generator --output-file $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf \
39 #               --wrap-width 80 \
40 #               --namespace cinder \
41 #               --namespace keystonemiddleware.auth_token \
42 #               --namespace oslo.config \
43 #               --namespace oslo.concurrency \
44 #               --namespace oslo.context \
45 #               --namespace oslo.db \
46 #               --namespace oslo.i18n \
47 #               --namespace oslo.log \
48 #               --namespace oslo.messaging \
49 #               --namespace oslo.middleware \
50 #               --namespace oslo.policy \
51 #               --namespace oslo.reports \
52 #               --namespace oslo.rootwrap \
53 #               --namespace oslo.serialization \
54 #               --namespace oslo.service \
55 #               --namespace oslo.utils \
56 #               --namespace oslo.versionedobjects \
57 #               --namespace oslo.vmware
58         # The generator is currently missing enabled_backend and the [lvm]
59         # section. This script fixes it until upstream gets smarter.
60 #       chmod +x debian/gen-fixed-config
61 #       ./debian/gen-fixed-config
62         cp etc/cinder/cinder.conf.sample $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
63
64         # Set LVM as default backend
65         sed -i 's/^[ \t#]*enabled_backends[ \t]*=.*/enabled_backends = lvm/' $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
66         echo "[lvm]"                            >> $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
67         echo "volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver" >> $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
68         echo "volume_group = pkgosvg0"          >> $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
69         echo "iscsi_protocol = iscsi"           >> $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
70         echo "iscsi_helper = tgtadm"            >> $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
71
72         # Set a default value for lock_path
73         sed -i 's|^[ \t#]*lock_path[ \t]*=.*|lock_path = /var/lock/cinder|' $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
74
75         # Disable https in default setup, as this makes our CI fail
76         sed -i 's/^[ \t#]*auth_protocol[ \t]*=.*/auth_protocol = http/' $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
77
78         # Default to keystone auth
79         sed -i "s/#auth_strategy=noauth/auth_strategy=keystone/" $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
80
81         # Write only in /var/lib/cinder please
82         sed -i 's|#[ \t#]*state_path[ \t]*=.*|state_path=/var/lib/cinder|' $(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
83
84         # Fix the missing sql_connection directive
85         #echo "# Connection to db:" >>$(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
86         #echo "sql_connection = sqlite:////var/lib/cinder/cinderdb" >>$(CURDIR)/debian/cinder-common/usr/share/cinder-common/cinder.conf
87
88         install -D -m 0644 $(CURDIR)/etc/cinder/logging_sample.conf $(CURDIR)/debian/cinder-common/usr/share/cinder-common/logging.conf
89
90 override_dh_fixperms:
91         dh_fixperms -Xcinder_tgt.conf
92         chmod 0440 $(CURDIR)/debian/cinder-common/etc/sudoers.d/cinder-common
93
94 override_dh_auto_build:
95         dh_auto_build -O--buildsystem=python_distutils
96
97         /usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func cinder-common.config
98         /usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func cinder-common.postinst
99         /usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func cinder-api.config
100         /usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func cinder-api.postinst
101         /usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func cinder-volume.postinst
102
103 override_dh_sphinxdoc:
104 ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
105         python setup.py build_sphinx
106         cp -rf doc/build/html $(CURDIR)/debian/cinder-doc/usr/share/doc/cinder-doc
107         dh_sphinxdoc -O--buildsystem=python_distutils
108 endif