innoextract: Update to 1.5

This commit is contained in:
Alexey Pavlov
2015-10-20 10:54:42 +03:00
parent f56d97b508
commit cbdf0b6a65
7 changed files with 9 additions and 592 deletions

View File

@@ -1,9 +1,10 @@
# Maintainer: Alexey Pavlov <alexpux@gmail.com>
_realname=innoextract
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.4
pkgrel=2
pkgver=1.5
pkgrel=1
pkgdesc="A tool to extract installers created by Inno Setup (mingw-w64)."
arch=('any')
url="http://constexpr.org/innoextract/"
@@ -17,39 +18,22 @@ depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
"${MINGW_PACKAGE_PREFIX}-bzip2"
"${MINGW_PACKAGE_PREFIX}-libiconv")
options=('staticlibs' '!strip')
source=("http://downloads.sourceforge.net/${_realname}/${_realname}-${pkgver}.tar.gz"
fix-typo-in-comment.patch
fix-crash-on-startup.patch
dont-set-background.patch
fix-flickering-progress-bar.patch
fix-restoring-original-console-color.patch
fix-an-infinite-loop-with-truncated-LZMA-streams.patch)
sha1sums=('3fd3ac98c802c72a1f4ae5f6e6a5dca35747ff98'
'554408d4be410563828d2599db698f0f76cef51e'
'd35974339a83db0cd04c343d865075d99fc426ba'
'abebb02453cd1d60afee5f4fb19ad0dc53d09125'
'43454e4e6ef70cd635135e38ead7e596308986c0'
'665c7cbb712d88e0d6506b3de157d7fbf819c239'
'69798ae9a93e0f944201889b6b7000130a7af4d4')
source=("http://constexpr.org/innoextract/files/${_realname}-${pkgver}.tar.gz")
sha1sums=('cd3e3f68213c2730e9db4665b2997f5052f12af7')
prepare() {
cd "${srcdir}/${_realname}-${pkgver}"
patch -p1 -i ${srcdir}/fix-typo-in-comment.patch
patch -p1 -i ${srcdir}/fix-crash-on-startup.patch
patch -p1 -i ${srcdir}/dont-set-background.patch
patch -p1 -i ${srcdir}/fix-flickering-progress-bar.patch
patch -p1 -i ${srcdir}/fix-restoring-original-console-color.patch
patch -p1 -i ${srcdir}/fix-an-infinite-loop-with-truncated-LZMA-streams.patch
}
build() {
[[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}
#MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX="
MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
${MINGW_PREFIX}/bin/cmake.exe \
-Wno-dev \
-G"MSYS Makefiles" \
-DCMAKE_INSTALL_PREFIX=${pkgdir}${MINGW_PREFIX} \
-DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_STATIC_LIBS=OFF \
../${_realname}-${pkgver}
@@ -59,7 +43,7 @@ build() {
package() {
cd "${srcdir}/build-${MINGW_CHOST}"
make install
make DESTDIR=${pkgdir} install
install -Dm644 ${srcdir}/${_realname}-${pkgver}/README.md \
"${pkgdir}${MINGW_PREFIX}/share/doc/${_realname}/README.md"

View File

@@ -1,77 +0,0 @@
From 9e40d651cb6b59582d4ee7c3dba10d8f66568dbd Mon Sep 17 00:00:00 2001
From: Daniel Scharrer <daniel@constexpr.org>
Date: Mon, 13 May 2013 21:32:25 +0200
Subject: [PATCH] Don't set the background color under Windows
... unless the current background color is too bright.
---
src/util/console.cpp | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/src/util/console.cpp b/src/util/console.cpp
index 72a2830..0f052c0 100644
--- a/src/util/console.cpp
+++ b/src/util/console.cpp
@@ -46,6 +46,7 @@
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
#include "util/output.hpp"
@@ -193,24 +194,41 @@ void init(is_enabled color, is_enabled progress) {
// Initialize color output
+ shell_command * const all_colors[] = {
+ &reset, &current,
+ &black, &red, &green, &yellow, &blue, &magenta, &cyan, &white,
+ &dim_black, &dim_red, &dim_green, &dim_yellow,
+ &dim_blue, &dim_magenta, &dim_cyan, &dim_white,
+ };
+
if(color == disable || (color == automatic && !is_tty)) {
- #if defined(_WIN32)
- reset.command = boost::uint16_t(-1);
- #else
- reset.command = "";
- #endif
-
- black = red = green = yellow = blue = magenta = cyan = white = reset;
- dim_black = dim_red = dim_green = dim_yellow = reset;
- dim_blue = dim_magenta = dim_cyan = dim_white = reset;
- current = reset;
+ BOOST_FOREACH(shell_command * color, all_colors) {
+ #if defined(_WIN32)
+ color->command = boost::uint16_t(-1);
+ #else
+ color->command = "";
+ #endif
+ }
} else {
+
#if defined(_WIN32)
+ // Preserve the original background color if it isn't too bright.
+ if(!(original_color.command & (COMMON_LVB_REVERSE_VIDEO|BACKGROUND_INTENSITY))) {
+ boost::uint16_t bgmask = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
+ if((color & bgmask) != bgmask) {
+ boost::uint16_t bg = original_color.command & bgmask;
+ BOOST_FOREACH(shell_command * color, all_colors) {
+ color->command |= bg;
+ }
+ }
+ }
+ // Force dim_white as the default color under Windows, restore original color on exit.
std::cout << reset;
std::atexit(restore_color);
#endif
+
}
}
--
1.9.1

View File

@@ -1,49 +0,0 @@
From b87d69182a637e3cb55a3d792594d842be8ace0d Mon Sep 17 00:00:00 2001
From: Daniel Scharrer <daniel@constexpr.org>
Date: Wed, 22 May 2013 15:22:34 +0200
Subject: [PATCH] Fix an infinite loop with truncated LZMA streams
---
src/stream/file.cpp | 2 ++
src/stream/lzma.cpp | 5 ++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/stream/file.cpp b/src/stream/file.cpp
index 42d6614..64c266c 100644
--- a/src/stream/file.cpp
+++ b/src/stream/file.cpp
@@ -69,6 +69,8 @@ file_reader::pointer file_reader::get(base_type & base, const file & file,
result->push(restrict(base, file.size));
+ result->exceptions(std::ios_base::badbit);
+
return pointer(result.release());
}
diff --git a/src/stream/lzma.cpp b/src/stream/lzma.cpp
index 695c799..a771070 100644
--- a/src/stream/lzma.cpp
+++ b/src/stream/lzma.cpp
@@ -56,7 +56,6 @@ static lzma_stream * init_raw_lzma_stream(lzma_vli filter, lzma_options_lzma & o
bool lzma_decompressor_impl_base::filter(const char * & begin_in, const char * end_in,
char * & begin_out, char * end_out, bool flush) {
- (void)flush;
lzma_stream * strm = static_cast<lzma_stream *>(stream);
@@ -68,6 +67,10 @@ bool lzma_decompressor_impl_base::filter(const char * & begin_in, const char * e
lzma_ret ret = lzma_code(strm, LZMA_RUN);
+ if(flush && ret == LZMA_BUF_ERROR && strm->avail_out > 0) {
+ throw lzma_error("truncated lzma stream", ret);
+ }
+
begin_in = reinterpret_cast<const char *>(strm->next_in);
begin_out = reinterpret_cast<char *>(strm->next_out);
--
1.9.1

View File

@@ -1,49 +0,0 @@
From b52c4a0699b3801b96cd25567843faa6ab57daf3 Mon Sep 17 00:00:00 2001
From: Daniel Scharrer <daniel@constexpr.org>
Date: Mon, 13 May 2013 20:47:16 +0200
Subject: [PATCH] Fix crash on startup under Windows
Don't assume that the runtime initializes the __wargv global variable.
---
src/util/windows.cpp | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/util/windows.cpp b/src/util/windows.cpp
index 7ee7caf..87cbaa9 100644
--- a/src/util/windows.cpp
+++ b/src/util/windows.cpp
@@ -27,6 +27,7 @@
#include <clocale>
#include <windows.h>
+#include <shellapi.h>
#include <boost/filesystem/path.hpp>
@@ -52,9 +53,11 @@ int main() {
std::setlocale(LC_ALL, "");
- // Get the UTF-16 command-line parameters and convert them to UTF-8 ourself.
- int argc = __argc;
- wchar_t ** wargv = __wargv;
+ // Emulate wmain() as it's nonstandard and not supported by MinGW.
+ int argc = 0;
+ wchar_t ** wargv = CommandLineToArgvW(GetCommandLineW(), &argc);
+
+ // Convert the UTF-16 command-line parameters to UTF-8 ourself.
char ** argv = new char *[argc + 1];
argv[argc] = NULL;
for(int i = 0; i < argc; i++) {
@@ -63,6 +66,8 @@ int main() {
WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, argv[i], n, NULL, NULL);
}
+ LocalFree(wargv);
+
// Tell boost::filesystem to interpret our path strings as UTF-8.
std::locale global_locale = std::locale();
std::locale utf8_locale(global_locale, new utf8_codecvt);
--
1.9.1

View File

@@ -1,292 +0,0 @@
From a144d3fff0e94e19acc098ee4b35503aaeb752ae Mon Sep 17 00:00:00 2001
From: Daniel Scharrer <daniel@constexpr.org>
Date: Tue, 14 May 2013 20:10:56 +0200
Subject: [PATCH] Fix flickering progress bar under Windows
---
src/cli/main.cpp | 68 +++++++++++++++++++++++++++-------------------------
src/util/console.cpp | 65 +++++++++++++++++++++++++++++--------------------
src/util/console.hpp | 13 +++++++---
3 files changed, 84 insertions(+), 62 deletions(-)
diff --git a/src/cli/main.cpp b/src/cli/main.cpp
index b4c72aa..3f90291 100644
--- a/src/cli/main.cpp
+++ b/src/cli/main.cpp
@@ -326,49 +326,48 @@ static void process_file(const fs::path & file, const options & o) {
}
// Print filename and size
- if(!o.silent) {
+ if(o.list) {
extract_progress.clear();
- std::cout << " - ";
- bool named = false;
- BOOST_FOREACH(const file_t & path, output_names) {
- if(named) {
- std::cout << ", ";
+ if(!o.silent) {
+
+ std::cout << " - ";
+ bool named = false;
+ BOOST_FOREACH(const file_t & path, output_names) {
+ if(named) {
+ std::cout << ", ";
+ }
+ std::cout << '"' << color::white << path.first << color::reset << '"';
+ if(!info.files[path.second].languages.empty()) {
+ std::cout << " [" << color::green << info.files[path.second].languages
+ << color::reset << "]";
+ }
+ named = true;
}
- std::cout << '"' << color::white << path.first << color::reset << '"';
- if(!info.files[path.second].languages.empty()) {
- std::cout << " [" << color::green << info.files[path.second].languages
- << color::reset << "]";
+ if(!named) {
+ std::cout << color::white << "unnamed file" << color::reset;
}
- named = true;
- }
- if(!named) {
- std::cout << color::white << "unnamed file" << color::reset;
- }
- if(!o.quiet) {
- if(logger::debug) {
- std::cout << " @ " << print_hex(file.offset);
+ if(!o.quiet) {
+ if(logger::debug) {
+ std::cout << " @ " << print_hex(file.offset);
+ }
+ std::cout << " (" << color::dim_cyan << print_bytes(file.size)
+ << color::reset << ")";
+ }
+ std::cout << '\n';
+
+ } else {
+ BOOST_FOREACH(const file_t & path, output_names) {
+ std::cout << color::white << path.first << color::reset << '\n';
}
- std::cout << " (" << color::dim_cyan << print_bytes(file.size)
- << color::reset << ")";
- }
- std::cout << '\n';
- if(o.extract || o.test) {
- std::cout.flush();
}
- extract_progress.update(0, true);
-
- } else if(o.list) {
- extract_progress.clear();
- BOOST_FOREACH(const file_t & path, output_names) {
- std::cout << color::white << path.first << color::reset << '\n';
- }
- if(o.extract || o.test) {
+ bool updated = extract_progress.update(0, true);
+ if(!updated && (o.extract || o.test)) {
std::cout.flush();
}
- extract_progress.update(0, true);
+
}
if(!o.extract && !o.test) {
@@ -568,6 +567,9 @@ int main(int argc, char * argv[]) {
if(!o.extract && !o.test) {
progress::set_enabled(false);
}
+ if(!o.silent) {
+ o.list = true;
+ }
// Additional actions.
o.filenames.set_expand(options.count("dump") == 0);
diff --git a/src/util/console.cpp b/src/util/console.cpp
index 0f052c0..9129056 100644
--- a/src/util/console.cpp
+++ b/src/util/console.cpp
@@ -184,13 +184,6 @@ void init(is_enabled color, is_enabled progress) {
show_progress = true;
}
#endif
- #if defined(_WIN32)
- if(show_progress) {
- // Buffer output so that the progress bar won't flicker (we flush after each update)
- static char buffer[BUFSIZ];
- std::setbuf(stdout, buffer);
- }
- #endif
// Initialize color output
@@ -214,7 +207,7 @@ void init(is_enabled color, is_enabled progress) {
} else {
#if defined(_WIN32)
- // Preserve the original background color if it isn't too bright.
+ // Preserve the original background color if it isn't too bright
if(!(original_color.command & (COMMON_LVB_REVERSE_VIDEO|BACKGROUND_INTENSITY))) {
boost::uint16_t bgmask = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
if((color & bgmask) != bgmask) {
@@ -224,7 +217,7 @@ void init(is_enabled color, is_enabled progress) {
}
}
}
- // Force dim_white as the default color under Windows, restore original color on exit.
+ // Force dim_white as the default color under Windows, restore original color on exit
std::cout << reset;
std::atexit(restore_color);
#endif
@@ -288,7 +281,7 @@ static int get_screen_width() {
static bool progress_cleared = true;
-int progress::clear() {
+int progress::clear(bool reset_only) {
int width = get_screen_width();
@@ -298,18 +291,37 @@ int progress::clear() {
#if defined(_WIN32)
- // Overwrite the current line with whitespace
-
- static std::string buffer;
- static int last_width = 0;
- if(width != last_width) {
- size_t cwidth = size_t(std::max(width, 1) - 1);
- buffer.resize(cwidth, ' ');
- last_width = width;
+ if(reset_only) {
+
+ /*
+ * If we overwrite the whole line with spaces, windows console likes to draw
+ * the empty line, even if it will be overwritten in the same flush(),
+ * causing the progress bar to flicker when updated.
+ * To work around this, don't actually clear the line if we are just going to
+ * overwrite it anyway.
+ * The progress bar still flickers when there is other output printed, but
+ * it seems there is no way around that without using the console API to manually
+ * scroll the output.
+ */
+
+ std::cout << '\r';
+
+ } else {
+
+ // Overwrite the current line with whitespace
+
+ static std::string buffer;
+ static int last_width = 0;
+ if(width != last_width) {
+ size_t cwidth = size_t(std::max(width, 1) - 1);
+ buffer.resize(cwidth, ' ');
+ last_width = width;
+ }
+
+ std::cout << '\r' << buffer << '\r';
+
}
- std::cout << '\r' << buffer << '\r';
-
#else
// Use the ANSI/VT100 control sequence to clear the current line
@@ -329,7 +341,7 @@ void progress::show(float value, const std::string & label) {
return;
}
- int width = clear();
+ int width = clear(true);
std::ios_base::fmtflags flags = std::cout.flags();
@@ -366,7 +378,7 @@ void progress::show_unbounded(float value, const std::string & label) {
return;
}
- int width = clear();
+ int width = clear(true);
std::ios_base::fmtflags flags = std::cout.flags();
@@ -402,10 +414,10 @@ progress::progress(boost::uint64_t max, bool show_rate)
start_time(boost::posix_time::microsec_clock::universal_time()),
last_status(-1.f), last_time(0), last_rate(0.f) { }
-void progress::update(boost::uint64_t delta, bool force) {
+bool progress::update(boost::uint64_t delta, bool force) {
if(!show_progress) {
- return;
+ return false;
}
force = force || progress_cleared;
@@ -417,7 +429,7 @@ void progress::update(boost::uint64_t delta, bool force) {
status = float(std::min(value, max)) / float(max);
status = float(size_t(1000.f * status)) * (1.f / 1000.f);
if(!force && status == last_status) {
- return;
+ return false;
}
}
@@ -430,7 +442,7 @@ void progress::update(boost::uint64_t delta, bool force) {
const boost::uint64_t update_interval = 50000;
#endif
if(!force && time - last_time < update_interval) {
- return;
+ return false;
}
last_time = time;
@@ -461,6 +473,7 @@ void progress::update(boost::uint64_t delta, bool force) {
show_unbounded(status, label.str());
}
+ return true;
}
void progress::set_enabled(bool enable) {
diff --git a/src/util/console.hpp b/src/util/console.hpp
index 1f8354c..4c6875d 100644
--- a/src/util/console.hpp
+++ b/src/util/console.hpp
@@ -132,8 +132,10 @@ public:
* maximum set in the constructor, the bar will be full.
* \param force Force updating the progress bar. Normally, the progress bar. Otherwise,
* updates are rate-limited and small deltas are not displayed immediately.
+ *
+ * \return true if the progres bar was updated
*/
- void update(boost::uint64_t delta = 0, bool force = false);
+ bool update(boost::uint64_t delta = 0, bool force = false);
/*!
* Draw a bounded progress bar (with a maximum).
@@ -151,8 +153,13 @@ public:
*/
static void show_unbounded(float value, const std::string & label = std::string());
- //! Clear any progress bar to make way for other output.
- static int clear();
+ /*!
+ * Clear any progress bar to make way for other output.
+ *
+ * \param reset_only Only reset the cursor if cleaning the line is expensive.
+ * This should be used if the whole line will be written anyway.
+ */
+ static int clear(bool reset_only = false);
//! Enable or disable the progress bar.
static void set_enabled(bool enable);
--
1.9.1

View File

@@ -1,75 +0,0 @@
From 507f4c178f8bb085afe830e0772ce79b1b8e771a Mon Sep 17 00:00:00 2001
From: Daniel Scharrer <daniel@constexpr.org>
Date: Tue, 14 May 2013 21:00:36 +0200
Subject: [PATCH] Fix restoring original console color under Windows
---
src/util/console.cpp | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/util/console.cpp b/src/util/console.cpp
index 9129056..f86a4f1 100644
--- a/src/util/console.cpp
+++ b/src/util/console.cpp
@@ -118,10 +118,17 @@ shell_command dim_cyan = { FOREGROUND_BLUE | FOREGROUND_GREEN };
shell_command dim_white = { FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE };
shell_command reset = dim_white;
-shell_command original_color;
+boost::uint16_t original_color = boost::uint16_t(-1);
static void restore_color() {
- std::cout << original_color;
+ if(original_color != boost::uint16_t(-1) && console_handle) {
+ SetConsoleTextAttribute(console_handle, original_color);
+ }
+}
+static BOOL WINAPI restore_color_handler(DWORD type) {
+ (void)type;
+ restore_color();
+ return FALSE;
}
#else
@@ -163,7 +170,7 @@ void init(is_enabled color, is_enabled progress) {
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO info;
if(console_handle && GetConsoleScreenBufferInfo(console_handle, &info)) {
- original_color.command = info.wAttributes;
+ original_color = info.wAttributes;
} else {
is_tty = false;
color = disable;
@@ -208,10 +215,10 @@ void init(is_enabled color, is_enabled progress) {
#if defined(_WIN32)
// Preserve the original background color if it isn't too bright
- if(!(original_color.command & (COMMON_LVB_REVERSE_VIDEO|BACKGROUND_INTENSITY))) {
+ if(!(original_color & (COMMON_LVB_REVERSE_VIDEO|BACKGROUND_INTENSITY))) {
boost::uint16_t bgmask = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
if((color & bgmask) != bgmask) {
- boost::uint16_t bg = original_color.command & bgmask;
+ boost::uint16_t bg = original_color & bgmask;
BOOST_FOREACH(shell_command * color, all_colors) {
color->command |= bg;
}
@@ -220,6 +227,7 @@ void init(is_enabled color, is_enabled progress) {
// Force dim_white as the default color under Windows, restore original color on exit
std::cout << reset;
std::atexit(restore_color);
+ SetConsoleCtrlHandler(restore_color_handler, TRUE);
#endif
}
@@ -324,6 +332,8 @@ int progress::clear(bool reset_only) {
#else
+ (void)reset_only;
+
// Use the ANSI/VT100 control sequence to clear the current line
std::cout << "\33[2K\r";
--
1.9.1

View File

@@ -1,25 +0,0 @@
From 7358c530490f9595444fcef3e1352905a6b2a366 Mon Sep 17 00:00:00 2001
From: Daniel Scharrer <daniel@constexpr.org>
Date: Thu, 11 Apr 2013 17:23:23 +0200
Subject: [PATCH] Fix typo in comment
---
src/util/windows.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/windows.cpp b/src/util/windows.cpp
index e25d4bb..7ee7caf 100644
--- a/src/util/windows.cpp
+++ b/src/util/windows.cpp
@@ -52,7 +52,7 @@ int main() {
std::setlocale(LC_ALL, "");
- // Get the UTF-16 command-line parameters and convert it them to UTF-8 ourself.
+ // Get the UTF-16 command-line parameters and convert them to UTF-8 ourself.
int argc = __argc;
wchar_t ** wargv = __wargv;
char ** argv = new char *[argc + 1];
--
1.9.1