Search Linux Wireless

[PATCH 4/4] wireless-regdb: make distribution packaging easier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This implements the ideas suggested by Paul Wise (slighly modified).

This should make packaging wireless-regdb easier for
distributions, as well as developer wishing to help
enhace the regulatory database.

You will see a key.pub.pem --> linvile.pub.pem, the files
are the same, not sure why "-M" won't listen, maybe because
its binary. This allows you to now cp linvile.key.priv.pem to:

~/.wireless-regdb-linville.key.priv.pem

And then symlink it as:

~/.wireless-regdb-Fedora.key.priv.pem

when you want to use a Fedora release, just an idea.

Users should just do:
     sudo make install

Developers should do:
     make maintainer-clean
     make
This will create a private key for you and install it into
~/.wireless-regdb-$(REGDB_AUTHOR).key.priv.pem
     sudo make install

Distributions packagers should do only once:
     make install-distro-key
This will create a private key for the distribution package and install it into
~/.wireless-regdb-$(LSB_ID).key.priv.pem
To make new releaes just do:
     make maintainer-clean
     make
     sudo make install

The make install target now also puts both the upstream key to

/usr/lib/crda/pubkeys/

Distributions now build regulatory.bin but also trust your key,
and their pubkey will also be putinto the same pubkeys dir. Same
will happen for developers sending patches.

Cc: Paul Wise <pabs@xxxxxxxxxx>
Signed-off-by: Luis R. Rodriguez <lrodriguez@xxxxxxxxxxx>
---
 Makefile                            |  106 +++++++++++++++++++++++++++++-----
 key.pub.pem => linville.key.pub.pem |    0
 regulatory.bin                      |  Bin 3080 -> 3088 bytes
 sha1sum.txt                         |    1 +
 4 files changed, 91 insertions(+), 16 deletions(-)
 rename key.pub.pem => linville.key.pub.pem (100%)
 create mode 100644 sha1sum.txt

diff --git a/Makefile b/Makefile
index 203152a..376311d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,38 +1,112 @@
 # Install prefix
-PREFIX = /usr
+PREFIX ?= /usr
 CRDA_PATH ?= $(PREFIX)/lib/crda
+CRDA_KEY_PATH ?= $(CRDA_PATH)/pubkeys
 
 MANDIR ?= $(PREFIX)/share/man/
 
+SHA1SUM ?= /usr/bin/sha1sum
+LSB_RELEASE ?= /usr/bin/lsb_release
+WHOAMI ?= /usr/bin/whoami
 
-.PHONY: all clean install maintainer-clean
+# 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)
 
-all: regulatory.bin key.pub.pem
+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 ?= ~/.wireless-regdb-$(REGDB_AUTHOR).key.priv.pem
+REGDB_PUBKEY ?= $(REGDB_AUTHOR).key.pub.pem
+
+REGDB_UPSTREAM_PUBKEY ?= linville.key.pub.pem
+
+REGDB_CHANGED = $(shell $(SHA1SUM) -c --status sha1sum.txt; \
+        if [ $$? -eq 0 ]; then \
+                echo ; \
+        else \
+                echo maintainer-clean $(REGDB_PUBKEY); \
+        fi)
+
+.PHONY: all clean mrproper install maintainer-clean install-distro-key
+
+all: $(REGDB_CHANGED) regulatory.bin
 
 clean:
-	rm -f *.pyc *.gz
+	@rm -f *.pyc *.gz
 
 maintainer-clean: clean
-	rm -f regulatory.bin key.pub.pem
+	@rm -f regulatory.bin
 
-ifneq ($(wildcard key.priv.pem),)
-regulatory.bin: db.txt key.priv.pem
-	./db2bin.py regulatory.bin db.txt key.priv.pem
+mrproper: clean maintainer-clean
+	@echo Removed public key, regulatory.bin and compresed man pages
+	@rm -f $(REGDB_PUBKEY) .custom
 
-key.pub.pem: key.priv.pem
-	openssl rsa -in key.priv.pem -out key.pub.pem -pubout -outform PEM
+regulatory.bin: db.txt $(REGDB_PRIVKEY) $(REGDB_PUBKEY)
+	@echo Generating $@ digitally signed by $(REGDB_AUTHOR)...
+	./db2bin.py regulatory.bin db.txt $(REGDB_PRIVKEY)
+
+$(REGDB_PUBKEY): $(REGDB_PRIVKEY)
+	@echo "Generating public key for $(REGDB_AUTHOR)..."
+	openssl rsa -in $(REGDB_PRIVKEY) -out $(REGDB_PUBKEY) -pubout -outform PEM
+	@echo $(REGDB_PUBKEY) > .custom
+
+
+$(REGDB_PRIVKEY):
+	@echo "Generating private key for $(REGDB_AUTHOR)..."
+	openssl genrsa -out $(REGDB_PRIVKEY) 2048
+
+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
 
