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
```
This commit is contained in:
Diego Iastrubni 2022-09-02 18:56:23 +03:00 committed by Sam Atkins
parent 8b30b69dac
commit 629c77440b
Notes: sideshowbarker 2024-07-17 11:06:06 +09:00

View file

@ -244,42 +244,24 @@ endif()
export_components("${CMAKE_BINARY_DIR}/components.ini") 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_FILE pci.ids)
set(PCI_IDS_GZ_URL https://pci-ids.ucw.cz/v2.2/${PCI_IDS_FILE}.gz) set(PCI_IDS_URL https://pci-ids.ucw.cz/v2.2/${PCI_IDS_FILE})
set(PCI_IDS_GZ_PATH ${CMAKE_BINARY_DIR}/${PCI_IDS_FILE}.gz)
set(PCI_IDS_PATH ${CMAKE_BINARY_DIR}/${PCI_IDS_FILE}) set(PCI_IDS_PATH ${CMAKE_BINARY_DIR}/${PCI_IDS_FILE})
set(PCI_IDS_INSTALL_PATH ${CMAKE_INSTALL_DATAROOTDIR}/${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}) if(ENABLE_PCI_IDS_DOWNLOAD AND NOT EXISTS ${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH} )
download_file("${PCI_IDS_GZ_URL}" "${PCI_IDS_GZ_PATH}") download_file("${PCI_IDS_URL}" "${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_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()
endif() endif()
set(USB_IDS_FILE usb.ids) set(USB_IDS_FILE usb.ids)
set(USB_IDS_GZ_URL http://www.linux-usb.org/${USB_IDS_FILE}.gz) set(USB_IDS_URL http://www.linux-usb.org/${USB_IDS_FILE})
set(USB_IDS_GZ_PATH ${CMAKE_BINARY_DIR}/${USB_IDS_FILE}.gz)
set(USB_IDS_PATH ${CMAKE_BINARY_DIR}/${USB_IDS_FILE}) set(USB_IDS_PATH ${CMAKE_BINARY_DIR}/${USB_IDS_FILE})
set(USB_IDS_INSTALL_PATH ${CMAKE_INSTALL_DATAROOTDIR}/${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}) if(ENABLE_USB_IDS_DOWNLOAD AND NOT EXISTS "${CMAKE_STAGING_PREFIX}/${USB_IDS_PATH}")
download_file("${USB_IDS_GZ_URL}" "${USB_IDS_GZ_PATH}") download_file("${USB_IDS_URL}" "${CMAKE_STAGING_PREFIX}/${USB_IDS_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()
endif() endif()