From 984c29c1e21e2c409a8c48df73007a67e8dee1eb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 24 Nov 2013 09:44:37 +0530 Subject: [PATCH] Get rid of the workaround for mtpz debug message by compiling libmtp with --disable-mtpz --- setup/installer/linux/freeze2.py | 4 ++-- src/calibre/devices/mtp/unix/libmtp.c | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/setup/installer/linux/freeze2.py b/setup/installer/linux/freeze2.py index 047938df41..13da77f8db 100644 --- a/setup/installer/linux/freeze2.py +++ b/setup/installer/linux/freeze2.py @@ -21,10 +21,11 @@ SITE_PACKAGES = ['PIL', 'dateutil', 'dns', 'PyQt4', 'mechanize', QTDIR = '/usr/lib/qt4' QTDLLS = ('QtCore', 'QtGui', 'QtNetwork', 'QtSvg', 'QtXml', 'QtWebKit', 'QtDBus', 'QtXmlPatterns') MAGICK_PREFIX = '/usr' +is64bit = platform.architecture()[0] == '64bit' binary_includes = [ '/usr/bin/pdftohtml', '/usr/bin/pdfinfo', - '/usr/lib/libusb-1.0.so.0', + '/usr/lib/libusb-1.0.so.0' if is64bit else '/lib/libusb-1.0.so.0', '/usr/lib/libmtp.so.9', '/usr/lib/libglib-2.0.so.0', '/usr/bin/pdftoppm', @@ -69,7 +70,6 @@ binary_includes = [ ] binary_includes += [os.path.join(QTDIR, 'lib%s.so.4'%x) for x in QTDLLS] -is64bit = platform.architecture()[0] == '64bit' arch = 'x86_64' if is64bit else 'i686' diff --git a/src/calibre/devices/mtp/unix/libmtp.c b/src/calibre/devices/mtp/unix/libmtp.c index 0191e04ef1..b08cb7da68 100644 --- a/src/calibre/devices/mtp/unix/libmtp.c +++ b/src/calibre/devices/mtp/unix/libmtp.c @@ -725,18 +725,18 @@ initlibmtp(void) { // Redirect stdout to get rid of the annoying message about mtpz. Really, // who designs a library without anyway to control/redirect the debugging - // output, and hardcoded paths that cannot be changed? - int bak, new; - fprintf(stdout, "\n"); // This is needed, without it, for some odd reason the code below causes stdout to buffer all output after it is restored, rather than using line buffering, and setlinebuf does not work. - fflush(stdout); - bak = dup(STDOUT_FILENO); - new = open("/dev/null", O_WRONLY); - dup2(new, STDOUT_FILENO); - close(new); + // output, and hardcoded paths that cannot be changed? Compiling libmtp without the crypt use flag disables mtpz support in libmtp + /* int bak, new; */ + /* fprintf(stdout, "\n"); // This is needed, without it, for some odd reason the code below causes stdout to buffer all output after it is restored, rather than using line buffering, and setlinebuf does not work. */ + /* fflush(stdout); */ + /* bak = dup(STDOUT_FILENO); */ + /* new = open("/dev/null", O_WRONLY); */ + /* dup2(new, STDOUT_FILENO); */ + /* close(new); */ LIBMTP_Init(); - fflush(stdout); - dup2(bak, STDOUT_FILENO); - close(bak); + /* fflush(stdout); */ + /* dup2(bak, STDOUT_FILENO); */ + /* close(bak); */ LIBMTP_Set_Debug(LIBMTP_DEBUG_NONE);