Blame SOURCES/0001-Add-AppStream-metadata.patch

4c80fc
From 90a6c3c999f2ee5fd20f9f5866a6164866ac7dfa Mon Sep 17 00:00:00 2001
4c80fc
From: "Rebecca N. Palmer" <rebecca_palmer@zoho.com>
4c80fc
Date: Sun, 15 Jan 2017 23:17:49 +0000
4c80fc
Subject: [PATCH] Add AppStream metadata
4c80fc
4c80fc
AppStream is a standard for software metadata,
4c80fc
including what hardware a driver supports:
4c80fc
https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html
4c80fc
4c80fc
Signed-off-by: Rebecca N. Palmer <rebecca_palmer@zoho.com>
4c80fc
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
4c80fc
(cherry picked from commit 033464f4b8045a49dbcc1a84cde5c05986ca11c2)
4c80fc
---
4c80fc
 CMakeLists.txt                    |  5 +++++
4c80fc
 com.intel.beignet.metainfo.xml.in | 18 ++++++++++++++++++
4c80fc
 update_metainfo_xml.py            | 32 ++++++++++++++++++++++++++++++++
4c80fc
 3 files changed, 55 insertions(+)
4c80fc
 create mode 100644 com.intel.beignet.metainfo.xml.in
4c80fc
 create mode 100755 update_metainfo_xml.py
4c80fc
4c80fc
diff --git a/CMakeLists.txt b/CMakeLists.txt
4c80fc
index face3ce7..2e520213 100644
4c80fc
--- a/CMakeLists.txt
4c80fc
+++ b/CMakeLists.txt
4c80fc
@@ -37,6 +37,7 @@ INCLUDE (GNUInstallDirs OPTIONAL)
4c80fc
 # support old CMake without GNUInstallDirs
4c80fc
 if (NOT CMAKE_INSTALL_FULL_LIBDIR)
4c80fc
   set (CMAKE_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
4c80fc
+  set (CMAKE_INSTALL_FULL_DATADIR "${CMAKE_INSTALL_PREFIX}/share")
4c80fc
   set (BEIGNET_LIBRARY_ARCHITECTURE "")
4c80fc
 else (NOT CMAKE_INSTALL_FULL_LIBDIR)
4c80fc
   set (BEIGNET_LIBRARY_ARCHITECTURE "${CMAKE_LIBRARY_ARCHITECTURE}")
4c80fc
@@ -340,6 +341,10 @@ IF(BUILD_EXAMPLES)
4c80fc
 ADD_SUBDIRECTORY(examples)
4c80fc
 ENDIF(BUILD_EXAMPLES)
4c80fc
 
4c80fc
+add_custom_target(metainfo ALL
4c80fc
+                  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/update_metainfo_xml.py "${LIBCL_DRIVER_VERSION_MAJOR}.${LIBCL_DRIVER_VERSION_MINOR}.${LIBCL_DRIVER_VERSION_PATCH}" ${CMAKE_CURRENT_BINARY_DIR})
4c80fc
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/com.intel.beignet.metainfo.xml DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/metainfo)
4c80fc
+
4c80fc
 SET(CPACK_SET_DESTDIR ON)
4c80fc
 SET(CPACK_PACKAGE_VERSION_MAJOR "${LIBCL_DRIVER_VERSION_MAJOR}")
4c80fc
 SET(CPACK_PACKAGE_VERSION_MINOR "${LIBCL_DRIVER_VERSION_MINOR}")
4c80fc
diff --git a/com.intel.beignet.metainfo.xml.in b/com.intel.beignet.metainfo.xml.in
4c80fc
new file mode 100644
4c80fc
index 00000000..65a2fad9
4c80fc
--- /dev/null
4c80fc
+++ b/com.intel.beignet.metainfo.xml.in
4c80fc
@@ -0,0 +1,18 @@
4c80fc
+
4c80fc
+<component type="driver">
4c80fc
+<id>com.intel.beignet</id>
4c80fc
+<name>Beignet</name>
4c80fc
+<summary>OpenCL (GPU compute) driver for Intel GPUs</summary>
4c80fc
+<description>This allows using Intel integrated GPUs for general computation, speeding up some applications.</description>
4c80fc
+<provides>
4c80fc
+@modalias_list@
4c80fc
+</provides>
4c80fc
+<metadata_license>MIT</metadata_license>
4c80fc
+<project_license>LGPL-2.1+</project_license>
4c80fc
+<url type="homepage">https://www.freedesktop.org/wiki/Software/Beignet/</url>
4c80fc
+<url type="bugtracker">https://bugs.freedesktop.org/buglist.cgi?product=Beignet&component=Beignet&resolution=---</url>
4c80fc
+<developer_name>Intel</developer_name>
4c80fc
+<releases>
4c80fc
+<release version="@version@"></release>
4c80fc
+</releases>
4c80fc
+</component>
4c80fc
diff --git a/update_metainfo_xml.py b/update_metainfo_xml.py
4c80fc
new file mode 100755
4c80fc
index 00000000..487bd757
4c80fc
--- /dev/null
4c80fc
+++ b/update_metainfo_xml.py
4c80fc
@@ -0,0 +1,32 @@
4c80fc
+#!/usr/bin/python
4c80fc
+
4c80fc
+import re
4c80fc
+import sys
4c80fc
+import os.path
4c80fc
+from io import open
4c80fc
+
4c80fc
+if len(sys.argv) != 3:
4c80fc
+    raise TypeError("requires version_string and output_directory")
4c80fc
+version_string = sys.argv[1]
4c80fc
+output_directory = sys.argv[2]
4c80fc
+source_directory = os.path.dirname(sys.argv[0])
4c80fc
+source_file = open(os.path.join(source_directory,"src/cl_device_data.h"),"r",encoding = 'utf-8')
4c80fc
+device_ids = []
4c80fc
+supported = False # first few devices in the file aren't supported
4c80fc
+for line in source_file:
4c80fc
+    device_id = re.match(r"#define\s+PCI_CHIP_([A-Za-z0-9_]+)\s+0x([0-9A-Fa-f]+)",line)
4c80fc
+    if device_id is None:
4c80fc
+        continue
4c80fc
+    if "IVYBRIDGE" in device_id.group(1):
4c80fc
+        supported = True # start of supported devices
4c80fc
+    if supported:
4c80fc
+        device_ids.append(device_id.group(2).upper())
4c80fc
+source_file.close()
4c80fc
+modalias_list_string = "\n".join("<modalias>pci:v00008086d0000{}*</modalias>".format(device_id) for device_id in sorted(device_ids))
4c80fc
+metadata_file_in = open(os.path.join(source_directory,"com.intel.beignet.metainfo.xml.in"),"r",encoding = 'utf-8')
4c80fc
+metadata_string = metadata_file_in.read()
4c80fc
+metadata_file_in.close()
4c80fc
+metadata_string = metadata_string.replace("@modalias_list@",modalias_list_string).replace("@version@",version_string)
4c80fc
+metadata_file_out = open(os.path.join(output_directory,"com.intel.beignet.metainfo.xml"),"w",encoding = 'utf-8')
4c80fc
+metadata_file_out.write(metadata_string)
4c80fc
+metadata_file_out.close()
4c80fc
-- 
4c80fc
2.14.2
4c80fc