File: rules

package info (click to toggle)
wireless-regdb 2020.04.29-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 404 kB
  • sloc: python: 830; makefile: 152; sh: 29
file content (68 lines) | stat: -rwxr-xr-x 2,627 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/make -f

export CRDA_PATH     = /lib/crda
export REGDB_AUTHOR  = $(shell dpkg-parsechangelog -SMaintainer | sed 's:.*<\(.*\)>:\1:')
export V             = 1
# prevent the build system from calling lsb_release
export LSB_ID        = Debian/Ubuntu

define copy_source
test -d .pc
set +e; QUILT_PC=.pc quilt unapplied --quiltrc - >/dev/null && echo 'Patch series not fully applied'; test $$? -eq 1
mkdir -p '$(1)'
cp -a $(filter-out debian .pc .git %.bin %.db %.p7s sha1sum.txt, $(wildcard * .[^.]*)) '$(1)'
endef

%:
	dh ${@}

debian/stamps/configure:
	rm -rf debian/build
	$(call copy_source,debian/build)
	cp debian/regulatory.bin.sig debian/regulatory.db.p7s debian/build/
	mkdir -p debian/stamps
	touch $@

override_dh_auto_configure: debian/stamps/configure

override_dh_auto_build:
	$(MAKE) -C debian/build regulatory.bin regulatory.db
# crda will install public keys
	rm -f debian/build/.custom
# Verify that our binaries match upstream unless db.txt is patched
ifeq ($(shell QUILT_PC=.pc quilt patches --quiltrc - db.txt | wc -l),0)
	diff regulatory.db debian/build/regulatory.db
	size="$$(dd if=regulatory.bin status=none bs=4 skip=2 count=1 | od -td4 --endian=big -An | sed 's/^\s*//')" \
	&& dd if=regulatory.bin status=none iflag=skip_bytes,count_bytes skip=12 count=$$size of=debian/build/regulatory.bin.unsigned-upstream \
	&& dd if=debian/build/regulatory.bin status=none iflag=skip_bytes,count_bytes skip=12 count=$$size of=debian/build/regulatory.bin.unsigned \
	&& diff debian/build/regulatory.bin.unsigned-upstream debian/build/regulatory.bin.unsigned
endif

override_dh_auto_install: install-wireless-regdb install-wireless-regdb-udeb

install-wireless-regdb: DIR = debian/wireless-regdb
install-wireless-regdb:
	$(MAKE) -C debian/build DESTDIR=$(CURDIR)/$(DIR) install
	for file in regulatory.db regulatory.db.p7s; do \
		install -m644 $$file $(DIR)/lib/firmware/$$file-upstream \
		&& mv $(DIR)/lib/firmware/$$file $(DIR)/lib/firmware/$$file-debian \
		|| exit; \
	done
# crda will install public keys
	rm -r $(DIR)/lib/crda/pubkeys

install-wireless-regdb-udeb: DIR = debian/wireless-regdb-udeb
install-wireless-regdb-udeb:
	$(MAKE) -C debian/build DESTDIR=$(CURDIR)/$(DIR) install
	rm -r $(DIR)/lib/crda $(DIR)/usr/share/man
	rmdir --ignore-fail-on-non-empty -p $(DIR)/usr/share

override_dh_auto_clean:
	rm -rf debian/build debian/stamps

sign:
	rm -rf debian/build
	$(call copy_source,debian/build)
	cp debian/certs/$(REGDB_AUTHOR).x509.pem debian/build/
	$(MAKE) -C debian/build regulatory.bin.sig regulatory.db.p7s
	cp debian/build/regulatory.bin.sig debian/build/regulatory.db.p7s debian/