From 8e41fcf367697e694aa00b9c6e5e0613803548b0 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Wed, 16 Apr 2014 17:16:01 +0000
Subject: crda: update to 3.13. refs #961

---
 .../crda/0001-Makefile-Don-t-run-ldconfig.patch    | 24 ++++++++++
 ...Link-libreg.so-against-the-crypto-library.patch | 55 ++++++++++++++++++++++
 ...e-linking-order-to-avoid-compilation-erro.patch | 52 ++++++++++++++++++++
 ...STDIR-support-in-install-libreg-rules-in-.patch | 37 +++++++++++++++
 abs/extra/crda/PKGBUILD                            | 36 ++++++++++----
 abs/extra/crda/__changelog                         |  1 +
 abs/extra/crda/libnl32.patch                       | 12 -----
 7 files changed, 195 insertions(+), 22 deletions(-)
 create mode 100644 abs/extra/crda/0001-Makefile-Don-t-run-ldconfig.patch
 create mode 100644 abs/extra/crda/0001-Makefile-Link-libreg.so-against-the-crypto-library.patch
 create mode 100644 abs/extra/crda/0001-crda-Fix-the-linking-order-to-avoid-compilation-erro.patch
 create mode 100644 abs/extra/crda/0002-crda-Add-DESTDIR-support-in-install-libreg-rules-in-.patch
 create mode 100644 abs/extra/crda/__changelog
 delete mode 100644 abs/extra/crda/libnl32.patch

