From 23b1a0ab70f190dbbb33dabb18ec039c7d85d6b3 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 11 Jan 2020 23:51:49 +0300 Subject: Add implementation --- .gitmodules | 4 + README-DEV | 151 +++++++++++ curl/.gitignore | 20 ++ curl/COPYING | 1 + curl/INSTALL | 7 + curl/README | 19 ++ curl/README-DEV | 16 ++ curl/build/.gitignore | 3 + curl/build/bootstrap.build | 11 + curl/build/export.build | 10 + curl/build/root.build | 14 + curl/buildfile | 10 + curl/curl/.gitignore | 1 + curl/curl/buildfile | 59 +++++ curl/curl/curl_config.h | 1 + curl/curl/curl_ctype.c | 1 + curl/curl/lib | 1 + curl/curl/nonblock.c | 1 + curl/curl/src | 1 + curl/curl/strtoofft.c | 1 + curl/curl/tool_hugehelp.c | 3 + curl/curl/tool_main.c | 379 ++++++++++++++++++++++++++ curl/curl/tool_main.c.patch | 55 ++++ curl/curl/warnless.c | 1 + curl/manifest | 19 ++ curl/tests/.gitignore | 4 + curl/tests/build/.gitignore | 3 + curl/tests/build/bootstrap.build | 9 + curl/tests/build/root.build | 16 ++ curl/tests/buildfile | 5 + curl/tests/empty.pem | 0 curl/tests/http.testscript | 10 + curl/tests/https.testscript | 22 ++ libcurl/.gitignore | 20 ++ libcurl/COPYING | 1 + libcurl/INSTALL | 7 + libcurl/README | 20 ++ libcurl/README-DEV | 39 +++ libcurl/build/.gitignore | 3 + libcurl/build/bootstrap.build | 35 +++ libcurl/build/export.build | 10 + libcurl/build/root.build | 16 ++ libcurl/buildfile | 10 + libcurl/libcurl/.gitignore | 1 + libcurl/libcurl/assert.c | 31 +++ libcurl/libcurl/buildfile | 128 +++++++++ libcurl/libcurl/curl_config.h | 472 +++++++++++++++++++++++++++++++++ libcurl/libcurl/include | 1 + libcurl/libcurl/lib | 1 + libcurl/libcurl/libcurl-symbols.expsym | 82 ++++++ libcurl/manifest | 21 ++ libcurl/tests/.gitignore | 3 + libcurl/tests/basic/buildfile | 7 + libcurl/tests/basic/driver.c | 48 ++++ libcurl/tests/basic/testscript | 27 ++ libcurl/tests/build/.gitignore | 3 + libcurl/tests/build/bootstrap.build | 9 + libcurl/tests/build/root.build | 22 ++ libcurl/tests/buildfile | 5 + packages.manifest | 4 + repositories.manifest | 14 + upstream | 1 + 62 files changed, 1899 insertions(+) create mode 100644 .gitmodules create mode 100644 README-DEV create mode 100644 curl/.gitignore create mode 120000 curl/COPYING create mode 100644 curl/INSTALL create mode 100644 curl/README create mode 100644 curl/README-DEV create mode 100644 curl/build/.gitignore create mode 100644 curl/build/bootstrap.build create mode 100644 curl/build/export.build create mode 100644 curl/build/root.build create mode 100644 curl/buildfile create mode 100644 curl/curl/.gitignore create mode 100644 curl/curl/buildfile create mode 120000 curl/curl/curl_config.h create mode 120000 curl/curl/curl_ctype.c create mode 120000 curl/curl/lib create mode 120000 curl/curl/nonblock.c create mode 120000 curl/curl/src create mode 120000 curl/curl/strtoofft.c create mode 100644 curl/curl/tool_hugehelp.c create mode 100644 curl/curl/tool_main.c create mode 100644 curl/curl/tool_main.c.patch create mode 120000 curl/curl/warnless.c create mode 100644 curl/manifest create mode 100644 curl/tests/.gitignore create mode 100644 curl/tests/build/.gitignore create mode 100644 curl/tests/build/bootstrap.build create mode 100644 curl/tests/build/root.build create mode 100644 curl/tests/buildfile create mode 100644 curl/tests/empty.pem create mode 100644 curl/tests/http.testscript create mode 100644 curl/tests/https.testscript create mode 100644 libcurl/.gitignore create mode 120000 libcurl/COPYING create mode 100644 libcurl/INSTALL create mode 100644 libcurl/README create mode 100644 libcurl/README-DEV create mode 100644 libcurl/build/.gitignore create mode 100644 libcurl/build/bootstrap.build create mode 100644 libcurl/build/export.build create mode 100644 libcurl/build/root.build create mode 100644 libcurl/buildfile create mode 100644 libcurl/libcurl/.gitignore create mode 100644 libcurl/libcurl/assert.c create mode 100644 libcurl/libcurl/buildfile create mode 100644 libcurl/libcurl/curl_config.h create mode 120000 libcurl/libcurl/include create mode 120000 libcurl/libcurl/lib create mode 100644 libcurl/libcurl/libcurl-symbols.expsym create mode 100644 libcurl/manifest create mode 100644 libcurl/tests/.gitignore create mode 100644 libcurl/tests/basic/buildfile create mode 100644 libcurl/tests/basic/driver.c create mode 100644 libcurl/tests/basic/testscript create mode 100644 libcurl/tests/build/.gitignore create mode 100644 libcurl/tests/build/bootstrap.build create mode 100644 libcurl/tests/build/root.build create mode 100644 libcurl/tests/buildfile create mode 100644 packages.manifest create mode 100644 repositories.manifest create mode 160000 upstream diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..fb88440 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "upstream"] + path = upstream + url = https://github.com/curl/curl.git + ignore = untracked diff --git a/README-DEV b/README-DEV new file mode 100644 index 0000000..94a128b --- /dev/null +++ b/README-DEV @@ -0,0 +1,151 @@ +This document describes an approach applied to packaging cURL for build2. In +particular, this understanding will be useful when upgrading to a new upstream +version. + +The upstream package contains the libcurl library and the curl program that we +package separately (see the respective README-DEV files for details). It also +contains tests that we currently don't package. + +We add the upstream package as a git submodule and symlink the required files +and subdirectories into the build2 package subdirectories. Then, when required, +we "overlay" the upstream with our own source files, placing them into the +library directory. + +Note that symlinking upstream submodule subdirectories into a build2 package +subdirectory results in creating intermediate build files (.d, .o, etc) inside +upstream directory while building the package in source tree. That's why we +need to make sure that packages do not share upstream source files via +subdirectory symlinks, not to also share the related intermediate files. If +several packages need to compile the same upstream source file, then only one +of them can symlink it via the parent directory while others must symlink it +directly. We also add the `ignore = untracked` configuration option into +.gitmodules to make sure that git ignores the intermediate build files under +upstream/ subdirectory. + +The upstream package can be configured to contain a specific feature set. We +reproduce the union of features configured for the upstream source package in +Debian and Fedora distributions. The configuration options defining these sets +are specified in the Debian's rules and Fedora's RPM .spec files. These files +can be obtained as follows: + +$ wget http://deb.debian.org/debian/pool/main/c/curl/curl_7.67.0-2.debian.tar.xz +$ tar xf curl_7.67.0-2.debian.tar.xz debian/rules + +$ wget https://kojipkgs.fedoraproject.org//packages/curl/7.67.0/2.fc32/src/curl-7.67.0-2.fc32.src.rpm +$ rpm2cpio curl-7.67.0-2.fc32.src.rpm | cpio -civ '*.spec' + +As a side note, on Debian and Fedora the source, library, headers, and tools +are packaged as follows: + + src library headers tool +Debian/Ubuntu: curl libcurl4 libcurl4-openssl-dev curl +Fedora/RHEL: curl libcurl libcurl-devel curl + +Search for the Debian and Fedora packages at https://packages.debian.org/search +and https://apps.fedoraproject.org/packages/. + +Here are the discovered configuration options. + +Debian: + + --disable-symbol-hiding --enable-versioned-symbols + --enable-threaded-resolver --with-lber-lib=lber + --with-gssapi=/usr --with-libssh2 --with-nghttp2 + --with-zsh-functions-dir=/usr/share/zsh/vendor-completions + --with-ca-path=/etc/ssl/certs + +Fedora: + + --disable-static --enable-symbol-hiding --enable-ipv6 + --enable-threaded-resolver --with-gssapi --with-nghttp2 --with-ssl + --with-ca-bundle=/etc/pki/tls/certs/ca-bundle.crt + --enable-ldap --enable-ldaps --enable-manual --with-brotli --with-libidn2 + --with-libmetalink --with-libpsl --with-libssh + +The union of these feature sets translates into the following options: + + --enable-symbol-hiding --enable-versioned-symbols + --enable-threaded-resolver --with-lber-lib=lber --with-gssapi --with-libssh2 + --with-nghttp2 --with-zsh-functions-dir= --with-ca-path= + --with-ca-bundle= --enable-ipv6 --with-ssl --enable-ldap + --enable-ldaps --enable-manual --with-brotli --with-libidn2 + --with-libmetalink --with-libpsl --with-libssh + +We, however, drop the external dependencies that are not packaged for build2, +disable default CA bundle/directory and use --with-ca-fallback instead, +explicitly request to use zlib and end up with the following options: + + --enable-symbol-hiding --enable-versioned-symbols --enable-threaded-resolve + --enable-ipv6 --with-ssl --with-zlib --disable-ldap --disable-ldaps + --disable-ares --disable-esni --disable-manual --without-lber-lib + --without-gssapi --without-libssh --without-libssh2 --without-nghttp2 + --without-zsh-functions-dir --without-brotli --without-libidn2 + --without-libmetalink --without-libpsl --without-ca-bundle --without-ca-path + --with-ca-fallback + +See the configuration options description at the "Install from source" page +(https://curl.haxx.se/docs/install.html). + +On Windows and MacOS we also enable the SSL backend provided by the system and +make it a default one. On MacOS we add the following configuration options: + + --with-secure-transport --with-default-ssl-backend=secure-transport + +Note, though, that on MacOS building curl with GCC fails for the Secure +Transport backend enabled (see curl issue 4821 for details). Thus, we disable +it for GCC on MacOS. + +For MSVC there is no easy way to request that via the configuration script, so +we apply the following patch to winbuild/MakefileBuild.vc: + +--- winbuild/MakefileBuild.vc.orig 2020-01-11 18:04:21.353519085 +0300 ++++ winbuild/MakefileBuild.vc 2020-01-11 18:08:35.962111020 +0300 +@@ -345,7 +345,7 @@ USE_WINSSL = true + !IF "$(USE_SSPI)"!="true" + !ERROR cannot build with WinSSL without SSPI + !ENDIF +-SSPI_CFLAGS = $(SSPI_CFLAGS) /DUSE_SCHANNEL ++SSPI_CFLAGS = $(SSPI_CFLAGS) /DUSE_SCHANNEL /DCURL_DEFAULT_SSL_BACKEND=\"schannel\" /DCURL_CA_FALLBACK=1 + WIN_LIBS = $(WIN_LIBS) Crypt32.lib + !ENDIF + +Normally, when packaging a project, we need to replace some auto-generated +headers with our own implementations and deduce compilation/linking options. +For cURL we can rely for that on m4/curl-compilers.m4, {lib,src}/Makefile.am, +and winbuild/MakefileBuild.vc. In practice, however, that can be uneasy and +error prone, so you may also need to see the auto-generated files and the +actual compiler and linker command lines in the build log. If that's the case, +you can configure/build the upstream package on the platform of interest +running the following commands in the upstream project root directory. + +On POSIX and for MinGW GCC (add --with-secure-transport +--with-default-ssl-backend=secure-transport for MacOS and --with-schannel +--with-default-ssl-backend=schannel for MinGW GCC): + +$ ./buildconf +$ mkdir build +$ cd build +$ ../configure --enable-symbol-hiding --enable-versioned-symbols \ + --enable-threaded-resolve --enable-ipv6 --with-ssl --with-zlib \ + --disable-ldap --disable-ldaps --disable-ares --disable-esni \ + --disable-manual --without-lber-lib --without-gssapi --without-libssh \ + --without-libssh2 --without-nghttp2 --without-zsh-functions-dir \ + --without-brotli --without-libidn2 --without-libmetalink --without-libpsl \ + --without-ca-bundle --without-ca-path --with-ca-fallback >build.log 2>&1 +$ make V=1 >>build.log 2>&1 + +For MSVC: + +> buildconf.bat +> cd winbuild +> nmake /f Makefile.vc mode=dll ENABLE_WINSSL=yes ^ + WITH_SSL=dll ENABLE_OPENSSL_AUTO_LOAD_CONFIG=no ^ + WITH_ZLIB=dll >build.log 2>&1 + +See the upstream/docs/INSTALL.md for details. + +When the packaging is complete, build all the project packages in source tree +and make sure that no cURL headers are included from the system, running the +following command from the project root: + +$ fgrep -a -e /usr/include/curl `find . -type f -name '*.d'` diff --git a/curl/.gitignore b/curl/.gitignore new file mode 100644 index 0000000..4c4fec7 --- /dev/null +++ b/curl/.gitignore @@ -0,0 +1,20 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.ii +*.o +*.obj +*.so +*.so.* +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc diff --git a/curl/COPYING b/curl/COPYING new file mode 120000 index 0000000..0ca50eb --- /dev/null +++ b/curl/COPYING @@ -0,0 +1 @@ +../upstream/COPYING \ No newline at end of file diff --git a/curl/INSTALL b/curl/INSTALL new file mode 100644 index 0000000..4d14918 --- /dev/null +++ b/curl/INSTALL @@ -0,0 +1,7 @@ +The aim of this package is to make reading the INSTALL file unnecessary. So +next time try running: + +$ bpkg build curl + +But if you don't want to use the package manager, then you can also build this +package manually using the standard build2 build system. diff --git a/curl/README b/curl/README new file mode 100644 index 0000000..b5338d6 --- /dev/null +++ b/curl/README @@ -0,0 +1,19 @@ +cURL is a client-side software for transferring data using URLs. The curl +command line tool makes the various features of libcurl available from the +shell. For more information see: + +https://curl.haxx.se/ + +This package contains the original curl program source code overlaid with the +build2-based build system and packaged for the build2 package manager (bpkg). + +See the INSTALL file for the prerequisites and installation instructions. + +Send questions, bug reports, or any other feedback about the program itself to +the cURL mailing lists. Send build system and packaging-related feedback to +the packaging@build2.org mailing list (see https://lists.build2.org for +posting guidelines, etc). + +The packaging of curl for build2 is tracked in a Git repository at: + +https://git.build2.org/cgit/packaging/curl/ diff --git a/curl/README-DEV b/curl/README-DEV new file mode 100644 index 0000000..6b9f99e --- /dev/null +++ b/curl/README-DEV @@ -0,0 +1,16 @@ +This document describes how curl was packaged for build2. In particular, this +understanding will be useful when upgrading to a new upstream version. See +../README-DEV for general notes on curl packaging. + +Symlink the required upstream directories into curl/: + +$ ln -s ../../upstream/{src,lib} curl +$ ln -s lib/{strtoofft,nonblock,warnless,curl_ctype}.c curl +$ ln -s src/tool_hugehelp.c.cvs curl/tool_hugehelp.c +$ ln -s ../../libcurl/libcurl/curl_config.h curl + +Patch curl to use CA certificate bundle provided by the +libca-certificates-curl package by default: + +$ cp curl/src/tool_main.c curl +$ patch -p0 , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +#include "tool_setup.h" + +#include + +#ifdef HAVE_SIGNAL_H +#include +#endif + +#ifdef USE_NSS +#include +#include +#endif + +#include /* setenv(), _putenv() */ + +#include + +#define ENABLE_CURLX_PRINTF +/* use our own printf() functions */ +#include "curlx.h" + +#include "tool_cfgable.h" +#include "tool_convert.h" +#include "tool_doswin.h" +#include "tool_msgs.h" +#include "tool_operate.h" +#include "tool_panykey.h" +#include "tool_vms.h" +#include "tool_main.h" +#include "tool_libinfo.h" + +/* + * This is low-level hard-hacking memory leak tracking and similar. Using + * the library level code from this client-side is ugly, but we do this + * anyway for convenience. + */ +#include "memdebug.h" /* keep this as LAST include */ + +#ifdef __VMS +/* + * vms_show is a global variable, used in main() as parameter for + * function vms_special_exit() to allow proper curl tool exiting. + * Its value may be set in other tool_*.c source files thanks to + * forward declaration present in tool_vms.h + */ +int vms_show = 0; +#endif + +#ifdef __MINGW32__ +/* + * There seems to be no way to escape "*" in command-line arguments with MinGW + * when command-line argument globbing is enabled under the MSYS shell, so turn + * it off. + */ +int _CRT_glob = 0; +#endif /* __MINGW32__ */ + +/* if we build a static library for unit tests, there is no main() function */ +#ifndef UNITTESTS + +/* + * Ensure that file descriptors 0, 1 and 2 (stdin, stdout, stderr) are + * open before starting to run. Otherwise, the first three network + * sockets opened by curl could be used for input sources, downloaded data + * or error logs as they will effectively be stdin, stdout and/or stderr. + */ +static void main_checkfds(void) +{ +#ifdef HAVE_PIPE + int fd[2] = { STDIN_FILENO, STDIN_FILENO }; + while(fd[0] == STDIN_FILENO || + fd[0] == STDOUT_FILENO || + fd[0] == STDERR_FILENO || + fd[1] == STDIN_FILENO || + fd[1] == STDOUT_FILENO || + fd[1] == STDERR_FILENO) + if(pipe(fd) < 0) + return; /* Out of handles. This isn't really a big problem now, but + will be when we try to create a socket later. */ + close(fd[0]); + close(fd[1]); +#endif +} + +#ifdef CURLDEBUG +static void memory_tracking_init(void) +{ + char *env; + /* if CURL_MEMDEBUG is set, this starts memory tracking message logging */ + env = curlx_getenv("CURL_MEMDEBUG"); + if(env) { + /* use the value as file name */ + char fname[CURL_MT_LOGFNAME_BUFSIZE]; + if(strlen(env) >= CURL_MT_LOGFNAME_BUFSIZE) + env[CURL_MT_LOGFNAME_BUFSIZE-1] = '\0'; + strcpy(fname, env); + curl_free(env); + curl_dbg_memdebug(fname); + /* this weird stuff here is to make curl_free() get called before + curl_gdb_memdebug() as otherwise memory tracking will log a free() + without an alloc! */ + } + /* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */ + env = curlx_getenv("CURL_MEMLIMIT"); + if(env) { + char *endptr; + long num = strtol(env, &endptr, 10); + if((endptr != env) && (endptr == env + strlen(env)) && (num > 0)) + curl_dbg_memlimit(num); + curl_free(env); + } +} +#else +# define memory_tracking_init() Curl_nop_stmt +#endif + +/* + * This is the main global constructor for the app. Call this before + * _any_ libcurl usage. If this fails, *NO* libcurl functions may be + * used, or havoc may be the result. + */ +static CURLcode main_init(struct GlobalConfig *config) +{ + /* Set the SSL_CERT_FILE environment variable to refer to the bundled CA + * certificates, unless it is already set, and switch to the OpenSSL + * backend. + */ + char* env = curlx_getenv ("SSL_CERT_FILE"); + + if (env == NULL) + { + int r; + +#ifndef _WIN32 + r = setenv ("SSL_CERT_FILE", ca_certificates_file (), 0 /* overwrite */); +#else + char* v = curl_maprintf ("SSL_CERT_FILE=%s", ca_certificates_file ()); + + if (v != NULL) + { + r = _putenv (v); + free (v); + } + else + r = -1; +#endif + + if (r == -1) + return CURLE_FAILED_INIT; + } + else + curl_free (env); + + if (curl_global_sslset (CURLSSLBACKEND_OPENSSL, + NULL /* name */, + NULL /* avail */) != CURLSSLSET_OK) + return CURLE_FAILED_INIT; + + CURLcode result = CURLE_OK; + +#if defined(__DJGPP__) || defined(__GO32__) + /* stop stat() wasting time */ + _djstat_flags |= _STAT_INODE | _STAT_EXEC_MAGIC | _STAT_DIRSIZE; +#endif + + /* Initialise the global config */ + config->showerror = -1; /* Will show errors */ + config->errors = stderr; /* Default errors to stderr */ + config->styled_output = TRUE; /* enable detection */ + config->parallel_max = PARALLEL_DEFAULT; + + /* Allocate the initial operate config */ + config->first = config->last = malloc(sizeof(struct OperationConfig)); + if(config->first) { + /* Perform the libcurl initialization */ + result = curl_global_init(CURL_GLOBAL_DEFAULT); + if(!result) { + /* Get information about libcurl */ + result = get_libcurl_info(); + + if(!result) { + /* Initialise the config */ + config_init(config->first); + config->first->global = config; + } + else { + helpf(stderr, "error retrieving curl library information\n"); + free(config->first); + } + } + else { + helpf(stderr, "error initializing curl library\n"); + free(config->first); + } + } + else { + helpf(stderr, "error initializing curl\n"); + result = CURLE_FAILED_INIT; + } + + return result; +} + +static void free_globalconfig(struct GlobalConfig *config) +{ + Curl_safefree(config->trace_dump); + + if(config->errors_fopened && config->errors) + fclose(config->errors); + config->errors = NULL; + + if(config->trace_fopened && config->trace_stream) + fclose(config->trace_stream); + config->trace_stream = NULL; + + Curl_safefree(config->libcurl); +} + +/* + * This is the main global destructor for the app. Call this after + * _all_ libcurl usage is done. + */ +static void main_free(struct GlobalConfig *config) +{ + /* Cleanup the easy handle */ + /* Main cleanup */ + curl_global_cleanup(); + convert_cleanup(); + metalink_cleanup(); +#ifdef USE_NSS + if(PR_Initialized()) { + /* prevent valgrind from reporting still reachable mem from NSRP arenas */ + PL_ArenaFinish(); + /* prevent valgrind from reporting possibly lost memory (fd cache, ...) */ + PR_Cleanup(); + } +#endif + free_globalconfig(config); + + /* Free the config structures */ + config_free(config->last); + config->first = NULL; + config->last = NULL; +} + +#ifdef WIN32 +/* TerminalSettings for Windows */ +static struct TerminalSettings { + HANDLE hStdOut; + DWORD dwOutputMode; +} TerminalSettings; + +static void configure_terminal(void) +{ + /* + * If we're running Windows, enable VT output. + * Note: VT mode flag can be set on any version of Windows, but VT + * processing only performed on Win10 >= Creators Update) + */ + + /* Define the VT flags in case we're building with an older SDK */ +#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING + #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 +#endif + + memset(&TerminalSettings, 0, sizeof(TerminalSettings)); + + /* Enable VT output */ + TerminalSettings.hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); + if((TerminalSettings.hStdOut != INVALID_HANDLE_VALUE) + && (GetConsoleMode(TerminalSettings.hStdOut, + &TerminalSettings.dwOutputMode))) { + SetConsoleMode(TerminalSettings.hStdOut, + TerminalSettings.dwOutputMode + | ENABLE_VIRTUAL_TERMINAL_PROCESSING); + } +} +#else +#define configure_terminal() +#endif + +static void restore_terminal(void) +{ +#ifdef WIN32 + /* Restore Console output mode and codepage to whatever they were + * when Curl started */ + SetConsoleMode(TerminalSettings.hStdOut, TerminalSettings.dwOutputMode); +#endif +} + +/* +** curl tool main function. +*/ +int main(int argc, char *argv[]) +{ + CURLcode result = CURLE_OK; + struct GlobalConfig global; + memset(&global, 0, sizeof(global)); + + /* Perform any platform-specific terminal configuration */ + configure_terminal(); + + main_checkfds(); + +#if defined(HAVE_SIGNAL) && defined(SIGPIPE) + (void)signal(SIGPIPE, SIG_IGN); +#endif + + /* Initialize memory tracking */ + memory_tracking_init(); + + /* Initialize the curl library - do not call any libcurl functions before + this point */ + result = main_init(&global); + +#ifdef WIN32 + /* Undocumented diagnostic option to list the full paths of all loaded + modules, regardless of whether or not initialization succeeded. */ + if(argc == 2 && !strcmp(argv[1], "--dump-module-paths")) { + struct curl_slist *item, *head = GetLoadedModulePaths(); + for(item = head; item; item = item->next) { + printf("%s\n", item->data); + } + curl_slist_free_all(head); + if(!result) + main_free(&global); + } + else +#endif /* WIN32 */ + if(!result) { + /* Start our curl operation */ + result = operate(&global, argc, argv); + +#ifdef __SYMBIAN32__ + if(global.showerror) + tool_pressanykey(); +#endif + + /* Perform the main cleanup */ + main_free(&global); + } + + /* Return the terminal to its original state */ + restore_terminal(); + +#ifdef __NOVELL_LIBC__ + if(getenv("_IN_NETWARE_BASH_") == NULL) + tool_pressanykey(); +#endif + +#ifdef __VMS + vms_special_exit(result, vms_show); +#else + return (int)result; +#endif +} + +#endif /* ndef UNITTESTS */ diff --git a/curl/curl/tool_main.c.patch b/curl/curl/tool_main.c.patch new file mode 100644 index 0000000..cae1787 --- /dev/null +++ b/curl/curl/tool_main.c.patch @@ -0,0 +1,55 @@ +--- curl/src/tool_main.c 2020-01-18 23:47:34.559751631 +0300 ++++ curl/tool_main.c 2020-01-20 16:07:17.183814044 +0300 +@@ -32,6 +32,10 @@ + #include + #endif + ++#include /* setenv(), _putenv() */ ++ ++#include ++ + #define ENABLE_CURLX_PRINTF + /* use our own printf() functions */ + #include "curlx.h" +@@ -138,6 +142,41 @@ static void memory_tracking_init(void) + */ + static CURLcode main_init(struct GlobalConfig *config) + { ++ /* Set the SSL_CERT_FILE environment variable to refer to the bundled CA ++ * certificates, unless it is already set, and switch to the OpenSSL ++ * backend. ++ */ ++ char* env = curlx_getenv ("SSL_CERT_FILE"); ++ ++ if (env == NULL) ++ { ++ int r; ++ ++#ifndef _WIN32 ++ r = setenv ("SSL_CERT_FILE", ca_certificates_file (), 0 /* overwrite */); ++#else ++ char* v = curl_maprintf ("SSL_CERT_FILE=%s", ca_certificates_file ()); ++ ++ if (v != NULL) ++ { ++ r = _putenv (v); ++ free (v); ++ } ++ else ++ r = -1; ++#endif ++ ++ if (r == -1) ++ return CURLE_FAILED_INIT; ++ } ++ else ++ curl_free (env); ++ ++ if (curl_global_sslset (CURLSSLBACKEND_OPENSSL, ++ NULL /* name */, ++ NULL /* avail */) != CURLSSLSET_OK) ++ return CURLE_FAILED_INIT; ++ + CURLcode result = CURLE_OK; + + #if defined(__DJGPP__) || defined(__GO32__) diff --git a/curl/curl/warnless.c b/curl/curl/warnless.c new file mode 120000 index 0000000..2ac2b7f --- /dev/null +++ b/curl/curl/warnless.c @@ -0,0 +1 @@ +lib/warnless.c \ No newline at end of file diff --git a/curl/manifest b/curl/manifest new file mode 100644 index 0000000..b91836a --- /dev/null +++ b/curl/manifest @@ -0,0 +1,19 @@ +: 1 +name: curl +version: 7.67.0-a.0.z +summary: Command line tool for transferring data with URLs +license: cURL ; MIT/X derivate license. +topics: HTTP, FTP, URL, data transfer +description-file: README +url: https://curl.haxx.se/ +doc-url: https://curl.haxx.se/docs/manpage.html +src-url: https://git.build2.org/cgit/packaging/curl/curl/tree/curl/ +package-url: https://git.build2.org/cgit/packaging/curl/ +email: curl-users@cool.haxx.se ; Mailing list. +package-email: packaging@build2.org ; Mailing list. +build-email: builds@build2.org +builds: all +depends: * build2 >= 0.12.0 +depends: * bpkg >= 0.12.0 +depends: libcurl == $ +depends: libca-certificates-curl >= 1.0.0 diff --git a/curl/tests/.gitignore b/curl/tests/.gitignore new file mode 100644 index 0000000..ce6eed8 --- /dev/null +++ b/curl/tests/.gitignore @@ -0,0 +1,4 @@ +# Testscript output directories (can be symlinks). +# +test +test-* diff --git a/curl/tests/build/.gitignore b/curl/tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/curl/tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/curl/tests/build/bootstrap.build b/curl/tests/build/bootstrap.build new file mode 100644 index 0000000..d8bbf2c --- /dev/null +++ b/curl/tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : tests/build/bootstrap.build +# copyright : Copyright (c) 2018-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +project = # Unnamed tests subproject. + +using config +using test +using dist diff --git a/curl/tests/build/root.build b/curl/tests/build/root.build new file mode 100644 index 0000000..2ea18e0 --- /dev/null +++ b/curl/tests/build/root.build @@ -0,0 +1,16 @@ +# file : tests/build/root.build +# copyright : Copyright (c) 2018-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +# We need to configure C module to obtain the target information (see below). +# +using c + +# Setup the curl program that we are testing. +# +import curl = curl%exe{curl} +testscript{*}: test = $curl + +# Specify the test target for cross-testing. +# +test.target = $c.target diff --git a/curl/tests/buildfile b/curl/tests/buildfile new file mode 100644 index 0000000..3ad4988 --- /dev/null +++ b/curl/tests/buildfile @@ -0,0 +1,5 @@ +# file : tests/buildfile +# copyright : Copyright (c) 2018-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +./: testscript{*} file{empty.pem} $curl diff --git a/curl/tests/empty.pem b/curl/tests/empty.pem new file mode 100644 index 0000000..e69de29 diff --git a/curl/tests/http.testscript b/curl/tests/http.testscript new file mode 100644 index 0000000..98e7267 --- /dev/null +++ b/curl/tests/http.testscript @@ -0,0 +1,10 @@ +# file : tests/http.testscript +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +: basic +: +$* -sS 'http://www.example.com' >>~%EOO% +%% +%.+ +EOO diff --git a/curl/tests/https.testscript b/curl/tests/https.testscript new file mode 100644 index 0000000..ae621ac --- /dev/null +++ b/curl/tests/https.testscript @@ -0,0 +1,22 @@ +# file : tests/https.testscript +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +: default +: +{ + test.options += -sS + + $* 'http://www.example.com' | set s; + $* 'https://www.example.com' >"$s" +} + +: override +: +: Specify the empty CA certificates bundle on the command line and make sure +: curl exits with the 'peer certificate cannot be authenticated with known CA +: certificates' exit code. +: +{ + $* -s 'https://www.example.com' --capath "$src_base/empty.pem" == 60 +} diff --git a/libcurl/.gitignore b/libcurl/.gitignore new file mode 100644 index 0000000..4c4fec7 --- /dev/null +++ b/libcurl/.gitignore @@ -0,0 +1,20 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.ii +*.o +*.obj +*.so +*.so.* +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc diff --git a/libcurl/COPYING b/libcurl/COPYING new file mode 120000 index 0000000..0ca50eb --- /dev/null +++ b/libcurl/COPYING @@ -0,0 +1 @@ +../upstream/COPYING \ No newline at end of file diff --git a/libcurl/INSTALL b/libcurl/INSTALL new file mode 100644 index 0000000..d75f7c8 --- /dev/null +++ b/libcurl/INSTALL @@ -0,0 +1,7 @@ +The aim of this package is to make reading the INSTALL file unnecessary. So +next time try running: + +$ bpkg build libcurl + +But if you don't want to use the package manager, then you can also build this +package manually using the standard build2 build system. diff --git a/libcurl/README b/libcurl/README new file mode 100644 index 0000000..e508068 --- /dev/null +++ b/libcurl/README @@ -0,0 +1,20 @@ +cURL is a client-side software for transferring data using URLs with the +libcurl C library providing the data transfer and URL manipulation APIs. +For more information see: + +https://curl.haxx.se/ + +This package contains the original libcurl library source code overlaid with +the build2-based build system and packaged for the build2 package manager +(bpkg). + +See the INSTALL file for the prerequisites and installation instructions. + +Send questions, bug reports, or any other feedback about the library itself to +the cURL mailing lists. Send build system and packaging-related feedback to +the packaging@build2.org mailing list (see https://lists.build2.org for +posting guidelines, etc). + +The packaging of libcurl for build2 is tracked in a Git repository at: + +https://git.build2.org/cgit/packaging/curl/ diff --git a/libcurl/README-DEV b/libcurl/README-DEV new file mode 100644 index 0000000..cea97e1 --- /dev/null +++ b/libcurl/README-DEV @@ -0,0 +1,39 @@ +This document describes how libcurl was packaged for build2. In particular, +this understanding will be useful when upgrading to a new upstream version. +See ../README-DEV for general notes on curl packaging. + +Symlink the required upstream directories into libcurl/: + +$ ln -s ../../upstream/{lib,include} libcurl + +Create libcurl/curl_config.h using as a base the upstream's auto-generated +header and/or the corresponding .m4 and configure.ac files. + +Some macro values cannot be easily determined at the preprocessing time. We +define them based on the supported platform tests and add libcurl/assert.c, +containing compile-time assertions for the macros in question. + +Copy the upstream's libtool-generated for MacOS libcurl-symbols.expsym file +and comment out (with #) the _curl_jmpenv symbol in it since it causes the +'cannot export hidden symbol' linked warning on MacOS. + +Note that re-creating libcurl/curl_config.h from scratch every time we upgrade +to a new upstream version would be a real pain. Instead we can only (un)define +the newly introduced macros, comparing the already defined and currently used +macro sets. For the comparison we can use config-win32.h and auto-generated on +Linux upstream's curl_config.h: + +$ for m in `cat /lib/curl_config.h libcurl/lib/config-win32.h | \ + sed -n 's/^.*#\s*\(define\|undef\)\s\{1,\}\([_A-Z0-9]\{1,\}\)\(\s.*\)\{0,1\}$/\2/p' | \ + sort -u`; do + if grep -q -e "\b$m\b" `find -L . ../curl -name '*.h' -a ! -name curl_config.h -a ! -name 'config-*.h' -o -name '*.c'`; then + echo "$m" + fi + done >used-macros + +$ cat libcurl/curl_config.h | \ + sed -n 's/^.*#\s*\(define\|undef\)\s\{1,\}\([_A-Z0-9]\{1,\}\)\(\s.*\)\{0,1\}$/\2/p' | \ + sort -u >defined-macros + +$ diff defined-macros used-macros | grep '<' >remove-macros +$ diff defined-macros used-macros | grep '>' >add-macros diff --git a/libcurl/build/.gitignore b/libcurl/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/libcurl/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/libcurl/build/bootstrap.build b/libcurl/build/bootstrap.build new file mode 100644 index 0000000..23d898a --- /dev/null +++ b/libcurl/build/bootstrap.build @@ -0,0 +1,35 @@ +# file : build/root.build +# copyright : Copyright (c) 2018-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +project = libcurl + +using version +using config +using test +using install +using dist + +# The cURL version has the .. form and follows the semver +# semantics. Specifically, the major version is increased when really big +# changes are made, the minor version when new features are added, and the +# patch version is increased for bug fixes. See also: +# +# https://curl.haxx.se/docs/versions.html +# +# The ABI version doesn't correlate with the release version and is assigned +# via the libtool's -version-info :: option +# (VERSIONINFO in lib/Makefile.am). As it follows from the comment in the +# makefile, the major version (current - age) is incremented for backwards- +# incompatible ABI changes. See also: +# +# https://curl.haxx.se/libcurl/abi.html +# +if ($version.major == 7 && $version.minor == 67 && $version.patch == 0) +{ + + abi_version_major = 4 + abi_version = "$abi_version_major.6.0" # .. +} +else + fail 'increment the ABI version?' diff --git a/libcurl/build/export.build b/libcurl/build/export.build new file mode 100644 index 0000000..2a2b403 --- /dev/null +++ b/libcurl/build/export.build @@ -0,0 +1,10 @@ +# file : build/root.build +# copyright : Copyright (c) 2018-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +$out_root/ +{ + include libcurl/ +} + +export $out_root/libcurl/$import.target diff --git a/libcurl/build/root.build b/libcurl/build/root.build new file mode 100644 index 0000000..3199ffa --- /dev/null +++ b/libcurl/build/root.build @@ -0,0 +1,16 @@ +# file : build/root.build +# copyright : Copyright (c) 2018-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +using in + +using c + +h{*}: extension = h +c{*}: extension = c + +if ($c.target.system == 'win32-msvc') + c.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($c.class == 'msvc') + c.coptions += /wd4251 /wd4275 /wd4800 diff --git a/libcurl/buildfile b/libcurl/buildfile new file mode 100644 index 0000000..04c29b8 --- /dev/null +++ b/libcurl/buildfile @@ -0,0 +1,10 @@ +# file : buildfile +# copyright : Copyright (c) 2018-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file +# +./: {*/ -build/} doc{COPYING INSTALL README} manifest + +# Don't install tests or the INSTALL file. +# +tests/: install = false +doc{INSTALL}@./: install = false diff --git a/libcurl/libcurl/.gitignore b/libcurl/libcurl/.gitignore new file mode 100644 index 0000000..33c2835 --- /dev/null +++ b/libcurl/libcurl/.gitignore @@ -0,0 +1 @@ +libcurl.vers diff --git a/libcurl/libcurl/assert.c b/libcurl/libcurl/assert.c new file mode 100644 index 0000000..60eb1e5 --- /dev/null +++ b/libcurl/libcurl/assert.c @@ -0,0 +1,31 @@ +/* file : libcurl/assert.c -*- C -*- + * copyright : Copyright (c) 2016-2019 Code Synthesis Ltd + * license : cURL License; see accompanying COPYING file + */ + +#include + +#ifdef _MSC_VER +# include // C_ASSERT() +#endif + +#include +#include + +#include + +/* Make sure that some assumptions made at the preprocessing stage are true. + */ + +/* _Static_assert() is introduced in C11, is available for GCC and Clang by + * default since they support C99, and is not supported by VC at all. + */ +#ifdef _MSC_VER +# define _Static_assert(C, M) C_ASSERT (C) +#endif + +_Static_assert (sizeof (off_t) == SIZEOF_OFF_T, "unexpected off_t size"); +_Static_assert (sizeof (time_t) == SIZEOF_TIME_T, "unexpected time_t size"); + +_Static_assert (sizeof (curl_off_t) == SIZEOF_CURL_OFF_T, + "unexpected curl_off_t size"); diff --git a/libcurl/libcurl/buildfile b/libcurl/libcurl/buildfile new file mode 100644 index 0000000..652a25e --- /dev/null +++ b/libcurl/libcurl/buildfile @@ -0,0 +1,128 @@ +# file : libcurl/buildfile +# copyright : Copyright (c) 2018-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +# Version script. +# +define vsc: file +vsc{*}: extension = vers + +# Exported symbols. +# +define esm: file +esm{*}: extension = expsym + +import imp_libs = libssl%lib{ssl} +import imp_libs += libcrypto%lib{crypto} +import imp_libs += libz%lib{z} + +lib{curl}: {h c}{**} $imp_libs + +tclass = $c.target.class +tsys = $c.target.system + +linux = ($tclass == 'linux') +bsd = ($tclass == 'bsd') +macos = ($tclass == 'macos') +windows = ($tclass == 'windows') + +lib{curl}: vsc{libcurl}: include = ($linux || $bsd ? adhoc : false) +lib{curl}: esm{libcurl-symbols}: include = ($macos ? adhoc : false) + +vsc{libcurl}: lib/in{libcurl} +{ + in.symbol = '@' + + CURL_LT_SHLIB_VERSIONED_FLAVOUR = 'OPENSSL_' +} + +# Build options. +# +c.poptions += -DBUILDING_LIBCURL -DHAVE_CONFIG_H \ + -DOS="\"$c.target\"" -DVERSION="\"$version.project_id\"" + +if! $windows + c.poptions += -DCURL_HIDDEN_SYMBOLS + +# Note that the upstream package uses the -pthread compiler/linker option on +# Linux and FreeBSD. The option is unsupported by build2 so we pass +# -D_REENTRANT and -lpthread preprocessor/linker options instead. +# +switch $tclass, $tsys +{ + case 'linux' | 'bsd' + c.poptions += -D_REENTRANT + + case 'windows', 'win32-msvc' + c.poptions += -DWIN32 +} + +c.poptions =+ "-I$src_base" "-I$src_base/include" "-I$src_base/lib" + +obja{*}: c.poptions += -DCURL_STATICLIB + +if! $windows + c.coptions += -fvisibility=hidden + +switch $c.class, $tsys +{ + case 'gcc' + { + # Disable warnings that pop up with -Wall -Wextra. Upstream doesn't seem + # to care about these and it is not easy to disable specific warnings in a + # way that works across compilers/version (some -Wno-* options are only + # recognized in newer versions). + # + c.coptions += -Wno-all -Wno-extra -Wno-deprecated-declarations + } + case 'msvc' + { + # Disable warnings that pop up with /W3. + # + c.coptions += /wd4996 + } +} + +switch $tclass, $tsys +{ + case 'linux' | 'bsd' + { + # Make sure all symbols are resolvable. + # + c.loptions += -Wl,--no-undefined + + c.loptions += "-Wl,--version-script=$out_base/libcurl.vers" + c.libs += -lpthread + } + case 'macos' + { + c.loptions += "-Wl,-exported_symbols_list,$src_base/libcurl-symbols.expsym" + c.libs += -framework CoreFoundation -framework Security + } + case 'windows', 'mingw32' + { + c.loptions += -Wl,--enable-auto-image-base + c.libs += -lws2_32 -lcrypt32 + } + case 'windows' + { + c.libs += ws2_32.lib crypt32.lib normaliz.lib advapi32.lib + } +} + +# Export options. +# +lib{curl}: cc.export.poptions = "-I$src_base/include" +liba{curl}: cc.export.poptions += -DCURL_STATICLIB + +# See bootstrap.build for details. +# +if $version.pre_release + lib{curl}: bin.lib.version = @"-$version.project_id" +else + lib{curl}: bin.lib.version = @"-$abi_version_major" linux@"$abi_version" + +# Install headers from the include/curl/ subdirectory only. +# +h{*}: install = false +include/curl/h{*}: install = include/curl/ diff --git a/libcurl/libcurl/curl_config.h b/libcurl/libcurl/curl_config.h new file mode 100644 index 0000000..524513c --- /dev/null +++ b/libcurl/libcurl/curl_config.h @@ -0,0 +1,472 @@ +/* file : libcurl/curl_config.h -*- C -*- + * copyright : Copyright (c) 2016-2019 Code Synthesis Ltd + * license : cURL License; see accompanying COPYING file + */ + +#ifndef LIBCURL_CURL_CONFIG_H +#define LIBCURL_CURL_CONFIG_H + +/* For the semantics of the following macros refer to upstream's configure.ac, + * .m4, lib/curl_config.h.cmake and lib/config-win32.h files. + * + * Note that we will explicitly undefine macros that should not be defined. + * While this is not technically required, it simplifies the change tracking + * (see ../README-DEV). As a bonus we also make sure that they are not get + * eventually defined by some system headers. + */ + +/* These macros are defined via the -D preprocessor option. Keep them listed + * (in this exact form) for the change tracking (see ../README-DEV). + +#define OS +#define VERSION + + */ + +/* See the ../../README-DEV for the SSL backend and CA information lookup + * configuration. + */ +#define USE_OPENSSL 1 +#define USE_TLS_SRP 1 + +#if (defined(__APPLE__) && defined(__clang__)) || defined(_WIN32) +# define CURL_WITH_MULTI_SSL 1 +# if defined(__APPLE__) +# define USE_SECTRANSP 1 +# define CURL_DEFAULT_SSL_BACKEND "secure-transport" +# else +# define USE_SCHANNEL 1 +# define CURL_DEFAULT_SSL_BACKEND "schannel" +# endif +#endif + +#undef CURL_CA_BUNDLE +#undef CURL_CA_PATH +#define CURL_CA_FALLBACK 1 + +#define CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG 1 + +#undef HAVE_BORINGSSL +#undef USE_WOLFSSL + +/* Enabled features. + */ +#define ENABLE_IPV6 1 +#define HAVE_ZLIB_H 1 +#define HAVE_LIBZ 1 + +#undef CURL_DISABLE_COOKIES +#undef CURL_DISABLE_CRYPTO_AUTH +#undef CURL_DISABLE_DICT +#undef CURL_DISABLE_DOH +#undef CURL_DISABLE_FILE +#undef CURL_DISABLE_FTP +#undef CURL_DISABLE_GOPHER +#undef CURL_DISABLE_HTTP +#undef CURL_DISABLE_HTTP_AUTH +#undef CURL_DISABLE_IMAP +#undef CURL_DISABLE_MIME +#undef CURL_DISABLE_LIBCURL_OPTION +#undef CURL_DISABLE_NETRC +#undef CURL_DISABLE_PARSEDATE +#undef CURL_DISABLE_POP3 +#undef CURL_DISABLE_PROGRESS_METER +#undef CURL_DISABLE_PROXY +#undef CURL_DISABLE_RTSP +#undef CURL_DISABLE_SHUFFLE_DNS +#undef CURL_DISABLE_SMB +#undef CURL_DISABLE_SMTP +#undef CURL_DISABLE_TELNET +#undef CURL_DISABLE_TFTP +#undef CURL_DISABLE_VERBOSE_STRINGS + +/* Diabled features. + */ +#define CURL_DISABLE_LDAP 1 +#define CURL_DISABLE_LDAPS 1 + +#undef USE_WIN32_LDAP +#undef HAVE_LDAP_SSL +#undef HAVE_LDAP_SSL_H +#undef HAVE_LDAP_URL_PARSE + +#undef USE_LIBSSH +#undef USE_LIBSSH2 +#undef HAVE_LIBSSH2_H +#undef HAVE_LIBSSH_LIBSSH_H +#undef USE_AMISSL +#undef USE_GNUTLS +#undef USE_GNUTLS_NETTLE +#undef USE_ARES +#undef USE_ESNI +#undef USE_LIBPSL +#undef USE_MANUAL +#undef USE_MBEDTLS +#undef USE_MESALINK +#undef USE_METALINK +#undef USE_NGHTTP2 +#undef USE_NGHTTP3 +#undef USE_NGTCP2 +#undef USE_NSS +#undef USE_OPENLDAP +#undef USE_ALTSVC +#undef USE_LIBRTMP +#undef USE_QUICHE + +/* Specific for (non-) Linux. + */ +#ifdef __linux__ +# define HAVE_FSETXATTR_5 1 +# define HAVE_LINUX_TCP_H 1 +#else +# define HAVE_SETMODE 1 +#endif + +/* Specific FreeBSD. + */ +#ifdef __FreeBSD__ +# define HAVE_MEMRCHR 1 +#endif + +/* Specific for MacOS. + */ +#ifdef __APPLE__ +# define HAVE_FSETXATTR_6 1 +# define HAVE_MACH_ABSOLUTE_TIME 1 +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Specific for FreeBSD and Linux. + */ +#if defined(__FreeBSD__) || defined(__linux__) +# define HAVE_MSG_NOSIGNAL 1 +# define HAVE_POLL_FINE 1 +#endif + +/* Specific for FreeBSD and Mac OS. + */ +#if defined(__FreeBSD__) || defined(__APPLE__) +# define HAVE_SYS_SOCKIO_H 1 +#endif + +/* Specific for Linux and Mac OS. + */ +#if defined(__linux__) || defined(__APPLE__) +# define HAVE_FSETXATTR 1 +#endif + +/* Specific for POSIX. + */ +#ifndef _WIN32 +# define HAVE_ARPA_INET_H 1 +# define HAVE_IFADDRS_H 1 +# define HAVE_NETDB_H 1 +# define HAVE_NETINET_IN_H 1 +# define HAVE_NETINET_TCP_H 1 +# define HAVE_NET_IF_H 1 +# define HAVE_POLL_H 1 +# define HAVE_PWD_H 1 +# define HAVE_ALARM 1 +# define HAVE_FCNTL_O_NONBLOCK 1 +# define HAVE_FNMATCH 1 +# define HAVE_GETEUID 1 +# define HAVE_GETIFADDRS 1 +# define HAVE_GETPWUID 1 +# define HAVE_GETPWUID_R 1 +# define HAVE_GETTIMEOFDAY 1 +# define HAVE_GMTIME_R 1 +# define HAVE_IF_NAMETOINDEX 1 +# define HAVE_IOCTL_FIONBIO 1 +# define HAVE_IOCTL_SIOCGIFADDR 1 +# define HAVE_PIPE 1 +# define HAVE_POSIX_STRERROR_R 1 +# define HAVE_SIGACTION 1 +# define HAVE_SIGSETJMP 1 +# define HAVE_SOCKETPAIR 1 +# define HAVE_STRERROR_R 1 +# define HAVE_SYS_IOCTL_H 1 +# define HAVE_SYS_POLL_H 1 +# define HAVE_SYS_SELECT_H 1 +# define HAVE_SYS_SOCKET_H 1 +# define HAVE_SYS_UN_H 1 +# define HAVE_SYS_WAIT_H 1 +# define HAVE_TERMIOS_H 1 +# define HAVE_UTIMES 1 +# define NTLM_WB_ENABLED 1 +# define USE_UNIX_SOCKETS 1 + +# define CURL_SA_FAMILY_T sa_family_t +# define GETHOSTNAME_TYPE_ARG2 size_t + +# define NTLM_WB_FILE "/usr/bin/ntlm_auth" +# define RANDOM_FILE "/dev/urandom" + +# define CURL_EXTERN_SYMBOL __attribute__ ((__visibility__ ("default"))) + +/* Specific for Windows. + */ +#else +# define HAVE_PROCESS_H 1 +# define HAVE_STRUCT_POLLFD 1 +# define USE_WIN32_CRYPTO 1 +# define HAVE_CLOSESOCKET 1 +# define HAVE_IOCTLSOCKET_FIONBIO 1 +# define HAVE_IO_H 1 +# define HAVE_SYS_UTIME_H 1 +# define HAVE_WINDOWS_H 1 +# define HAVE_WINSOCK2_H 1 +# define HAVE_WINSOCK_H 1 +# define USE_WIN32_IDN 1 +# define USE_WIN32_LARGE_FILES 1 +# define USE_WINDOWS_SSPI 1 +# define WANT_IDN_PROTOTYPES 1 + +# undef SOCKET +# undef USE_LWIPSOCK +# undef USE_WIN32_SMALL_FILES + +/* The upstream's logic of defining the macro is quite hairy. Let's not + * reproduce it here and see how it goes. + */ +# undef _WIN32_WINNT + +/* For these ones sensible defaults are defined in lib/curl_setup.h. + */ +# undef CURL_SA_FAMILY_T +# undef GETHOSTNAME_TYPE_ARG2 +# undef USE_WINSOCK + +/* Unused on Windows (see include/curl/curl.h for details). + */ +# undef CURL_EXTERN_SYMBOL +#endif + +/* Specific for GNU C Library. + */ +#ifdef __GLIBC__ +# define HAVE_GETHOSTBYNAME_R 1 +# define HAVE_GETHOSTBYNAME_R_6 1 +# undef HAVE_GETHOSTBYNAME_R_3 +# undef HAVE_GETHOSTBYNAME_R_5 +#endif + +/* Specific for (non-) VC. + */ +#ifndef _MSC_VER +# define HAVE_BASENAME 1 +# define HAVE_CLOCK_GETTIME_MONOTONIC 1 +# define HAVE_INET_NTOP 1 +# define HAVE_INET_PTON 1 +# define HAVE_LIBGEN_H 1 +# define HAVE_PTHREAD_H 1 +# define HAVE_SETJMP_H 1 +# define HAVE_SIGNAL 1 +# define HAVE_STRCASECMP 1 +# define HAVE_STRINGS_H 1 +# define HAVE_STRING_H 1 +# define HAVE_STRTOK_R 1 +# define HAVE_SYS_PARAM_H 1 +# define HAVE_SYS_TIME_H 1 +# define HAVE_UNISTD_H 1 +# define HAVE_UTIME_H 1 +# define HAVE_VARIADIC_MACROS_GCC 1 +# define TIME_WITH_SYS_TIME 1 +# define USE_THREADS_POSIX 1 +# undef USE_THREADS_WIN32 +#else +# define NEED_MALLOC_H 1 +# define USE_THREADS_WIN32 1 +# undef USE_THREADS_POSIX +#endif + +/* Common for all supported OSes/compilers. + */ +#define HAVE_ASSERT_H 1 +#define HAVE_STDBOOL_H 1 +#define HAVE_BOOL_T 1 +#define HAVE_ERRNO_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_WS2TCPIP_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_LOCALE_H 1 +#define HAVE_SETLOCALE 1 +#define HAVE_GETADDRINFO 1 +#define HAVE_FREEADDRINFO 1 +#define HAVE_GETADDRINFO_THREADSAFE 1 +#define HAVE_FTRUNCATE 1 +#define HAVE_GETHOSTBYNAME 1 +#define HAVE_GETHOSTNAME 1 +#define HAVE_GETPEERNAME 1 +#define HAVE_GETSOCKNAME 1 +#define HAVE_LONGLONG 1 +#define HAVE_OPENSSL_VERSION 1 +#define HAVE_SOCKET 1 +#define HAVE_SELECT 1 +#define HAVE_SIG_ATOMIC_T 1 +#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1 +#define HAVE_STRDUP 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 +#define HAVE_STRUCT_TIMEVAL 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_TIME_H 1 +#define HAVE_UTIME 1 +#define HAVE_VARIADIC_MACROS_C99 1 +#define STDC_HEADERS 1 + +#undef _ALL_SOURCE +#undef _LARGE_FILES +#undef HAVE_LBER_H +#undef HAVE_NETINET_IN6_H +#undef HAVE_GSSAPI_GSSAPI_GENERIC_H +#undef HAVE_GSSAPI_GSSAPI_H +#undef HAVE_IDN2_H +#undef HAVE_LIBIDN2 +#undef HAVE_BROTLI +#undef EGD_SOCKET +#undef DEBUGBUILD +#undef HAVE_DECL_GETPWUID_R_MISSING +#undef HAVE_GETPASS_R +#undef HAVE_GNUTLS_ALPN_SET_PROTOCOLS +#undef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 +#undef HAVE_GNUTLS_OCSP_REQ_INIT +#undef HAVE_GSSAPI +#undef HAVE_GSSGNU +#undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO +#undef HAVE_OLD_GSSMIT +#undef HAVE_PK11_CREATEMANAGEDGENERICOBJECT +#undef HAVE_PROTO_BSDSOCKET_H +#undef HAVE_RAND_EGD +#undef HAVE_SETSOCKOPT_SO_NONBLOCK +#undef HAVE_SIG_ATOMIC_T_VOLATILE +#undef HAVE_SSLV2_CLIENT_METHOD +#undef HAVE_STRCMPI +#undef HAVE_STROPTS_H +#undef HAVE_TERMIO_H +#undef HAVE_TIME_T_UNSIGNED +#undef HAVE_WOLFSSLV3_CLIENT_METHOD +#undef HAVE_WOLFSSL_GET_PEER_CERTIFICATE +#undef HAVE_WOLFSSL_USEALPN +#undef HAVE_WRITABLE_ARGV +#undef NEED_MEMORY_H +#undef NEED_REENTRANT +#undef NEED_THREAD_SAFE + +#undef CURLDEBUG +#undef HAVE_GETNAMEINFO +#undef GETNAMEINFO_QUAL_ARG1 +#undef GETNAMEINFO_TYPE_ARG1 +#undef GETNAMEINFO_TYPE_ARG2 +#undef GETNAMEINFO_TYPE_ARG46 +#undef GETNAMEINFO_TYPE_ARG7 + +#undef HAVE_RECVFROM +#undef RECVFROM_TYPE_ARG1 +#undef RECVFROM_TYPE_ARG2 +#undef RECVFROM_TYPE_ARG3 +#undef RECVFROM_TYPE_ARG4 +#undef RECVFROM_TYPE_ARG5 +#undef RECVFROM_TYPE_ARG6 +#undef RECVFROM_TYPE_RETV + +/* While upstream defines the macro for Clang, it fails to build for older + * version of Clang on Mac OS. Thus, we never define it. + */ +#undef HAVE_BUILTIN_AVAILABLE + +/* send() + */ +#define HAVE_SEND 1 +#ifndef _WIN32 +# define SEND_TYPE_ARG1 int +# define SEND_TYPE_ARG2 void * +# define SEND_TYPE_ARG3 size_t +# define SEND_TYPE_ARG4 int +# define SEND_TYPE_RETV ssize_t +#else +# define SEND_TYPE_ARG1 SOCKET +# define SEND_TYPE_ARG2 char * +# define SEND_TYPE_ARG3 int +# define SEND_TYPE_ARG4 int +# define SEND_TYPE_RETV int +#endif + +/* recv() + */ +#define HAVE_RECV 1 +#ifndef _WIN32 +# define RECV_TYPE_ARG1 int +# define RECV_TYPE_ARG2 void * +# define RECV_TYPE_ARG3 size_t +# define RECV_TYPE_ARG4 int +# define RECV_TYPE_RETV ssize_t +#else +# define RECV_TYPE_ARG1 SOCKET +# define RECV_TYPE_ARG2 char * +# define RECV_TYPE_ARG3 int +# define RECV_TYPE_ARG4 int +# define RECV_TYPE_RETV int +#endif + +/* Types and type sizes. + */ +#ifndef _WIN32 +# define SIZEOF_SHORT __SIZEOF_SHORT__ +# define SIZEOF_INT __SIZEOF_INT__ +# define SIZEOF_LONG __SIZEOF_LONG__ +# define SIZEOF_SIZE_T __SIZEOF_SIZE_T__ + +/* There is no way to exactly tell these type sizes at the preprocessing time, + * so we define them as the most probable ones. We check this assumption at + * the compile time using _Static_assert() in assert.c. + */ +# define SIZEOF_OFF_T __SIZEOF_LONG__ +# define SIZEOF_TIME_T __SIZEOF_LONG__ +#else +# define SIZEOF_SHORT 2 +# define SIZEOF_INT 4 +# define SIZEOF_LONG 4 +# define SIZEOF_OFF_T 4 +# ifdef _WIN64 +# define SIZEOF_TIME_T 8 +# define SIZEOF_SIZE_T 8 +# else +# define SIZEOF_TIME_T 8 +# define SIZEOF_SIZE_T 4 +# endif +# define in_addr_t unsigned long + +/* Inspired by lib/config-win32.h. + */ +# if defined(_MSC_VER) && !defined(_SSIZE_T_DEFINED) +# if defined(_WIN64) +# define ssize_t __int64 +# else +# define ssize_t int +# endif +# define _SSIZE_T_DEFINED +# endif +#endif + +/* Is always 8 bytes for any platform that provides a 64-bit signed integral + * data type (see include/curl/system.h for details) and we can parobably + * assume that's the case for the platforms we build for. We also check this + * at the compile time using _Static_assert() in assert.c. + */ +#define SIZEOF_CURL_OFF_T 8 + +#define RETSIGTYPE void +#define SEND_QUAL_ARG2 const + +/* We can probably assume that on platforms we build for, these keywords/types + * doesn't require definition. + +#undef const +#undef inline +#undef size_t +#undef ssize_t + +*/ + +#endif /* LIBCURL_CURL_CONFIG_H */ diff --git a/libcurl/libcurl/include b/libcurl/libcurl/include new file mode 120000 index 0000000..01fbb48 --- /dev/null +++ b/libcurl/libcurl/include @@ -0,0 +1 @@ +../../upstream/include \ No newline at end of file diff --git a/libcurl/libcurl/lib b/libcurl/libcurl/lib new file mode 120000 index 0000000..d06277d --- /dev/null +++ b/libcurl/libcurl/lib @@ -0,0 +1 @@ +../../upstream/lib \ No newline at end of file diff --git a/libcurl/libcurl/libcurl-symbols.expsym b/libcurl/libcurl/libcurl-symbols.expsym new file mode 100644 index 0000000..aada9a9 --- /dev/null +++ b/libcurl/libcurl/libcurl-symbols.expsym @@ -0,0 +1,82 @@ +_curl_easy_cleanup +_curl_easy_duphandle +_curl_easy_escape +_curl_easy_getinfo +_curl_easy_init +_curl_easy_pause +_curl_easy_perform +_curl_easy_recv +_curl_easy_reset +_curl_easy_send +_curl_easy_setopt +_curl_easy_strerror +_curl_easy_unescape +_curl_easy_upkeep +_curl_escape +_curl_formadd +_curl_formfree +_curl_formget +_curl_free +_curl_getdate +_curl_getenv +_curl_global_cleanup +_curl_global_init +_curl_global_init_mem +_curl_global_sslset +#_curl_jmpenv +_curl_maprintf +_curl_mfprintf +_curl_mime_addpart +_curl_mime_data +_curl_mime_data_cb +_curl_mime_encoder +_curl_mime_filedata +_curl_mime_filename +_curl_mime_free +_curl_mime_headers +_curl_mime_init +_curl_mime_name +_curl_mime_subparts +_curl_mime_type +_curl_mprintf +_curl_msnprintf +_curl_msprintf +_curl_multi_add_handle +_curl_multi_assign +_curl_multi_cleanup +_curl_multi_fdset +_curl_multi_info_read +_curl_multi_init +_curl_multi_perform +_curl_multi_poll +_curl_multi_remove_handle +_curl_multi_setopt +_curl_multi_socket +_curl_multi_socket_action +_curl_multi_socket_all +_curl_multi_strerror +_curl_multi_timeout +_curl_multi_wait +_curl_mvaprintf +_curl_mvfprintf +_curl_mvprintf +_curl_mvsnprintf +_curl_mvsprintf +_curl_pushheader_byname +_curl_pushheader_bynum +_curl_share_cleanup +_curl_share_init +_curl_share_setopt +_curl_share_strerror +_curl_slist_append +_curl_slist_free_all +_curl_strequal +_curl_strnequal +_curl_unescape +_curl_url +_curl_url_cleanup +_curl_url_dup +_curl_url_get +_curl_url_set +_curl_version +_curl_version_info diff --git a/libcurl/manifest b/libcurl/manifest new file mode 100644 index 0000000..9561078 --- /dev/null +++ b/libcurl/manifest @@ -0,0 +1,21 @@ +: 1 +name: libcurl +version: 7.67.0-a.0.z +project: curl +summary: C library for transferring data with URLs +license: cURL ; MIT/X derivate license. +topics: C, HTTP, FTP, URL, data transfer +description-file: README +url: https://curl.haxx.se/ +doc-url: https://curl.haxx.se/libcurl/c/ +src-url: https://git.build2.org/cgit/packaging/curl/curl/tree/libcurl/ +package-url: https://git.build2.org/cgit/packaging/curl/ +email: curl-library@cool.haxx.se ; Mailing list. +package-email: packaging@build2.org ; Mailing list. +build-email: builds@build2.org +builds: all +depends: * build2 >= 0.12.0 +depends: * bpkg >= 0.12.0 +depends: libz >= 1.2.1100 +depends: libcrypto >= 1.1.1 +depends: libssl >= 1.1.1 diff --git a/libcurl/tests/.gitignore b/libcurl/tests/.gitignore new file mode 100644 index 0000000..2e508a9 --- /dev/null +++ b/libcurl/tests/.gitignore @@ -0,0 +1,3 @@ +driver +test/ +test-*/ diff --git a/libcurl/tests/basic/buildfile b/libcurl/tests/basic/buildfile new file mode 100644 index 0000000..a01f5f2 --- /dev/null +++ b/libcurl/tests/basic/buildfile @@ -0,0 +1,7 @@ +# file : tests/basic/buildfile +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : cURL License; see accompanying COPYING file + +import libs = libcurl%lib{curl} + +exe{driver}: {h c}{*} $libs testscript diff --git a/libcurl/tests/basic/driver.c b/libcurl/tests/basic/driver.c new file mode 100644 index 0000000..8e78ba9 --- /dev/null +++ b/libcurl/tests/basic/driver.c @@ -0,0 +1,48 @@ +/* file : tests/basic/driver.c + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC + * license : cURL License; see accompanying COPYING file + */ +#include +#include + +#include + +/* Usage: argv[0] + * + * Request the specified URL and print the response to stdout. + */ +int +main (int argc, char* argv[]) +{ + assert (argc == 2); + + const char* url = argv[1]; + + curl_global_init (CURL_GLOBAL_DEFAULT); + + int r = 1; + + CURL* curl = curl_easy_init (); + + if (curl != NULL) + { + curl_easy_setopt (curl, CURLOPT_URL, url); + + CURLcode cr = curl_easy_perform (curl); + + if (cr == CURLE_OK) + r = 0; + else + fprintf (stderr, + "failed to request '%s': %s\n", + url, + curl_easy_strerror (cr)); + + curl_easy_cleanup (curl); + } + else + fprintf (stderr, "curl_easy_init() failed\n"); + + curl_global_cleanup (); + return r; +} diff --git a/libcurl/tests/basic/testscript b/libcurl/tests/basic/testscript new file mode 100644 index 0000000..a2260f4 --- /dev/null +++ b/libcurl/tests/basic/testscript @@ -0,0 +1,27 @@ +# file : tests/basic/testscript +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +: http +: +$* 'http://www.example.com' >>~%EOO% +%% +%.+ +EOO + +: https +: +: Test that an HTTPS URL is queried successfully via the system SSL backend +: on Windows and MacOS/Clang and fails for other targets that use the OpenSSL +: backend by default. +: +if ($c.target.class == 'windows' || \ + $c.target.class == 'macos' && $c.id == 'clang-apple') +{ + $* 'http://www.example.com' | set s; + $* 'https://www.example.com' >"$s" +} +else +{ + $* 'https://www.example.com' 2>~'%failed to request .+%' != 0 +} diff --git a/libcurl/tests/build/.gitignore b/libcurl/tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/libcurl/tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/libcurl/tests/build/bootstrap.build b/libcurl/tests/build/bootstrap.build new file mode 100644 index 0000000..d2722f1 --- /dev/null +++ b/libcurl/tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : tests/build/bootstrap.build +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +project = # Unnamed subproject. + +using config +using dist +using test diff --git a/libcurl/tests/build/root.build b/libcurl/tests/build/root.build new file mode 100644 index 0000000..a5f8fbe --- /dev/null +++ b/libcurl/tests/build/root.build @@ -0,0 +1,22 @@ +# file : tests/build/root.build +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +using c + +h{*}: extension = h +c{*}: extension = c + +if ($c.target.system == 'win32-msvc') + c.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($c.class == 'msvc') + c.coptions += /wd4251 /wd4275 /wd4800 + +# Every exe{} in this subproject is by default a test. +# +exe{*}: test = true + +# Specify the test target for cross-testing. +# +test.target = $c.target diff --git a/libcurl/tests/buildfile b/libcurl/tests/buildfile new file mode 100644 index 0000000..dcd3e02 --- /dev/null +++ b/libcurl/tests/buildfile @@ -0,0 +1,5 @@ +# file : tests/buildfile +# copyright : Copyright (c) 2016-2019 Code Synthesis Ltd +# license : cURL License; see accompanying COPYING file + +./: {*/ -build/} diff --git a/packages.manifest b/packages.manifest new file mode 100644 index 0000000..9cb33be --- /dev/null +++ b/packages.manifest @@ -0,0 +1,4 @@ +: 1 +location: libcurl/ +: +location: curl/ diff --git a/repositories.manifest b/repositories.manifest new file mode 100644 index 0000000..a42d607 --- /dev/null +++ b/repositories.manifest @@ -0,0 +1,14 @@ +: 1 +summary: cURL build2 package repository + +: +role: prerequisite +location: ../../openssl/openssl.git##HEAD + +: +role: prerequisite +location: ../ca-certificates-curl.git##HEAD + +: +role: prerequisite +location: ../../zlib/zlib.git##HEAD diff --git a/upstream b/upstream new file mode 160000 index 0000000..2e9b725 --- /dev/null +++ b/upstream @@ -0,0 +1 @@ +Subproject commit 2e9b725f67d49a9d7a1f053fe52dd4920c9ab1ad -- cgit v1.1