From 629c77440b1c5fffb50bb3ac0ca0d5ca9e97fb51 Mon Sep 17 00:00:00 2001 From: Diego Iastrubni Date: Fri, 2 Sep 2022 18:56:23 +0300 Subject: [PATCH] Meta: Download uncompressed files instead of *.gz Problem: cmake cannot handle gzip files (see https://gitlab.kitware.com/cmake/cmake/-/issues/23054 for more details). Instead of downloading the compressed (*.gz) USB and PCI ids, we not download the raw uncompressed files. The sizes we "loose" due to downloading such files are meaningless. This are the file sizes: ``` diego@debian:~/$ ls -lh pci.ids{,.gz} usb.ids{,.gz} -rw-r--r-- 1 diego diego 1.3M Aug 7 04:15 pci.ids -rw-r--r-- 1 diego diego 300K Aug 7 04:15 pci.ids.gz -rw-r--r-- 1 diego diego 700K May 20 22:34 usb.ids -rw-r--r-- 1 diego diego 245K May 20 22:34 usb.ids.gz ``` --- CMakeLists.txt | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f20d105002..8bbd49c03c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,42 +244,24 @@ endif() export_components("${CMAKE_BINARY_DIR}/components.ini") +# it seems like cmake cannot uncompress *.gz files... only ZIP/tar.gz. +# Lets download the uncompressed versions. +# https://gitlab.kitware.com/cmake/cmake/-/issues/23054 + set(PCI_IDS_FILE pci.ids) -set(PCI_IDS_GZ_URL https://pci-ids.ucw.cz/v2.2/${PCI_IDS_FILE}.gz) -set(PCI_IDS_GZ_PATH ${CMAKE_BINARY_DIR}/${PCI_IDS_FILE}.gz) +set(PCI_IDS_URL https://pci-ids.ucw.cz/v2.2/${PCI_IDS_FILE}) set(PCI_IDS_PATH ${CMAKE_BINARY_DIR}/${PCI_IDS_FILE}) set(PCI_IDS_INSTALL_PATH ${CMAKE_INSTALL_DATAROOTDIR}/${PCI_IDS_FILE}) -if(ENABLE_PCI_IDS_DOWNLOAD AND NOT EXISTS ${PCI_IDS_GZ_PATH}) - download_file("${PCI_IDS_GZ_URL}" "${PCI_IDS_GZ_PATH}") -endif() - -if(EXISTS ${PCI_IDS_GZ_PATH} AND NOT EXISTS ${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}) - message(STATUS "Extracting PCI ID database from ${PCI_IDS_GZ_PATH}...") - file(MAKE_DIRECTORY "${CMAKE_STAGING_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}") - if (CMAKE_VERSION VERSION_LESS 3.18.0) - execute_process(COMMAND "${GZIP_TOOL}" -d -c "${PCI_IDS_GZ_PATH}" OUTPUT_FILE "${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}") - else() - file(ARCHIVE_EXTRACT INPUT "${PCI_IDS_GZ_PATH}" DESTINATION "${PCI_IDS_GZ_PATH}" PATTERNS "${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}") - endif() +if(ENABLE_PCI_IDS_DOWNLOAD AND NOT EXISTS ${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH} ) + download_file("${PCI_IDS_URL}" "${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}") endif() set(USB_IDS_FILE usb.ids) -set(USB_IDS_GZ_URL http://www.linux-usb.org/${USB_IDS_FILE}.gz) -set(USB_IDS_GZ_PATH ${CMAKE_BINARY_DIR}/${USB_IDS_FILE}.gz) +set(USB_IDS_URL http://www.linux-usb.org/${USB_IDS_FILE}) set(USB_IDS_PATH ${CMAKE_BINARY_DIR}/${USB_IDS_FILE}) set(USB_IDS_INSTALL_PATH ${CMAKE_INSTALL_DATAROOTDIR}/${USB_IDS_FILE}) -if(ENABLE_USB_IDS_DOWNLOAD AND NOT EXISTS ${USB_IDS_GZ_PATH}) - download_file("${USB_IDS_GZ_URL}" "${USB_IDS_GZ_PATH}") -endif() - -if(EXISTS ${USB_IDS_GZ_PATH} AND NOT EXISTS ${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH}) - message(STATUS "Extracting USB ID database from ${USB_IDS_GZ_PATH}...") - file(MAKE_DIRECTORY "${CMAKE_STAGING_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}") - if (CMAKE_VERSION VERSION_LESS 3.18.0) - execute_process(COMMAND "${GZIP_TOOL}" -d -c "${USB_IDS_GZ_PATH}" OUTPUT_FILE "${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH}") - else() - file(ARCHIVE_EXTRACT INPUT "${PCI_IDS_GZ_PATH}" DESTINATION "${USB_IDS_GZ_PATH}" PATTERNS "${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH}") - endif() +if(ENABLE_USB_IDS_DOWNLOAD AND NOT EXISTS "${CMAKE_STAGING_PREFIX}/${USB_IDS_PATH}") + download_file("${USB_IDS_URL}" "${CMAKE_STAGING_PREFIX}/${USB_IDS_PATH}") endif()