diff --git a/abs/extra/crda/0001-Makefile-Don-t-run-ldconfig.patch b/abs/extra/crda/0001-Makefile-Don-t-run-ldconfig.patch
new file mode 100644
index 0000000..e9f102d
--- /dev/null
+++ b/abs/extra/crda/0001-Makefile-Don-t-run-ldconfig.patch
@@ -0,0 +1,24 @@
+From 15bc8065e9dc5485c650c528f8d80f7536e378d6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Thomas=20B=C3=A4chler?= <thomas@archlinux.org>
+Date: Fri, 21 Feb 2014 20:30:24 +0100
+Subject: [PATCH] Makefile: Don't run ldconfig
+
+---
+ Makefile | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 80f4946..c003195 100644
+--- a/Makefile
++++ b/Makefile
+@@ -130,7 +130,6 @@ install-libreg:
+ 	$(NQ) '  INSTALL  libreg'
+ 	$(Q)mkdir -p $(DESTDIR)/$(LIBDIR)
+ 	$(Q)cp $(LIBREG) $(DESTDIR)/$(LIBDIR)/
+-	$(Q)ldconfig
+ 
+ %.o: %.c regdb.h $(LIBREG)
+ 	$(NQ) '  CC  ' $@
+-- 
+1.9.0
+
diff --git a/abs/extra/crda/0001-Makefile-Link-libreg.so-against-the-crypto-library.patch b/abs/extra/crda/0001-Makefile-Link-libreg.so-against-the-crypto-library.patch
new file mode 100644
index 0000000..10dae58
--- /dev/null
+++ b/abs/extra/crda/0001-Makefile-Link-libreg.so-against-the-crypto-library.patch
@@ -0,0 +1,55 @@
+From e2e519730c33de4503ac5dda28863d029e3cf578 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Thomas=20B=C3=A4chler?= <thomas@archlinux.org>
+Date: Fri, 21 Feb 2014 20:15:32 +0100
+Subject: [PATCH] Makefile: Link libreg.so against the crypto library.
+
+---
+ Makefile | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 1f25509..80f4946 100644
+--- a/Makefile
++++ b/Makefile
+@@ -33,6 +33,7 @@ LDLIBS += $(LDLIBREG)
+ LDLIBS += -lm
+ LIBREG += libreg.so
+ LDFLAGS += -L ./
++LIBREG_LDFLAGS += -lm
+ 
+ all: all_noverify verify
+ 
+@@ -40,17 +41,19 @@ all_noverify: $(LIBREG) crda intersect regdbdump db2rd optimize
+ 
+ ifeq ($(USE_OPENSSL),1)
+ CFLAGS += -DUSE_OPENSSL -DPUBKEY_DIR=\"$(RUNTIME_PUBKEY_DIR)\" `pkg-config --cflags openssl`
+-LDLIBS += `pkg-config --libs openssl`
++LDCRYPTOLIB := `pkg-config --libs openssl`
+ 
+ $(LIBREG): keys-ssl.c
+ 
+ else
+ CFLAGS += -DUSE_GCRYPT
+-LDLIBS += -lgcrypt
++LDCRYPTOLIB := -lgcrypt
+ 
+ $(LIBREG): keys-gcrypt.c
+ 
+ endif
++LDLIBS += $(LDCRYPTOLIB)
++LIBREG_LDFLAGS += $(LDCRYPTOLIB)
+ MKDIR ?= mkdir -p
+ INSTALL ?= install
+ 
+@@ -116,7 +119,7 @@ keys-%.c: utils/key2pub.py $(wildcard $(PUBKEY_DIR)/*.pem)
+ 
+ $(LIBREG): regdb.h reglib.h reglib.c
+ 	$(NQ) '  CC  ' $@
+-	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -shared -Wl,-soname,$(LIBREG) $^
++	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -shared -Wl,-soname,$(LIBREG) $^ $(LIBREG_LDFLAGS)
+ 
+ install-libreg-headers:
+ 	$(NQ) '  INSTALL  libreg-headers'
+-- 
+1.9.0
+
diff --git a/abs/extra/crda/0001-crda-Fix-the-linking-order-to-avoid-compilation-erro.patch b/abs/extra/crda/0001-crda-Fix-the-linking-order-to-avoid-compilation-erro.patch
new file mode 100644
index 0000000..6807e99
--- /dev/null
+++ b/abs/extra/crda/0001-crda-Fix-the-linking-order-to-avoid-compilation-erro.patch
@@ -0,0 +1,52 @@
+From fefefdb2c52c8fbedbb339b4badb8226cad7e7e0 Mon Sep 17 00:00:00 2001
+From: Krishna Chaitanya <chaitanya.mgit@gmail.com>
+Date: Mon, 16 Dec 2013 21:57:39 +0530
+Subject: [PATCH] crda: Fix the linking order to avoid compilation error
+
+While linking the crda.o and libreg.so, first put crda.o
+and then -lreg. This fixed the below error:
+
+  GEN  keys-gcrypt.c
+  Trusted pubkeys: pubkeys/linville.key.pub.pem
+  CC   libreg.so
+  CC   crda.o
+  LD   crda
+crda.o: In function `main':
+crda/crda.c:196: undefined reference to `reglib_get_rd_alpha2'
+collect2: ld returned 1 exit status
+make: *** [crda] Error 1
+
+Note: This still doesn't fix the below error (will send another mail)
+
+  CHK  /usr/lib/crda/regulatory.bin
+Database signature verification failed.
+Invalid or empty regulatory file, note: a binary regulatory file should be used.
+make: *** [verify] Error 234
+
+Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
+Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
+---
+ Makefile | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 4a351c6..0b2f0d7 100644
+--- a/Makefile
++++ b/Makefile
+@@ -28,10 +28,11 @@ RUNTIME_PUBKEY_DIR?=/etc/wireless-regdb/pubkeys
+ CFLAGS += -O2 -fpic
+ CFLAGS += -std=gnu99 -Wall -Werror -pedantic
+ CFLAGS += -Wall -g
+-LDLIBS += -lm
+ LDLIBREG += -lreg
++LDLIBS += $(LDLIBREG)
++LDLIBS += -lm
+ LIBREG += libreg.so
+-LDFLAGS += -L ./ $(LDLIBREG)
++LDFLAGS += -L ./
+ 
+ all: all_noverify verify
+ 
+-- 
+1.9.0
+
diff --git a/abs/extra/crda/0002-crda-Add-DESTDIR-support-in-install-libreg-rules-in-.patch b/abs/extra/crda/0002-crda-Add-DESTDIR-support-in-install-libreg-rules-in-.patch
new file mode 100644
index 0000000..c69f8f7
--- /dev/null
+++ b/abs/extra/crda/0002-crda-Add-DESTDIR-support-in-install-libreg-rules-in-.patch
@@ -0,0 +1,37 @@
+From 2cabb2588da56735369131b709f191453c080be0 Mon Sep 17 00:00:00 2001
+From: "John W. Linville" <linville@tuxdriver.com>
+Date: Fri, 14 Feb 2014 13:58:44 -0500
+Subject: [PATCH 2/2] crda: Add DESTDIR support in install-libreg* rules in
+ Makefile
+
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
+---
+ Makefile | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 0b2f0d7..1f25509 100644
+--- a/Makefile
++++ b/Makefile
+@@ -120,13 +120,13 @@ $(LIBREG): regdb.h reglib.h reglib.c
+ 
+ install-libreg-headers:
+ 	$(NQ) '  INSTALL  libreg-headers'
+-	$(Q)mkdir -p $(INCLUDE_DIR)
+-	$(Q)cp *.h $(INCLUDE_DIR)/
++	$(Q)mkdir -p $(DESTDIR)/$(INCLUDE_DIR)
++	$(Q)cp *.h $(DESTDIR)/$(INCLUDE_DIR)/
+ 
+ install-libreg:
+ 	$(NQ) '  INSTALL  libreg'
+-	$(Q)mkdir -p $(LIBDIR)
+-	$(Q)cp $(LIBREG) $(LIBDIR)/
++	$(Q)mkdir -p $(DESTDIR)/$(LIBDIR)
++	$(Q)cp $(LIBREG) $(DESTDIR)/$(LIBDIR)/
+ 	$(Q)ldconfig
+ 
+ %.o: %.c regdb.h $(LIBREG)
+-- 
+1.9.0
+
diff --git a/abs/extra/crda/PKGBUILD b/abs/extra/crda/PKGBUILD
index 2f4f1c2..53fe499 100644
--- a/abs/extra/crda/PKGBUILD
+++ b/abs/extra/crda/PKGBUILD
@@ -1,23 +1,41 @@
-# $Id: PKGBUILD 186207 2013-05-22 04:47:50Z foutrelis $
+# $Id$
 # Maintainer: Thomas Bächler <thomas@archlinux.org>
 
 pkgname=crda
-pkgver=1.1.3
-pkgrel=2
+pkgver=3.13
+pkgrel=1
 pkgdesc="Central Regulatory Domain Agent for wireless networks"
 arch=(i686 x86_64)
 url="http://wireless.kernel.org/en/developers/Regulatory/CRDA"
 license=('custom')
-depends=('wireless-regdb' 'libnl' 'libgcrypt' 'systemd-tools' 'iw')
+depends=('wireless-regdb' 'libnl' 'libgcrypt' 'systemd' 'iw')
 makedepends=('python-m2crypto')
 install=crda.install
-source=(http://wireless.kernel.org/download/crda/${pkgname}-${pkgver}.tar.bz2
-        set-wireless-regdom)
+source=(https://kernel.org/pub/software/network/crda/${pkgname}-${pkgver}.tar.xz
+        set-wireless-regdom
+        0001-crda-Fix-the-linking-order-to-avoid-compilation-erro.patch
+        0002-crda-Add-DESTDIR-support-in-install-libreg-rules-in-.patch
+        0001-Makefile-Link-libreg.so-against-the-crypto-library.patch
+        0001-Makefile-Don-t-run-ldconfig.patch)
+sha256sums=('2f85da7ab0170b140d6ed62596c8f268d4a7dedecf84cac7182ada979742ff59'
+            '603ce97da5cce3f5337e99007ce04e2f295bb33a36b308794884011f7bcabaf3'
+            '8920b5988eb1befe13f88ce5c0dbbf30c294796d613681a2b0925f6f8534c51b'
+            'ced0a372b06ffd64f90be77d7267c9d8cc10413bc017c3154b7208dbf69be3cb'
+            '96b2068b27202f8bc78009869520e396cb3f3ac7a826efef06d0fc41047f2520'
+            'ff52990cf9295e5cebcf07ebbf2a96e225d97088573edcc898b29ce33a0fb663')
 
-build() {
+prepare() {
   cd "${srcdir}"/${pkgname}-${pkgver}
   sed 's|^#!/usr/bin/env python|#!/usr/bin/python2|' -i utils/key2pub.py
-  make crda regdbdump
+  patch -p1 -i "${srcdir}"/0001-crda-Fix-the-linking-order-to-avoid-compilation-erro.patch
+  patch -p1 -i "${srcdir}"/0002-crda-Add-DESTDIR-support-in-install-libreg-rules-in-.patch
+  patch -p1 -i "${srcdir}"/0001-Makefile-Link-libreg.so-against-the-crypto-library.patch
+  patch -p1 -i "${srcdir}"/0001-Makefile-Don-t-run-ldconfig.patch
+}
+
+build() {
+  cd "${srcdir}"/${pkgname}-${pkgver}
+  make
 }
 
 package() {
@@ -33,5 +51,3 @@ package() {
   
   install -D -m755 "${srcdir}"/set-wireless-regdom "${pkgdir}"/usr/bin/set-wireless-regdom
 }
-md5sums=('29579185e06a75675507527243d28e5c'
-         '65c93f2ff2eb1b29d9e9fa102ae2dd45')
diff --git a/abs/extra/crda/__changelog b/abs/extra/crda/__changelog
new file mode 100644
index 0000000..2c7ba65
--- /dev/null
+++ b/abs/extra/crda/__changelog
@@ -0,0 +1 @@
+PKGBUILD: change dep python2-m2crypto to python-m2crypto
diff --git a/abs/extra/crda/libnl32.patch b/abs/extra/crda/libnl32.patch
deleted file mode 100644
index 682b6c5..0000000
--- a/abs/extra/crda/libnl32.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -u -r crda-1.1.2/Makefile crda-1.1.2-libnl32/Makefile
---- crda-1.1.2/Makefile	2011-08-10 01:36:19.000000000 +0200
-+++ crda-1.1.2-libnl32/Makefile	2012-02-09 18:53:33.376430180 +0100
-@@ -51,7 +51,7 @@
- 
- ifeq ($(NL3FOUND),Y)
- CFLAGS += -DCONFIG_LIBNL30
--NLLIBS += -lnl-genl
-+NLLIBS += $(shell pkg-config --libs libnl-genl-3.0)
- NLLIBNAME = libnl-3.0
- else
- 	ifeq ($(NL2FOUND),Y)
-- 
cgit v0.12

