From a6b88dbc16ffcc3deb0eaa7bc162f64edd60bc27 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 8 Jul 2019 23:16:16 +0200 Subject: [PATCH] Parse GOG Galaxy architecture constraints Previously we would warn on any values other than "32#64#". --- CHANGELOG | 1 + src/cli/goggalaxy.cpp | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index bbbeb83..1ea0c0c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ innoextract 1.8 (WIP) - Added support for installers using an alternative setup loader magic - Added support for using boost_{zlib,bzip2} when statically linking Boost - Added support for automatically reading external setup.0 files + - Implemented parsing of GOG Galaxy architecture constraints - Fixed extracting files from slices larger than 2 GiB with 32-bit builds - Fixed output path for files with absolute paths (canonicalization now strips all unsafe characters) - Fixed output directory being created even when not extracting files diff --git a/src/cli/goggalaxy.cpp b/src/cli/goggalaxy.cpp index 885bb83..377e0e8 100644 --- a/src/cli/goggalaxy.cpp +++ b/src/cli/goggalaxy.cpp @@ -448,9 +448,35 @@ void parse_galaxy_files(setup::info & info, bool force) { } - if(check.size() >= 2 && !check[1].empty() && check[1] != "32#64#") { - log_warning << "Ignoring architecture constraint for GOG Galaxy file " << file.destination - << ": " << check[1]; + if(check.size() >= 2 && !check[1].empty()) { + const setup::file_entry::flags all_arch = setup::file_entry::Bits32 | setup::file_entry::Bits64; + setup::file_entry::flags arch = 0; + if(check[1] != "32#64#") { + std::vector architectures = parse_constraints(check[1]); + BOOST_FOREACH(const constraint & architecture, architectures) { + if(architecture.negated && architectures.size() > 1) { + log_warning << "Ignoring architecture for GOG Galaxy file " << file.destination + << ": !" << architecture.name; + } else if(architecture.name == "32") { + arch |= setup::file_entry::Bits32; + } else if(architecture.name == "64") { + arch |= setup::file_entry::Bits64; + } else { + log_warning << "Unknown architecture for GOG Galaxy file " << file.destination + << ": " << architecture.name; + } + if(architecture.negated && architectures.size() <= 1) { + arch = all_arch & ~arch; + } + } + if(arch == all_arch) { + arch = 0; + } + } + if((file.options & all_arch) && (file.options & all_arch) != arch) { + log_warning << "Overwriting architecture constraints for GOG Galaxy file " << file.destination; + } + file.options = (file.options & ~all_arch) | arch; } if(check.size() >= 3 && !check[2].empty()) {