[libosinfo] Allow to use system pci.ids/usb.ids files

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

 



Most distros already ship copies of pci.ids/usb.ids. This commit
allows to make use of these rather than the ones shipped with
libosinfo. This is achieved through the use of
--with-usb-ids-path and --with-pci-ids-path configure flags.
---
 configure.ac      | 21 +++++++++++++++++++++
 data/Makefile.am  | 37 ++++++++++++++++++++++++++-----------
 libosinfo.spec.in |  2 +-
 3 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1e255c1..5ad9b6d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,6 +7,7 @@ AC_CONFIG_SRCDIR([osinfo/osinfo_db.c])
 AC_CONFIG_HEADERS([config.h])
 AC_PROG_LIBTOOL
 AC_PROG_CC
+AC_PROG_LN_S
 
 LIBOSINFO_COMPILE_WARNINGS
 GNOME_MAINTAINER_MODE_DEFINES
@@ -171,6 +172,26 @@ fi
 AC_SUBST(COVERAGE_CFLAGS)
 AC_SUBST(COVERAGE_LDFLAGS)
 
+# Path to the usb.ids file -- to know if we use one shipped with another
+# package, or an internal file
+AC_ARG_WITH(usb-ids-path,
+              [AC_HELP_STRING([--with-usb-ids-path],
+                              [Specify the path to usb.ids @<:@default=(internal)@:>@])],,
+                              [with_usb_ids_path="\${usb_databasedir}/usb.ids"])
+
+AM_CONDITIONAL(USE_INTERNAL_USB_IDS, test "x$with_usb_ids_path" = "x\${usb_databasedir}/usb.ids")
+AC_SUBST([USB_IDS], ["$with_usb_ids_path"])
+
+# Path to the pci.ids file -- to know if we use one shipped with another
+# package, or an internal file
+AC_ARG_WITH(pci-ids-path,
+              [AC_HELP_STRING([--with-pci-ids-path],
+                              [Specify the path to pci.ids @<:@default=(internal)@:>@])],,
+                              [with_pci_ids_path="\${pci_databasedir}/pci.ids"])
+
+AM_CONDITIONAL(USE_INTERNAL_PCI_IDS, test "x$with_pci_ids_path" = "x\${pci_databasedir}/pci.ids")
+AC_SUBST([PCI_IDS], ["$with_pci_ids_path"])
+
 # Setup GLIB_MKENUMS to use glib-mkenums even if GLib is uninstalled.
 GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
 AC_SUBST(GLIB_MKENUMS)
diff --git a/data/Makefile.am b/data/Makefile.am
index 747f0e9..77ad889 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,10 +1,30 @@
+INSTALL_DATA_HOOK_DEPS =
 
 SUBDIRS = datamaps devices oses hypervisors install-scripts schemas
-
 EXTRA_DIST = usb.ids pci.ids 95-osinfo.rules.in
+CLEANFILES = usb.ids pci.ids
+
+if USE_INTERNAL_USB_IDS
+usb_database_DATA = usb.ids
+usb_databasedir = $(pkgdatadir)/db/
+usb.ids:
+	-wget -q -O $@ http://www.linux-usb.org/usb.ids
+else
+usb_ids_install:
+	$(LN_S) $(USB_IDS) $(pkgdatadir)/db/usb.ids
+INSTALL_DATA_HOOK_DEPS += usb_ids_install
+endif
 
-databasedir = $(pkgdatadir)/db/
-database_DATA = usb.ids pci.ids
+if USE_INTERNAL_PCI_IDS
+pci_database_DATA = pci.ids
+pci_databasedir = $(pkgdatadir)/db/
+pci.ids:
+	-wget -q -O $@ http://pciids.sourceforge.net/v2.2/pci.ids
+else
+pci_ids_install:
+	$(LN_S) $(PCI_IDS) $(pkgdatadir)/db/pci.ids
+INSTALL_DATA_HOOK_DEPS += pci_ids_install
+endif
 
 if WITH_UDEV
 BUILT_SOURCES = 95-osinfo.rules
@@ -12,16 +32,11 @@ BUILT_SOURCES = 95-osinfo.rules
 95-osinfo.rules: 95-osinfo.rules.in
 	sed 's,\@bindir\@,$(exec_prefix)/bin,' $< > $@
 
-install-data-hook: 95-osinfo.rules
+95-osinfo.rules-install: 95-osinfo.rules
 	mkdir -p $(DESTDIR)$(UDEV_RULESDIR)
 	$(INSTALL) -m 0644 95-osinfo.rules $(DESTDIR)$(UDEV_RULESDIR)
 
+INSTALL_DATA_HOOK_DEPS += 95-osinfo.rules-install
 endif
 
-CLEANFILES = usb.ids pci.ids
-
-usb.ids:
-	-wget -q -O $@ http://www.linux-usb.org/usb.ids
-
-pci.ids:
-	-wget -q -O $@ http://pciids.sourceforge.net/v2.2/pci.ids
+install-data-hook: $(INSTALL_DATA_HOOK_DEPS)
diff --git a/libosinfo.spec.in b/libosinfo.spec.in
index 75de896..0864a2b 100644
--- a/libosinfo.spec.in
+++ b/libosinfo.spec.in
@@ -85,7 +85,7 @@ This package provides the Vala bindings for libosinfo library.
 %define udev_arg --enable-udev=no
 %endif
 
-%configure %{gir_arg} %{udev_arg} --enable-vala=yes
+%configure %{gir_arg} %{udev_arg} --enable-vala=yes --with-usb-ids-path=/usr/share/hwdata/usb.ids --with-pci-ids-path=/usr/share/hwdata/pci.ids
 %__make %{?_smp_mflags} V=1
 
 chmod a-x examples/*.js examples/*.py
-- 
1.8.1.4

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux