Don't enable xds-agent service during install
[src/xds/xds-agent.git] / conf.d / packaging / deb / debian.rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3 # Uncomment this to turn on verbose mode.
4 export DH_VERBOSE=1
5
6 # These are used for cross-compiling and for saving the configure script
7 # from having to guess our platform (since we know it already)
8 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
9 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
10
11
12 CFLAGS = -Wall -g
13
14 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
15        CFLAGS += -O0
16 else
17        CFLAGS += -O2
18 endif
19 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
20        INSTALL_PROGRAM += -s
21 endif
22
23 configure: configure-stamp
24 configure-stamp:
25         dh_testdir
26         #
27         touch configure-stamp
28
29 build: build-stamp
30 build-stamp: configure-stamp
31         dh_testdir
32         touch build-stamp
33
34 clean:
35         #dh_testdir
36         dh_testroot
37         rm -f configure-stamp build-stamp
38         [ ! -f Makefile ] || $(MAKE) distclean
39         #dh_clean
40
41
42 NAME=agl-xds-agent
43 INSTALL_XDS_DIR=/opt/AGL/xds/agent
44 INSTALL_BIN_DIR=/opt/AGL/bin
45
46 DEB_BASE_DIR=debian/$(NAME)
47 DEB_INSTALL_XDS_DIR=$(DEB_BASE_DIR)/$(INSTALL_XDS_DIR)
48 DEB_INSTALL_BIN_DIR=$(DEB_BASE_DIR)/$(INSTALL_BIN_DIR)
49
50 install: build
51         dh_testdir
52         dh_testroot
53         dh_prep
54         dh_installdirs
55         # Add here commands to install the package into debian/tmp
56         mkdir -p $(DEB_INSTALL_XDS_DIR) $(DEB_INSTALL_BIN_DIR)
57         find . -maxdepth 1 ! -name debian -exec cp -r {} $(DEB_INSTALL_XDS_DIR) \;
58         rm -fr $(DEB_INSTALL_XDS_DIR)/debian $(DEB_INSTALL_XDS_DIR)/*-stamp
59         cd $(DEB_INSTALL_BIN_DIR) && ln -s ../xds/agent/xds-agent
60         # Install service files
61         mkdir -p $(DEB_BASE_DIR)/usr/lib/systemd/user
62         cp $(DEB_INSTALL_XDS_DIR)/conf.d/usr/lib/systemd/user/xds-agent.service $(DEB_BASE_DIR)/usr/lib/systemd/user
63         mkdir -p $(DEB_BASE_DIR)/etc/default $(DEB_BASE_DIR)/etc/xds/agent
64         cp $(DEB_INSTALL_XDS_DIR)/conf.d/etc/default/xds-agent $(DEB_BASE_DIR)/etc/default/
65         cp $(DEB_INSTALL_XDS_DIR)/conf.d/etc/xds/agent/* $(DEB_BASE_DIR)/etc/xds/agent/
66
67         # Add XDS in user's PATH
68         mkdir -p $(DEB_BASE_DIR)/etc/profile.d
69         sed -e "s;@XDS_INSTALL_BIN_DIR@;$(INSTALL_BIN_DIR);g" $(DEB_INSTALL_XDS_DIR)/conf.d/etc/profile.d/xds-agent.sh > $(DEB_BASE_DIR)/etc/profile.d/$(NAME).sh
70
71         # Cleanup
72         rm -rf $(DEB_INSTALL_XDS_DIR)/conf.d
73
74         # Move all files in their corresponding package
75         dh_install --list-missing -s --sourcedir=debian/tmp
76
77 postinst: install
78         if [ -f "/etc/xds-agent/config.json" ]; then
79                 install -b -S .rpmsave /etc/xds-agent/config.json /etc/xds/agent/agent-config.json
80         fi
81
82 prerm:
83         rm -f /etc/xds-agent/*.rpm*
84
85 # Build architecture-independent files here.
86 binary-indep: build install
87 # We have nothing to do by default.
88
89 # Build architecture-dependent files here.
90 binary-arch: build install
91         dh_testdir
92         dh_testroot
93         dh_installchangelogs
94         dh_installdocs
95         dh_installexamples
96         dh_installman
97         dh_link
98         dh_strip
99         dh_compress
100         dh_fixperms
101         dh_makeshlibs -V
102         dh_installdeb
103         #dh_shlibdeps
104         dh_gencontrol
105         dh_md5sums
106         dh_builddeb
107
108 binary: binary-indep binary-arch
109 .PHONY: build clean binary-indep binary-arch binary install