Build: Download and uncompress gzipped version of pci.ids

Partially addresses #5611.
This commit is contained in:
Linus Groh 2021-03-03 23:50:25 +01:00 committed by Andreas Kling
parent 15ae22f7cc
commit 3775507613
Notes: sideshowbarker 2024-07-18 21:43:31 +09:00

View file

@ -184,9 +184,19 @@ add_subdirectory(AK)
add_subdirectory(Kernel)
add_subdirectory(Userland)
set(PCI_IDS_URL https://pci-ids.ucw.cz/v2.2/pci.ids)
set(PCI_IDS_PATH ${CMAKE_INSTALL_DATAROOTDIR}/pci.ids)
if(ENABLE_PCI_IDS_DOWNLOAD AND NOT EXISTS ${PCI_IDS_PATH})
message(STATUS "Downloading PCI ID database from ${PCI_IDS_URL}...")
file(DOWNLOAD ${PCI_IDS_URL} ${PCI_IDS_PATH} INACTIVITY_TIMEOUT 10)
set(PCI_IDS_GZ_URL https://pci-ids.ucw.cz/v2.2/pci.ids.gz)
set(PCI_IDS_GZ_PATH ${CMAKE_BINARY_DIR}/pci.ids.gz)
set(PCI_IDS_PATH ${CMAKE_BINARY_DIR}/pci.ids)
set(PCI_IDS_INSTALL_PATH ${CMAKE_INSTALL_DATAROOTDIR}/pci.ids)
if(ENABLE_PCI_IDS_DOWNLOAD AND NOT EXISTS ${PCI_IDS_GZ_PATH})
message(STATUS "Downloading PCI ID database from ${PCI_IDS_GZ_URL}...")
file(DOWNLOAD ${PCI_IDS_GZ_URL} ${PCI_IDS_GZ_PATH} INACTIVITY_TIMEOUT 10)
endif()
if(EXISTS ${PCI_IDS_GZ_PATH} AND NOT EXISTS ${PCI_IDS_INSTALL_PATH})
message(STATUS "Extracting PCI ID database from ${PCI_IDS_GZ_PATH}...")
execute_process(COMMAND gzip -k -d ${PCI_IDS_GZ_PATH})
file(MAKE_DIRECTORY ${CMAKE_INSTALL_DATAROOTDIR})
file(RENAME ${PCI_IDS_PATH} ${PCI_IDS_INSTALL_PATH})
endif()