Browse Source

Add a --data-version option to identify Inno Setup installers

Implements: issue #17
coverity_scan
Daniel Scharrer 8 years ago
parent
commit
e97782cd7b
  1. 1
      CHANGELOG
  2. 20
      doc/innoextract.1
  3. 12
      src/cli/extract.cpp
  4. 1
      src/cli/extract.hpp
  5. 17
      src/cli/main.cpp

1
CHANGELOG

@ -6,6 +6,7 @@ innoextract 1.7 (TDB)
- Added a --show-password option to print password check information
- Added a --check-password option to abort if the provided password does not match the stored checksum
- Added a --info convenience option to print information about the installer
- Added a --data-version option to print the data version and exit
- Fixed building in paths that contain regex expressions
- Fixed case-sensitivity in parent directory when creating subdirectories
- Fixed .bin slice file names used with Inno Setup versions older than 4.1.7

20
doc/innoextract.1

@ -39,6 +39,7 @@ Here is a short summary of the options available in innoextract. Please refer to
\-\-gog\-game\-id Determine the GOG.com game ID for this installer
\-\-show\-password Show password check information
\-\-check\-password Abort if the password is incorrect
\-V \-\-data\-version Only print the data version
.fi
.TP
.B Modifiers:
@ -109,6 +110,20 @@ Exit when a collision is detected.
With the "\fBrename\fP" action, steps 1 and 3 are only applied to files that would have been overwritten by the "\fBoverwrite\fP" action while "\fBrename-all\fP" applies them to all files in the collision set.
.TP
\fB\-c\fP, \fB\-\-color\fP[=\fIENABLE\fP]
By default
.B innoextract
will try to detect if the terminal supports shell escape codes and enable or disable color output accordingly. Specifically, colors will be enabled if both \fBstdout\fP and \fBstderr\fP point to a TTY and the \fBTERM\fP environment variable is not set to "\fBdumb\fP". Pass \fB1\fP or \fBtrue\fP to \fB\-\-color\fP to force color output. Pass \fB0\fP or \fBfalse\fP to never output color codes.
.TP
\fB\-V\FP, \fB\-\-data\-version\fP
Print the Inno Setup data version of the installer and exit immediately.
The version printed using this option is the one stored in the setup file and can differ from the version printed with other actions as the stored data version is not always correct.
This option can be used to determine if a file is an Inno Setup installer without loading any compressed headers.
This option cannot be combined with any other action.
.TP
\fB\-\-default\-language\fP \fILANG\fP
Set a language as the default.
@ -116,11 +131,6 @@ With \fB\-\-collisions\=overwrite\fP (the default) this will change the choice o
When using the \fB\-\-collisions\=rename\fP option, \fB\-\-default\-language\fP chooses a language for which the files should keep the original name if possible.
.TP
\fB\-c\fP, \fB\-\-color\fP[=\fIENABLE\fP]
By default
.B innoextract
will try to detect if the terminal supports shell escape codes and enable or disable color output accordingly. Specifically, colors will be enabled if both \fBstdout\fP and \fBstderr\fP point to a TTY and the \fBTERM\fP environment variable is not set to "\fBdumb\fP". Pass \fB1\fP or \fBtrue\fP to \fB\-\-color\fP to force color output. Pass \fB0\fP or \fBfalse\fP to never output color codes.
.TP
\fB\-\-dump\fP
Don't convert Windows paths to UNIX paths and don't substitute constants in paths.

12
src/cli/extract.cpp

@ -845,6 +845,18 @@ void process_file(const fs::path & file, const extract_options & o) {
loader::offsets offsets;
offsets.load(ifs);
if(o.data_version) {
setup::version version;
ifs.seekg(offsets.header_offset);
version.load(ifs);
if(o.silent) {
std::cout << version << '\n';
} else {
std::cout << color::white << version << color::reset << '\n';
}
return;
}
#ifdef DEBUG
if(logger::debug) {
print_offsets(offsets);

1
src/cli/extract.hpp

@ -52,6 +52,7 @@ struct extract_options {
bool warn_unused; //!< Warn if there are unused files
bool data_version; //!< Print the data version
bool list; //!< List files
bool test; //!< Test files (but don't extract)
bool extract; //!< Extract files

17
src/cli/main.cpp

@ -138,6 +138,7 @@ int main(int argc, char * argv[]) {
("gog-game-id", "Determine the installer's GOG.com game ID")
("show-password", "Show password check information")
("check-password", "Abort if the password is incorrect")
("data-version,V", "Only print the data version")
;
po::options_description modifiers("Modifiers");
@ -413,6 +414,12 @@ int main(int argc, char * argv[]) {
o.gog = (options.count("gog") != 0);
o.gog_galaxy = (options.count("no-gog-galaxy") == 0);
o.data_version = (options.count("data-version") != 0);
if(o.data_version && explicit_action) {
log_error << "Combining --data-version with other options is not allowed";
return ExitUserError;
}
const std::vector<std::string> & files = options["setup-files"]
.as< std::vector<std::string> >();
@ -420,7 +427,7 @@ int main(int argc, char * argv[]) {
try {
BOOST_FOREACH(const std::string & file, files) {
process_file(file, o);
if(files.size() > 1) {
if(!o.data_version && files.size() > 1) {
std::cout << '\n';
}
}
@ -446,7 +453,9 @@ int main(int argc, char * argv[]) {
if(!logger::quiet || logger::total_errors || logger::total_warnings) {
progress::clear();
std::ostream & os = logger::quiet ? std::cerr : std::cout;
os << color::green << "Done" << color::reset << std::dec;
if(!o.data_version || logger::total_errors || logger::total_warnings) {
os << color::green << "Done" << color::reset << std::dec;
}
if(logger::total_errors || logger::total_warnings) {
os << " with ";
if(logger::total_errors) {
@ -463,7 +472,9 @@ int main(int argc, char * argv[]) {
<< color::reset;
}
}
os << '.' << std::endl;
if(logger::total_errors) {
os << '.' << std::endl;
}
}
return logger::total_errors == 0 ? ExitSuccess : ExitDataError;

Loading…
Cancel
Save