From d7b691b6f53a855955efd6dc98b654746319134f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 30 Dec 2016 15:01:30 +0100 Subject: [PATCH] all: remove --check-for-updates command line option & dependency on CURL --- README.Windows.md | 2 +- README.md | 2 - Rakefile | 3 +- ac/curl.m4 | 32 ------ build-config.in | 2 - configure.ac | 1 - debian-upstream/control | 1 - mkvtoolnix.spec | 2 +- rake.d/target.rb | 1 - src/common/cli_parser.cpp | 3 - src/common/command_line.cpp | 20 ---- src/common/curl.cpp | 109 ------------------- src/common/curl.h | 52 --------- src/common/version.cpp | 69 +----------- src/common/version.h | 5 - src/merge/mkvmerge.cpp | 3 - tools/macos/build.sh | 10 -- tools/windows/setup_cross_compilation_env.sh | 2 +- 18 files changed, 5 insertions(+), 314 deletions(-) delete mode 100644 ac/curl.m4 delete mode 100644 src/common/curl.cpp delete mode 100644 src/common/curl.h diff --git a/README.Windows.md b/README.Windows.md index 034f52501..d177d0bae 100644 --- a/README.Windows.md +++ b/README.Windows.md @@ -89,7 +89,7 @@ one, and increase `JOBS` if you have more than one core): cd $HOME/mxe make MXE_TARGETS=x86_64-w64-mingw32.static MXE_PLUGIN_DIRS=plugins/gcc6 \ JOBS=2 \ - gettext libiconv zlib boost curl file flac lzo ogg pthreads vorbis \ + gettext libiconv zlib boost file flac lzo ogg pthreads vorbis \ qtbase qttranslations qtwinextras Append the installation directory to your `PATH` variable: diff --git a/README.md b/README.md index 65f4e5e93..ddab4c071 100644 --- a/README.md +++ b/README.md @@ -121,8 +121,6 @@ built. These include: - [libMagic](http://www.darwinsys.com/file/) from the "file" package for automatic content type detection -- [libcurl](http://curl.haxx.se/) for online update checks - ## 2.3. Building libEBML and libMatroska This is optional as MKVToolNix comes with its own set of the diff --git a/Rakefile b/Rakefile index b13771848..10c8d6830 100644 --- a/Rakefile +++ b/Rakefile @@ -128,7 +128,7 @@ def setup_globals cxxflags = "#{cflags_common} #{c(:STD_CXX)}" cxxflags += " -Wnon-virtual-dtor -Woverloaded-virtual -Wextra -Wno-missing-field-initializers #{c(:WNO_MAYBE_UNINITIALIZED)}" - cxxflags += " #{c(:QT_CFLAGS)} #{c(:BOOST_CPPFLAGS)} #{c(:CURL_CFLAGS)} #{c(:USER_CXXFLAGS)}" + cxxflags += " #{c(:QT_CFLAGS)} #{c(:BOOST_CPPFLAGS)}" ldflags = "" ldflags += " -Llib/libebml/src -Llib/libmatroska/src" if c?(:EBML_MATROSKA_INTERNAL) @@ -866,7 +866,6 @@ $common_libs = [ :pugixml, :intl, :iconv, - :curl, :boost_regex, :boost_filesystem, :boost_system, diff --git a/ac/curl.m4 b/ac/curl.m4 deleted file mode 100644 index 5a26f4923..000000000 --- a/ac/curl.m4 +++ /dev/null @@ -1,32 +0,0 @@ -dnl -dnl Check for libcurl -dnl - -curl_found=no -AC_ARG_WITH([curl], AC_HELP_STRING([--without-curl], [do not build with CURL support]), - [ with_curl=${withval} ], [ with_curl=yes ]) -AC_ARG_WITH(curl_config, - AC_HELP_STRING([--with-curl-config=prog],[use prog instead of looking for curl-config]), - [ CURL_CONFIG="$with_curl_config" ],) - -if test "x$with_curl" != "xno"; then - AC_PATH_TOOL(CURL_CONFIG, curl-config, no) - - if test x"$CURL_CONFIG" != "xno" ; then - curl_found=yes - CURL_CFLAGS="`"$CURL_CONFIG" --cflags`" - CURL_LIBS="`"$CURL_CONFIG" --libs`" - - else - PKG_CHECK_MODULES([CURL], [libcurl], [curl_found=yes]) - fi -fi - -if test "$curl_found" = "yes"; then - opt_features_yes="$opt_features_yes\n * online update checks (via libcurl)" - AC_DEFINE(HAVE_CURL_EASY_H, 1, [define if libcurl is found via pkg-config]) -else - opt_features_no="$opt_features_no\n * online update checks (via libcurl)" - CURL_CFLAGS="" - CURL_LIBS="" -fi diff --git a/build-config.in b/build-config.in index 213912c81..80285d4c1 100644 --- a/build-config.in +++ b/build-config.in @@ -75,8 +75,6 @@ BOOST_FILESYSTEM_LIB = @BOOST_FILESYSTEM_LIB@ BOOST_LDFLAGS = @BOOST_LDFLAGS@ BOOST_REGEX_LIB = @BOOST_REGEX_LIB@ BOOST_SYSTEM_LIB = @BOOST_SYSTEM_LIB@ -CURL_CFLAGS = @CURL_CFLAGS@ -CURL_LIBS = @CURL_LIBS@ DEBUG_CFLAGS = @DEBUG_CFLAGS@ DOCBOOK_MANPAGES_STYLESHEET = @DOCBOOK_MANPAGES_STYLESHEET@ DOCBOOK_ROOT = @DOCBOOK_ROOT@ diff --git a/configure.ac b/configure.ac index 4bb9829fa..f08d61b46 100644 --- a/configure.ac +++ b/configure.ac @@ -34,7 +34,6 @@ m4_include(ac/zlib.m4) m4_include(ac/qt5.m4) m4_include(ac/gnurx.m4) m4_include(ac/magic.m4) -m4_include(ac/curl.m4) m4_include(ac/ax_boost_base.m4) m4_include(ac/ax_boost_check_headers.m4) m4_include(ac/ax_boost_filesystem.m4) diff --git a/debian-upstream/control b/debian-upstream/control index f7e5e5671..527d39882 100644 --- a/debian-upstream/control +++ b/debian-upstream/control @@ -9,7 +9,6 @@ Build-Depends: ruby (>= 1.9) | ruby1.9 | ruby1.9.1 | ruby1.9.3, libbz2-dev, liblzo2-dev, zlib1g-dev, libmagic-dev, libflac-dev, libogg-dev, libvorbis-dev, - libcurl4-gnutls-dev | libcurl4-openssl-dev, libboost-dev (>= 1.46), libboost-filesystem-dev (>= 1.46), libboost-regex-dev (>= 1.46), libboost-date-time-dev (>= 1.46), libboost-system-dev (>= 1.46), qtbase5-dev, qtbase5-dev-tools, diff --git a/mkvtoolnix.spec b/mkvtoolnix.spec index 36697d3a8..ec5642864 100644 --- a/mkvtoolnix.spec +++ b/mkvtoolnix.spec @@ -9,7 +9,7 @@ Release: 1 Summary: Tools to create, alter and inspect Matroska files Source: %{name}-%{version}.tar.xz -BuildRequires: fdupes, file-devel, flac, flac-devel, libcurl-devel, libogg-devel, libstdc++-devel, libvorbis-devel, make, pkgconfig, zlib-devel +BuildRequires: fdupes, file-devel, flac, flac-devel, libogg-devel, libstdc++-devel, libvorbis-devel, make, pkgconfig, zlib-devel %if 0%{?centos} && 0%{?centos} < 7 BuildRequires: devtoolset-1.1-gcc-c++ >= 4.6.3 diff --git a/rake.d/target.rb b/rake.d/target.rb index 698c1ffcd..f672a6232 100644 --- a/rake.d/target.rb +++ b/rake.d/target.rb @@ -124,7 +124,6 @@ class Target @libraries += list.collect do |entry| case entry when nil then nil - when :curl then c(:CURL_LIBS) when :magic then c(:MAGIC_LIBS) when :flac then c(:FLAC_LIBS) when :iconv then c(:ICONV_LIBS) diff --git a/src/common/cli_parser.cpp b/src/common/cli_parser.cpp index fbcabb436..b8c4ad709 100644 --- a/src/common/cli_parser.cpp +++ b/src/common/cli_parser.cpp @@ -183,9 +183,6 @@ cli_parser_c::add_common_options() { OPT("@option-file.json", YT("Reads additional command line options from the specified JSON file (see man page).")); OPT("h|help", YT("Show this help.")); OPT("V|version", YT("Show version information.")); -#if defined(HAVE_CURL_EASY_H) - OPT("check-for-updates", YT("Check online for the latest release.")); -#endif // defined(HAVE_CURL_EASY_H) } #undef OPT diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp index d31ca21c1..9a319ce20 100644 --- a/src/common/command_line.cpp +++ b/src/common/command_line.cpp @@ -344,26 +344,6 @@ handle_common_cli_args(std::vector &args, } else if ((args[i] == "-h") || (args[i] == "-?") || (args[i] == "--help")) usage(); -#if defined(HAVE_CURL_EASY_H) - else if (args[i] == "--check-for-updates") { - mtx_release_version_t rel = get_latest_release_version(); - if (!rel.latest_source.valid) - mxerror(boost::format(Y("The update information could not be retrieved from %1%.\n")) % MTX_VERSION_CHECK_URL); - - std::vector keys; - brng::push_back(keys, rel.urls | badap::map_keys | badap::filtered(+[](std::string const &key) { return key != "general"; })); - brng::sort(keys); - - std::string urls; - for (auto &key : keys) - urls += key + "_download_url=" + rel.urls[key] + "\n"; - - mxinfo(boost::format("version_check_url=%1%\nrunning_version=%2%\navailable_version=%3%\ndownload_url=%4%\n%5%") - % MTX_VERSION_CHECK_URL % rel.current_version.to_string() % rel.latest_source.to_string() % rel.urls["general"] % urls); - mxexit(rel.current_version < rel.latest_source ? 1 : 0); - } -#endif // defined(HAVE_CURL_EASY_H) - else ++i; } diff --git a/src/common/curl.cpp b/src/common/curl.cpp deleted file mode 100644 index 2240004ec..000000000 --- a/src/common/curl.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - mkvmerge -- utility for splicing together matroska files - from component media subtypes - - Distributed under the GPL v2 - see the file COPYING for details - or visit http://www.gnu.org/copyleft/gpl.html - - even easier interface to CURL - - Written by Moritz Bunkus . -*/ - -#include "config.h" - -#if defined(HAVE_CURL_EASY_H) - -# include "common/common_pch.h" - -# include "common/curl.h" -# include "common/strings/parsing.h" - -# include - -static size_t -curl_write_data_cb(void *buffer, - size_t size, - size_t nmemb, - void *user_data) { - static_cast(user_data)->add_data(std::string(static_cast(buffer), size * nmemb)); - return size * nmemb; -} - -static size_t -curl_header_cb(void *buffer, - size_t size, - size_t nmemb, - void *user_data) { - static_cast(user_data)->parse_header(std::string(static_cast(buffer), size * nmemb)); - return size * nmemb; -} - -url_retriever_c::url_retriever_c() - : m_connect_timeout(10) - , m_download_timeout(0) - , m_total_size(-1) - , m_debug{"curl|url_retriever"} -{ -} - -url_retriever_c & -url_retriever_c::set_timeout(int connect_timeout, - int download_timeout) { - m_connect_timeout = connect_timeout; - m_download_timeout = download_timeout; - return *this; -} - -url_retriever_c & -url_retriever_c::set_progress_cb(progress_cb_t const &progress_cb) { - m_progress_cb = progress_cb; - return *this; -} - -CURLcode -url_retriever_c::retrieve(std::string const &url, - std::string &data) { - m_data = &data; - m_total_size = -1; - - curl_global_init(CURL_GLOBAL_ALL); - CURL *handle = curl_easy_init(); - - curl_easy_setopt(handle, CURLOPT_VERBOSE, 0); - curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 1); - curl_easy_setopt(handle, CURLOPT_TIMEOUT, m_download_timeout); - curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, m_connect_timeout); - curl_easy_setopt(handle, CURLOPT_URL, url.c_str()); - curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curl_write_data_cb); - curl_easy_setopt(handle, CURLOPT_WRITEDATA, this); - curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, curl_header_cb); - curl_easy_setopt(handle, CURLOPT_HEADERDATA, this); - - CURLcode result = curl_easy_perform(handle); - - curl_easy_cleanup(handle); - - return result; -} - -void -url_retriever_c::add_data(std::string const &data) { - *m_data += data; - - mxdebug_if(m_debug, boost::format("Data received: %1% bytes, now %2% total\n") % data.size() % m_data->size()); - - if (m_progress_cb) - m_progress_cb(m_data->size(), m_total_size); -} - -void -url_retriever_c::parse_header(std::string const &header) { - boost::smatch matches; - if (boost::regex_search(header, matches, boost::regex("^content-length\\s*:\\s*(\\d+)", boost::regex::perl | boost::regex::icase))) - parse_number(matches[1].str(), m_total_size); - mxdebug_if(m_debug, boost::format("Header received: %1% total size: %2%\n") % header % m_total_size); -} - -#endif // defined(HAVE_CURL_EASY_H) diff --git a/src/common/curl.h b/src/common/curl.h deleted file mode 100644 index d76b69eec..000000000 --- a/src/common/curl.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - mkvmerge -- utility for splicing together matroska files - from component media subtypes - - Distributed under the GPL v2 - see the file COPYING for details - or visit http://www.gnu.org/copyleft/gpl.html - - even easier interface to CURL - - Written by Moritz Bunkus . -*/ - -#ifndef MTX_COMMON_CURL_H -# define MTX_COMMON_CURL_H - -# include "common/common_pch.h" - -# if defined(HAVE_CURL_EASY_H) - -# if defined(SYS_WINDOWS) -# include -# endif // defined(SYS_WINDOWS) -# include -# include - -class url_retriever_c { -public: - using progress_cb_t = std::function; - -protected: - progress_cb_t m_progress_cb; - std::string *m_data; - int m_connect_timeout, m_download_timeout; - int64_t m_total_size; - debugging_option_c m_debug; - -public: - url_retriever_c(); - - url_retriever_c &set_timeout(int connect_timeout = 10, int download_timeout = 0); - url_retriever_c &set_progress_cb(progress_cb_t const &progress_cb); - - CURLcode retrieve(std::string const &url, std::string &data); - - void add_data(std::string const &data); - void parse_header(std::string const &header); -}; - -# endif // defined(HAVE_CURL_EASY_H) - -#endif // MTX_COMMON_CURL_H diff --git a/src/common/version.cpp b/src/common/version.cpp index 178db4448..ad6133973 100644 --- a/src/common/version.cpp +++ b/src/common/version.cpp @@ -13,13 +13,6 @@ #include "common/common_pch.h" -#if defined(HAVE_CURL_EASY_H) -# include - -# include "common/compression.h" -# include "common/curl.h" -#endif // defined(HAVE_CURL_EASY_H) - #include "common/debugging.h" #include "common/strings/formatting.h" #include "common/strings/parsing.h" @@ -173,7 +166,7 @@ parse_latest_release_version(mtx::xml::document_cptr const &doc) { for (auto package : std::vector{ "installer", "portable" }) release.urls[std::string{"windows_"} + arch + "_" + package] = doc->select_single_node((std::string{"/mkvtoolnix-releases/latest-windows-binary/"} + package + "-url/" + arch).c_str()).node().child_value(); - if (debugging_c::requested("version_check|curl")) { + if (debugging_c::requested("version_check")) { std::stringstream urls; brng::for_each(release.urls, [&urls](auto const &kv) { urls << " " << kv.first << ":" << kv.second; }); mxdebug(boost::format("update check: current %1% latest source %2% latest winpre %3% URLs%4%\n") @@ -182,63 +175,3 @@ parse_latest_release_version(mtx::xml::document_cptr const &doc) { return release; } - -#if defined(HAVE_CURL_EASY_H) -static mtx::xml::document_cptr -retrieve_and_parse_xml(std::string const &url) { - bool debug = debugging_c::requested("version_check|releases_info|curl"); - - std::string data; - auto result = url_retriever_c().set_timeout(10, 20).retrieve(url, data); - - if (0 != result) { - mxdebug_if(debug, boost::format("CURL error for %2%: %1%\n") % static_cast(result) % url); - return mtx::xml::document_cptr(); - } - - try { - data = compressor_c::create_from_file_name(url)->decompress(data); - - mtx::xml::document_cptr doc(new pugi::xml_document); - std::stringstream sdata(data); - auto xml_result = doc->load(sdata); - - if (xml_result) { - mxdebug_if(debug, boost::format("Doc loaded fine from %1%\n") % url); - return doc; - - } else - mxdebug_if(debug, boost::format("Doc load error for %1%: %1% at %2%\n") % url % xml_result.description() % xml_result.offset); - - } catch (mtx::compression_x &ex) { - mxdebug_if(debug, boost::format("Decompression exception for %2%: %1%\n") % ex.what() % url); - } - - return mtx::xml::document_cptr(); -} - -mtx_release_version_t -get_latest_release_version() { - bool debug = debugging_c::requested("version_check|curl"); - std::string url = MTX_VERSION_CHECK_URL; - debugging_c::requested("version_check_url", &url); - - mxdebug_if(debug, boost::format("Update check started with URL %1%\n") % url); - - auto doc = retrieve_and_parse_xml(url + ".gz"); - if (!doc) - doc = retrieve_and_parse_xml(url); - if (!doc) - return {}; - - return parse_latest_release_version(doc); -} - -mtx::xml::document_cptr -get_releases_info() { - std::string url = MTX_RELEASES_INFO_URL; - debugging_c::requested("releases_info_url", &url); - - return retrieve_and_parse_xml(url + ".gz"); -} -#endif // defined(HAVE_CURL_EASY_H) diff --git a/src/common/version.h b/src/common/version.h index 98bd3dc8d..4ef0120d9 100644 --- a/src/common/version.h +++ b/src/common/version.h @@ -59,9 +59,4 @@ int compare_current_version_to(const std::string &other_version_str); version_number_t get_current_version(); mtx_release_version_t parse_latest_release_version(mtx::xml::document_cptr const &doc); -# if defined(HAVE_CURL_EASY_H) -mtx_release_version_t get_latest_release_version(); -mtx::xml::document_cptr get_releases_info(); -# endif // defined(HAVE_CURL_EASY_H) - #endif // MTX_COMMON_VERSION_H diff --git a/src/merge/mkvmerge.cpp b/src/merge/mkvmerge.cpp index 1e8306edd..e25998f79 100644 --- a/src/merge/mkvmerge.cpp +++ b/src/merge/mkvmerge.cpp @@ -344,9 +344,6 @@ set_usage() { " the specified JSON file (see man page).\n"); usage_text += Y(" -h, --help Show this help.\n"); usage_text += Y(" -V, --version Show version information.\n"); -#if defined(HAVE_CURL_EASY_H) - usage_text += std::string(" --check-for-updates ") + Y("Check online for the latest release.") + "\n"; -#endif usage_text += "\n\n"; usage_text += Y("Please read the man page/the HTML documentation to mkvmerge. It\n" "explains several details in great length which are not obvious from\n" diff --git a/tools/macos/build.sh b/tools/macos/build.sh index 58a062833..fe015d0ec 100755 --- a/tools/macos/build.sh +++ b/tools/macos/build.sh @@ -116,15 +116,6 @@ function build_boost { build_tarball command "./b2 ${args} ${properties} install" } -function build_curl { - build_package curl-7.40.0.tar.xz --prefix=${TARGET} \ - --disable-shared --enable-static \ - --disable-ldap --disable-ldaps --disable-rtsp \ - --disable-dict --disable-telnet --disable-gopher \ - --disable-imap --disable-imaps --disable-pop3 --disable-pop3s \ - --disable-smb --disable-smbs --disable-smtp --disable-smtps --disable-tftp -} - function build_qtbase { local -a args args=(--prefix=${TARGET} -opensource -confirm-license -release @@ -389,7 +380,6 @@ if [[ -z $@ ]]; then build_zlib build_gettext build_boost - build_curl build_qtbase build_qttools build_qttranslations diff --git a/tools/windows/setup_cross_compilation_env.sh b/tools/windows/setup_cross_compilation_env.sh index 098b33f19..d5d7140ba 100755 --- a/tools/windows/setup_cross_compilation_env.sh +++ b/tools/windows/setup_cross_compilation_env.sh @@ -50,7 +50,7 @@ MXE_TARGETS = ${HOST} MXE_PLUGIN_DIRS += plugins/gcc6 JOBS = ${PARALLEL} -MKVTOOLNIX_DEPENDENCIES=gettext libiconv zlib boost curl file flac lzo ogg pthreads vorbis +MKVTOOLNIX_DEPENDENCIES=gettext libiconv zlib boost file flac lzo ogg pthreads vorbis MKVTOOLNIX_DEPENDENCIES+=qtbase qttranslations qtwinextras mkvtoolnix-deps: \$(MKVTOOLNIX_DEPENDENCIES)