beignet-1.3.2-add-appstream-metadata.patch 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. Description: Add Appstream metadata listing supported hardware
  2. http://people.skolelinux.org/pere/blog/Using_appstream_with_isenkram_to_install_hardware_related_packages_in_Debian.html
  3. https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#sect-Metadata-GenericComponent
  4. Upstream agreed in
  5. https://lists.freedesktop.org/archives/beignet/2017-February/008597.html
  6. that this metadata (including parts automatically extracted from
  7. src/cl_device_data.h) can be MIT licensed.
  8. Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>, Yang Rong
  9. Forwarded: accepted https://cgit.freedesktop.org/beignet/commit/?id=033464f4b8045a49dbcc1a84cde5c05986ca11c2
  10. --- a/CMakeLists.txt
  11. +++ b/CMakeLists.txt
  12. @@ -339,6 +339,10 @@ IF(BUILD_EXAMPLES)
  13. ADD_SUBDIRECTORY(examples)
  14. ENDIF(BUILD_EXAMPLES)
  15. +add_custom_target(metainfo ALL
  16. + 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})
  17. +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/com.intel.beignet.metainfo.xml DESTINATION /usr/share/metainfo)
  18. +
  19. SET(CPACK_SET_DESTDIR ON)
  20. SET(CPACK_PACKAGE_VERSION_MAJOR "${LIBCL_DRIVER_VERSION_MAJOR}")
  21. SET(CPACK_PACKAGE_VERSION_MINOR "${LIBCL_DRIVER_VERSION_MINOR}")
  22. --- /dev/null
  23. +++ b/com.intel.beignet.metainfo.xml.in
  24. @@ -0,0 +1,17 @@
  25. +<?xml version="1.0" encoding="UTF-8"?>
  26. +<component type="driver">
  27. +<id>com.intel.beignet</id>
  28. +<name>Beignet</name>
  29. +<summary>OpenCL (GPU compute) driver for Intel GPUs</summary>
  30. +<description>This allows using Intel integrated GPUs for general computation, speeding up some applications.</description>
  31. +<provides>
  32. +@modalias_list@
  33. +</provides>
  34. +<metadata_license>MIT</metadata_license>
  35. +<project_license>LGPL-2.1+</project_license>
  36. +<url type="homepage">https://www.freedesktop.org/wiki/Software/Beignet/</url>
  37. +<developer_name>Intel</developer_name>
  38. +<releases>
  39. +<release version="@version@"></release>
  40. +</releases>
  41. +</component>
  42. --- /dev/null
  43. +++ b/update_metainfo_xml.py
  44. @@ -0,0 +1,33 @@
  45. +#!/usr/bin/python3
  46. +
  47. +import re
  48. +import sys
  49. +import os.path
  50. +from io import open
  51. +
  52. +if len(sys.argv)!=3:
  53. + raise TypeError("requires version_string and output_directory")
  54. +version_string=sys.argv[1]
  55. +output_directory=sys.argv[2]
  56. +source_directory=os.path.dirname(sys.argv[0])
  57. +source_file=open(os.path.join(source_directory,"src/cl_device_data.h"),"r",encoding='utf-8')
  58. +device_ids=[]
  59. +supported=False#first few devices in the file aren't supported
  60. +for line in source_file:
  61. + device_id=re.match(r"#define\s+PCI_CHIP_([A-Za-z0-9_]+)\s+0x([0-9A-Fa-f]+)",line)
  62. + if device_id is None:
  63. + continue
  64. + if "IVYBRIDGE" in device_id.group(1):
  65. + supported=True#start of supported devices
  66. + if supported:
  67. + device_ids.append(device_id.group(2).upper())
  68. +source_file.close()
  69. +modalias_list_string="\n".join("<modalias>pci:v00008086d0000{}*</modalias>".format(device_id) for device_id in sorted(device_ids))
  70. +metadata_file_in=open(os.path.join(source_directory,"com.intel.beignet.metainfo.xml.in"),"r",encoding='utf-8')
  71. +metadata_string=metadata_file_in.read()
  72. +metadata_file_in.close()
  73. +metadata_string=metadata_string.replace("@modalias_list@",modalias_list_string).replace("@version@",version_string)
  74. +metadata_file_out=open(os.path.join(output_directory,"com.intel.beignet.metainfo.xml"),"w",encoding='utf-8')
  75. +metadata_file_out.write(metadata_string)
  76. +metadata_file_out.close()
  77. +