~ubuntu-branches/ubuntu/precise/sysvinit/precise

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#! /usr/bin/make -f
#
#	debian/rules file for sysvinit
#

# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

tmp     = $(shell pwd)/debian/tmp
sysvtmp = $(shell pwd)/debian/sysvinit
utiltmp = $(shell pwd)/debian/sysvinit-utils
rctmp   = $(shell pwd)/debian/sysv-rc
inittmp = $(shell pwd)/debian/initscripts
doc	= /usr/share/doc

LC_ALL	= POSIX

DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
DEB_HOST_ARCH       ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_ARCH_OS    ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
DEB_HOST_MULTIARCH  ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

INSTALL_DATA = install -o root -g root -m 644
INSTALL      = install -o root -g root -m 755

# Handle cross builds
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
CROSS=CC=$(DEB_HOST_GNU_TYPE)-gcc
# CROSS is passed to make, CC is called directly.
CC=$(DEB_HOST_GNU_TYPE)-gcc
endif

# Set arch specific build flags
ifeq ($(DEB_HOST_ARCH_OS),linux)
CONFFLAGS = WITH_SELINUX="yes"
endif

PATCH_STAMP=debian/stamp-patched
patch: $(PATCH_STAMP)
$(PATCH_STAMP):
	dh_testdir debian/patches/series \
		debian/startpar/patches/series
	QUILT_PATCHES=debian/patches quilt --quiltrc /dev/null push -a || test $$? = 2
	cd debian/startpar && \
		QUILT_PATCHES=patches quilt --quiltrc /dev/null push -a || test $$? = 2
	touch $(PATCH_STAMP)

unpatch:
	QUILT_PATCHES=debian/patches quilt --quiltrc /dev/null pop -a -R || test $$? = 2
	cd debian/startpar && \
		QUILT_PATCHES=patches quilt --quiltrc /dev/null pop -a -R || test $$? = 2
	rm -rf .pc debian/startpar/.pc $(PATCH_STAMP)

build: build-stamp
build-stamp: patch
# Builds the binary package.
	dh_testdir
	$(MAKE) $(CROSS) $(CONFFLAGS) -C src DISTRO=Debian LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)
	$(MAKE) $(CROSS) -C debian/startpar
	touch $@

# Make a binary package (.deb file)
binary-arch: DH_OPTIONS=-a
binary-arch: build
	dh_testroot
	dh_prep
	dh_installdirs
	$(MAKE) -C src $(CROSS) ROOT=$(tmp) DISTRO=Debian install
	dh_install
	dh_link
	# Used by sysvinit and sysvinit-utils
	cat debian/copyright.in COPYRIGHT > debian/copyright
	#
	# sysvinit-utils package
	#
	$(MAKE) $(CROSS) -C debian/startpar DESTDIR=$(utiltmp) install
	ln -sf /usr/sbin/service $(utiltmp)/usr/bin
	dh_installchangelogs -psysvinit-utils doc/Changelog
	sed -i -ne '/sysvinit (2.86.ds1-47)/q' -e p \
		$(inittmp)$(doc)/initscripts/changelog.Debian
	#
	# initscripts package
	#
	$(MAKE) -C debian/src/initscripts install DESTDIR=$(inittmp)
ifneq (,$(findstring $(DEB_HOST_ARCH_OS),linux kfreebsd))
	$(INSTALL) -d $(inittmp)/sys
endif
	rm -rf $(inittmp)/lib/init/rw
	ln -s /run $(inittmp)/lib/init/rw
	dh_installchangelogs -pinitscripts
	sed -i -ne '/sysvinit (2.86.ds1-47)/q' -e p \
		$(inittmp)$(doc)/initscripts/changelog.Debian
	dh_installdeb -pinitscripts
	# Override autogenerated conffiles
	$(INSTALL_DATA) debian/initscripts.conffiles \
		$(inittmp)/DEBIAN/conffiles
	sh debian/deps-mount >> debian/initscripts.substvars

	# Wrap it all up
	dh_fixperms -X/etc/init.d/skeleton
	dh_installman
	dh_installdocs
	dh_lintian
	dh_shlibdeps
	dh_strip
	dh_compress
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Architecture independant files.
binary-indep: DH_OPTIONS=-i
binary-indep:
	#
	# sysv-rc package
	#
	dh_testroot
	dh_prep
	$(MAKE) -C debian/src/sysv-rc install DESTDIR=$(rctmp)
	dh_installchangelogs
	sed -i -ne '/sysvinit (2.86.ds1-47)/q' -e p \
		$(rctmp)$(doc)/sysv-rc/changelog.Debian
	dh_installdeb
	# Neither rc, rcS nor README are conffiles
	$(RM) $(rctmp)/DEBIAN/conffiles

	# Wrap it all up
	dh_fixperms -X/etc/init.d/README
	dh_installdebconf
	dh_installdocs
	dh_installman
	dh_lintian
	dh_compress
	dh_gencontrol
	dh_md5sums
	dh_builddeb

clean:
	dh_testdir
	$(MAKE) -C src clobber
	$(MAKE) -C debian/startpar clean
	$(MAKE) -f debian/rules unpatch
	dh_clean build-stamp debian/copyright

binary: binary-arch binary-indep

.PHONY: binary binary-arch binary-indep clean