aboutsummaryrefslogtreecommitdiff
path: root/bpkg/fetch.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'bpkg/fetch.hxx')
-rw-r--r--bpkg/fetch.hxx89
1 files changed, 79 insertions, 10 deletions
diff --git a/bpkg/fetch.hxx b/bpkg/fetch.hxx
index 36b1b01..daf1ffe 100644
--- a/bpkg/fetch.hxx
+++ b/bpkg/fetch.hxx
@@ -1,5 +1,4 @@
// file : bpkg/fetch.hxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#ifndef BPKG_FETCH_HXX
@@ -7,8 +6,6 @@
#include <ctime> // time_t
-#include <libbutl/process.mxx>
-
#include <libbpkg/manifest.hxx>
#include <bpkg/types.hxx>
@@ -21,6 +18,9 @@ namespace bpkg
// Repository type pkg (fetch-pkg.cxx).
//
+ // If HTTP proxy is specified via the --pkg-proxy option, then use it for
+ // fetching manifests and archives from the remote pkg repository.
+ //
pkg_repository_manifests
pkg_fetch_repositories (const dir_path&, bool ignore_unknown);
@@ -102,18 +102,29 @@ namespace bpkg
const repository_location&,
const dir_path&);
+
+ // Verify that the symlinks target paths in the working tree are valid,
+ // relative, and none of them refer outside the repository directory.
+ //
+ void
+ git_verify_symlinks (const common_options&, const dir_path&);
+
// Fix up or revert the fixes (including in submodules, recursively) in a
// working tree previously checked out by git_checkout() or
// git_checkout_submodules(). Return true if any changes have been made to
- // the filesystem.
+ // the filesystem. On error issue diagnostics and return nullopt in the
+ // ignore errors mode and throw failed otherwise.
//
// Noop on POSIX. On Windows it may replace git's filesystem-agnostic
// symlinks with hardlinks for the file targets and junctions for the
// directory targets. Note that it still makes sure the working tree is
// being treated by git as "clean" despite the changes.
//
- bool
- git_fixup_worktree (const common_options&, const dir_path&, bool revert);
+ optional<bool>
+ git_fixup_worktree (const common_options&,
+ const dir_path&,
+ bool revert,
+ bool ignore_errors = false);
// Low-level fetch API (fetch.cxx).
//
@@ -121,13 +132,71 @@ namespace bpkg
// Start the process of fetching the specified URL. If out is empty, then
// fetch to stdout. In this case also don't show any progress unless we are
// running verbose. If user_agent is empty, then send the default (fetch
- // program specific) User-Agent header value.
+ // program specific) User-Agent header value. If the HTTP proxy URL is not
+ // empty and the URL to fetch is HTTP(S), then fetch it via the specified
+ // proxy server converting the https URL scheme to http (see the --pkg-proxy
+ // option for details).
//
- butl::process
- start_fetch (const common_options& o,
+ process
+ start_fetch (const common_options&,
const string& url,
const path& out = {},
- const string& user_agent = {});
+ const string& user_agent = {},
+ const butl::url& proxy = {});
+
+ // Similar to the above but can only be used for fetching HTTP(S) URL to a
+ // file. Additionally return the HTTP status code, if the underlying fetch
+ // program provides an easy way to retrieve it, and 0 otherwise.
+ //
+ pair<process, uint16_t>
+ start_fetch_http (const common_options&,
+ const string& url,
+ const path& out,
+ const string& user_agent = {},
+ const butl::url& proxy = {});
+
+ // As above but fetches HTTP(S) URL to stdout, which can be read by the
+ // caller from the specified stream. On HTTP errors (e.g., 404) this stream
+ // may contain the error description returned by the server and the process
+ // may exit with 0 code.
+ //
+ // Fetch process stderr redirect mode.
+ //
+ enum class stderr_mode
+ {
+ // Don't redirect stderr.
+ //
+ pass,
+
+ // If the underlying fetch program provides an easy way to retrieve the
+ // HTTP status code, then redirect the fetch process stderr to a pipe, so
+ // that depending on the returned status code the caller can either drop
+ // or dump the fetch process diagnostics. Otherwise, may still redirect
+ // stderr for some implementation-specific reasons (to prevent the
+ // underlying fetch program from interacting with the user, etc). The
+ // caller can detect whether stderr is redirected or not by checking
+ // process::in_efd.
+ //
+ redirect,
+
+ // As above but if stderr is redirected, minimize the amount of
+ // diagnostics printed by the fetch program by only printing errors. That
+ // allows the caller to read stdout and stderr streams sequentially in the
+ // blocking mode by assuming that the diagnostics always fits into the
+ // pipe buffer. If stderr is not redirected, then ignore this mode in
+ // favor of the more informative diagnostics.
+ //
+ redirect_quiet
+ };
+
+ pair<process, uint16_t>
+ start_fetch_http (const common_options&,
+ const string& url,
+ ifdstream& out,
+ fdstream_mode out_mode,
+ stderr_mode,
+ const string& user_agent = {},
+ const butl::url& proxy = {});
}
#endif // BPKG_FETCH_HXX