[virt-tools-list] [libosinfo 2/2] Add Udev support

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Tue Aug 30 18:30:16 UTC 2011


From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>

If enabled, provide a udev rule to listen to insertion/removal of
ISO9660 media and sets some helpful (to apps) properties on the device
if media is bootable.
---
 configure.ac            |    5 +++++
 data/95-osinfo.rules.in |   21 +++++++++++++++++++++
 data/Makefile.am        |   11 ++++++++++-
 libosinfo.spec.in       |    1 +
 4 files changed, 37 insertions(+), 1 deletions(-)
 create mode 100644 data/95-osinfo.rules.in

diff --git a/configure.ac b/configure.ac
index 324c0a1..390e053 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,6 +93,11 @@ if test "x$enable_introspection" != "xno" ; then
 fi
 AM_CONDITIONAL([WITH_GOBJECT_INTROSPECTION], [test "x$enable_introspection" = "xyes"])
 
+AC_ARG_ENABLE([udev],
+        AS_HELP_STRING([--enable-udev], [enable Udev support]),
+        [], [enable_udev=no])
+AM_CONDITIONAL([WITH_UDEV], [test "x$enable_udev" = "xyes"])
+
 AC_ARG_ENABLE([coverage],
         AS_HELP_STRING([--enable-coverage], [enable GCC code coverage]),
         [], [enable_coverage=no])
diff --git a/data/95-osinfo.rules.in b/data/95-osinfo.rules.in
new file mode 100644
index 0000000..0d5e5dd
--- /dev/null
+++ b/data/95-osinfo.rules.in
@@ -0,0 +1,21 @@
+# USB flash drives
+ACTION=="add|remove", \
+ SUBSYSTEM=="block", \
+ ENV{ID_FS_TYPE}=="iso9660", \
+ IMPORT{program}="@bindir@/osinfo-detect -f env $tempnode"
+
+# CDROMs
+
+# Disk inserted
+ACTION=="change", \
+ SUBSYSTEM=="block", \
+ ENV{ID_FS_TYPE}=="iso9660", \
+ IMPORT{program}="@bindir@/osinfo-detect -f env $tempnode"
+
+# Disk ejected
+ACTION=="change", \
+ SUBSYSTEM=="block", \
+ ENV{ID_FS_TYPE}!="iso9660", \
+ OSINFO_BOOTABLE="", \
+ OSINFO_INSTALLER=""
+
diff --git a/data/Makefile.am b/data/Makefile.am
index 657916a..566c611 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,11 +1,20 @@
 
 SUBDIRS = devices oses hypervisors
 
-EXTRA_DIST = usb.ids pci.ids
+EXTRA_DIST = usb.ids pci.ids 95-osinfo.rules.in
 
 databasedir = $(pkgdatadir)/data/
 database_DATA = usb.ids pci.ids
 
+if WITH_UDEV
+udevdir = /lib/udev/rules.d/
+udev_DATA = 95-osinfo.rules
+BUILT_SOURCES = 95-osinfo.rules
+
+95-osinfo.rules: 95-osinfo.rules.in
+	sed 's,\@bindir\@,$(exec_prefix)/bin,' 95-osinfo.rules.in > 95-osinfo.rules
+endif
+
 CLEANFILES = usb.ids pci.ids
 
 usb.ids:
diff --git a/libosinfo.spec.in b/libosinfo.spec.in
index 5d215ce..c91e897 100644
--- a/libosinfo.spec.in
+++ b/libosinfo.spec.in
@@ -28,6 +28,7 @@ BuildRequires: gobject-introspection-devel
 BuildRequires: gir-repository-devel
 %endif
 %endif
+Requires: udev
 
 %description
 libosinfo is a library that allows virtualization provisioning tools to
-- 
1.7.6




More information about the virt-tools-list mailing list