-key.priv.pem:
-	openssl genrsa -out key.priv.pem 2048
+install-distro-key: maintainer-clean $(DISTRO_PRIVKEY)
 
 %.gz: %
 	gzip < $< > $@
 
-# Distributions wishing to just use John's database
-# can just call make install.
+# 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
 	install -m 755 -d $(DESTDIR)/$(CRDA_PATH)
-	install -m 644 regulatory.bin $(DESTDIR)/$(CRDA_PATH)/regulatory.bin
-	mkdir -p $(DESTDIR)/$(MANDIR)/man5/
+	install -m 755 -d $(DESTDIR)/$(CRDA_KEY_PATH)
+	if [ -f .custom ]; then \
+		install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(shell cat .custom); \
+	fi
+	@# In linville we trust
+	install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(REGDB_UPSTREAM_PUBKEY)
+	install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.bin
+	install -m 755 -d $(DESTDIR)/$(MANDIR)/man5/
 	install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.bin.5.gz
+
+uninstall:
+	rm -rf $(DESTDIR)/$(CRDA_PATH)/
diff --git a/key.pub.pem b/linville.key.pub.pem
similarity index 100%
rename from key.pub.pem
rename to linville.key.pub.pem
diff --git a/regulatory.bin b/regulatory.bin
index 49c6e4f3ce8f828c177b75a2c304e9b4a5548ba9..05a7147589daef2c700f3c9f01d5e7a1e21a789f 100644
GIT binary patch
literal 3088
zcmZ`&YiyHM7(QJu-$cMAV4MgMOouaEtYN|kP3&!K-P-c8c3U@Ugai{D3oc~gl3+3r
zkRSpY&`$wf3}VHqBU#8GQ<n(If(zM?fh1eFISAq+3jvv7UY_?o=agdfByZp6Jm-0D
z=X|X$4+Vq}lY}tZ;MWLYgQI2iNk49v^!a1bKiVn1kq_-`AzX*0Cq3=yoIJ&m*KzrO
z3ipvdQFO@^;-F8&el~^q6k>qMFHJ~3e%cgu)7!JW*;(+gJ~sV<9yqH9uG^9n_4%W$
z&tmY|x*B)-SX1;yTJ{6JsJlSSoahk(xboL_QMIs7h-V8JN8I4iCvjD8jW8eSZWfXI
zxC3YiM~^}eO?2X35q+_ZdG{wm6kWp|(7gLS56}B)GxPEF9#OZfLSoEbbHl?uQ2)u3
z7Z}I7<Q;Jy+*|Hlu^#!edR^=JWHx{8e3P;H+DJAwi!raTrSPVcVYEhIxj4kE<P!=H
z<!GAzg)uKL`d$!gYlSDQa@ufbjPao{Ce3CTox5RJw(0oMnDS{{nu8IS<uP9tuL52P
zLmgYc!iB(xfhnc{mR1;!aR~t|;=PO{rhB19yy{<U0M;79T0<E5d0xV~dYzwmHw??x
zjvwlW)<GEY)LRFPX4aTuHKtk`Q+|yp58<t_T&(rPYdv9=)7ApK5>|+QM&Z3M<gpFs
z;LE_OAD&I)UEm`y(sw<;q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!
zJ-5#ctlawim0Qn*W-edf?s@8glPq1n;`GhF_NA>~?U~>G@uw4PdHv?t*?p^i$vk_c
z_3DkoFLyNW`n~v%OUa6DW&bRie`rPP+*@DlaNd5Y<>u|Ojs=&GvYCW&v?gdY?p~_3
k7k*!Vc=1_h<-E6#KOR`NeBa?s<@>aQ-)+8}ZpnoH1)hZD5&!@I

diff --git a/sha1sum.txt b/sha1sum.txt
new file mode 100644
index 0000000..ec63bd7
--- /dev/null
+++ b/sha1sum.txt
@@ -0,0 +1 @@
+46a39009a9944b92a0b48b258ea98570b23d0b95  db.txt
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux