aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lpm.c18
-rw-r--r--src/lpm.lua6
2 files changed, 22 insertions, 2 deletions
diff --git a/src/lpm.c b/src/lpm.c
index 60e1c07..7d1b4a9 100644
--- a/src/lpm.c
+++ b/src/lpm.c
@@ -354,6 +354,7 @@ static int lpm_init(lua_State* L) {
static int no_verify_ssl = 0;
static int has_setup_ssl = 0;
+static int print_trace = 0;
static mbedtls_x509_crt x509_certificate;
static mbedtls_entropy_context entropy_context;
static mbedtls_ctr_drbg_context drbg_context;
@@ -418,6 +419,17 @@ static void lpm_tls_debug(void *ctx, int level, const char *file, int line, cons
fflush(stderr);
}
+static void lpm_libgit2_debug(git_trace_level_t level, const char *msg) {
+ fprintf(stderr, "[libgit2]: %s\n", msg);
+ fflush(stderr);
+}
+
+static int lpm_trace(lua_State* L) {
+ int trace = lua_toboolean(L, 1);
+ print_trace = trace ? 1 : 0;
+ return 0;
+}
+
static int lpm_certs(lua_State* L) {
const char* type = luaL_checkstring(L, 1);
int status;
@@ -441,9 +453,12 @@ static int lpm_certs(lua_State* L) {
mbedtls_ssl_conf_authmode(&ssl_config, MBEDTLS_SSL_VERIFY_REQUIRED);
mbedtls_ssl_conf_rng(&ssl_config, mbedtls_ctr_drbg_random, &drbg_context);
mbedtls_ssl_conf_read_timeout(&ssl_config, 5000);
- #if defined(MBEDTLS_DEBUG_C) && defined(LPM_MBEDTLS_DEBUG)
+ #if defined(MBEDTLS_DEBUG_C)
+ if (print_trace) {
mbedtls_debug_set_threshold(5);
mbedtls_ssl_conf_dbg(&ssl_config, lpm_tls_debug, NULL);
+ git_trace_set(GIT_TRACE_TRACE, lpm_libgit2_debug);
+ }
#endif
has_setup_ssl = 1;
if (strcmp(type, "noverify") == 0) {
@@ -841,6 +856,7 @@ static const luaL_Reg system_lib[] = {
{ "reset", lpm_reset }, // Updates a git repository to the specified commit/hash/branch.
{ "get", lpm_get }, // HTTP(s) GET request.
{ "extract", lpm_extract }, // Extracts .tar.gz, and .zip files.
+ { "trace", lpm_trace }, // Sets trace bit.
{ "certs", lpm_certs }, // Sets the SSL certificate chain folder/file.
{ "chdir", lpm_chdir }, // Changes directory. Only use for --post actions.
{ "pwd", lpm_pwd }, // Gets existing directory. Only use for --post actions.
diff --git a/src/lpm.lua b/src/lpm.lua
index 08e0eaa..10d4022 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -1516,7 +1516,7 @@ xpcall(function()
json = "flag", userdir = "string", cachedir = "string", version = "flag", verbose = "flag",
quiet = "flag", version = "string", ["mod-version"] = "string", remotes = "flag", help = "flag",
remotes = "flag", ssl_certs = "string", force = "flag", arch = "string", ["assume-yes"] = "flag",
- ["install-optional"] = "flag", datadir = "string", binary = "string"
+ ["install-optional"] = "flag", datadir = "string", binary = "string", trace = "flag"
})
if ARGS["version"] then
io.stdout:write(VERSION .. "\n")
@@ -1614,6 +1614,9 @@ Flags have the following effects:
to all.
--no-install-optional On install, anything marked as optional
won't prompt.
+ --trace Dumps to STDERR useful debugging information, in
+ particular information relating to SSL connections,
+ and other network activity.
There also several flags which are classified as "risky", and are never enabled
in any circumstance unless explicitly supplied.
@@ -1651,6 +1654,7 @@ in any circumstance unless explicitly supplied.
if not system.stat(USERDIR) then common.mkdirp(USERDIR) end
CACHEDIR = common.normalize_path(ARGS["cachedir"]) or os.getenv("LPM_CACHE") or USERDIR .. PATHSEP .. "lpm"
TMPDIR = common.normalize_path(ARGS["tmpdir"]) or CACHEDIR .. PATHSEP .. "tmp"
+ if ARGS["trace"] then system.trace(true) end
repositories = {}
if ARGS[2] == "purge" then return lpm_purge() end