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
|
# Install prefix
PREFIX ?= /usr
CRDA_PATH ?= $(PREFIX)/lib/crda
CRDA_KEY_PATH ?= $(CRDA_PATH)/pubkeys
FIRMWARE_PATH ?= /lib/firmware
MANDIR ?= $(PREFIX)/share/man/
SHA1SUM ?= /usr/bin/sha1sum
LSB_RELEASE ?= /usr/bin/lsb_release
WHOAMI ?= /usr/bin/whoami
# Distro name: Ubuntu, Debian, Fedora, if not present you get
# "custom-distro", if your distribution does not have the LSB stuff,
# then set this variable when calling make if you don't want "custom-distro"
LSB_ID ?= $(shell if [ -f $(LSB_RELEASE) ]; then \
$(LSB_RELEASE) -i -s; \
else \
echo custom-distro; \
fi)
DISTRO_PRIVKEY ?= ~/.wireless-regdb-$(LSB_ID).key.priv.pem
DISTRO_PUBKEY ?= ~/.wireless-regdb-$(LSB_ID).key.priv.pem
REGDB_AUTHOR ?= $(shell if [ -f $(DISTRO_PRIVKEY) ]; then \
echo $(LSB_ID) ; \
elif [ -f $(WHOAMI) ]; then \
$(WHOAMI); \
else \
echo custom-user; \
fi)
REGDB_PRIVKEY ?= $(HOME)/.wireless-regdb-$(REGDB_AUTHOR).key.priv.pem
REGDB_PUBKEY ?= $(REGDB_AUTHOR).key.pub.pem
REGDB_PUBCERT ?= $(REGDB_AUTHOR).x509.pem
REGDB_UPSTREAM_PUBKEY ?= wens.key.pub.pem
REGDB_CHANGED = $(shell $(SHA1SUM) -c --status sha1sum.txt >/dev/null 2>&1; \
if [ $$? -ne 0 ]; then \
echo maintainer-clean $(REGDB_PUBKEY) $(REGDB_PUBCERT); \
fi)
.PHONY: all clean mrproper install maintainer-clean install-distro-key
all: $(REGDB_CHANGED) regulatory.bin sha1sum.txt regulatory.db.p7s
clean:
@rm -f *.pyc *.gz
maintainer-clean: clean
@rm -f regulatory.bin regulatory.db regulatory.db.p7s
mrproper: clean maintainer-clean
@echo Removed public key, regulatory.bin, regulatory.db* and compressed man pages
@rm -f $(REGDB_PUBKEY) $(REGDB_PUBCERT) .custom
regulatory.bin: db.txt $(REGDB_PRIVKEY) $(REGDB_PUBKEY)
@echo Generating $@ digitally signed by $(REGDB_AUTHOR)...
./db2bin.py regulatory.bin db.txt $(REGDB_PRIVKEY)
regulatory.db: db.txt db2fw.py
@echo "Generating $@"
./db2fw.py regulatory.db db.txt
regulatory.db.p7s: regulatory.db $(REGDB_PRIVKEY) $(REGDB_PUBCERT)
@echo "Signing regulatory.db (by $(REGDB_AUTHOR))..."
@openssl smime -sign \
-signer $(REGDB_PUBCERT) \
-inkey $(REGDB_PRIVKEY) \
-in $< -nosmimecap -binary \
-noattr \
-outform DER -out $@
sha1sum.txt: db.txt
sha1sum $< > $@
$(REGDB_PUBKEY): $(REGDB_PRIVKEY)
@echo "Generating public key for $(REGDB_AUTHOR)..."
openssl rsa -in $(REGDB_PRIVKEY) -out $(REGDB_PUBKEY) -pubout -outform PEM
$(REGDB_PUBCERT): $(REGDB_PRIVKEY)
@echo "Generating certificate for $(REGDB_AUTHOR)..."
./gen-pubcert.sh $(REGDB_PRIVKEY) $(REGDB_PUBCERT) $(REGDB_AUTHOR)
@echo $(REGDB_PUBKEY) > .custom
$(REGDB_PRIVKEY):
ifeq ($(MAKECMDGOALS),$(REGDB_PRIVKEY))
@echo "Generating private key for $(REGDB_AUTHOR)..."
openssl genrsa -out $(REGDB_PRIVKEY) 2048
else
@echo "No private key found. To generate a private key, run:"
@echo " make ~/.wireless-regdb-<author-id>.key.priv.pem"
@echo "Your author-id is currently \"$(REGDB_AUTHOR)\"; set REGDB_AUTHOR to override this."
@exit 1
endif
ifneq ($(shell test -e $(DISTRO_PRIVKEY) && echo yes),yes)
$(DISTRO_PRIVKEY):
@echo "Generating private key for $(LSB_ID) packager..."
openssl genrsa -out $(DISTRO_PRIVKEY) 2048
endif
install-distro-key: maintainer-clean $(DISTRO_PRIVKEY)
%.gz: %
gzip < $< > $@
# Users should just do:
# sudo make install
#
# Developers should do:
# make maintainer-clean
# make
# sudo make install
#
# Distributions packagers should do only once:
# make install-distro-key
# This will create a private key for you and install it into
# ~/.wireless-regdb-$(LSB_ID).key.priv.pem
# To make new releaes just do:
# make maintainer-clean
# make
# sudo make install
install: regulatory.bin.5.gz regulatory.db.5.gz
install -m 755 -d $(DESTDIR)/$(CRDA_PATH)
install -m 755 -d $(DESTDIR)/$(CRDA_KEY_PATH)
install -m 755 -d $(DESTDIR)/$(FIRMWARE_PATH)
if [ -f .custom ]; then \
install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(shell cat .custom); \
fi
install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(REGDB_UPSTREAM_PUBKEY)
install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.bin
install -m 644 -t $(DESTDIR)/$(FIRMWARE_PATH) regulatory.db regulatory.db.p7s
install -m 755 -d $(DESTDIR)/$(MANDIR)/man5/
install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.bin.5.gz regulatory.db.5.gz
|