diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2022-12-31 16:07:36 -0500 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2022-12-31 16:07:36 -0500 |
commit | 71e1d5f3534ea1663d136fef238f7d4786ed15bd (patch) | |
tree | d7ba614364aa805cc1b0a81d9e05a56fd28716c7 | |
parent | 1f03811ff2fb168679c5d3add8574d6ddf986f34 (diff) | |
download | lite-xl-plugin-manager-71e1d5f3534ea1663d136fef238f7d4786ed15bd.tar.gz lite-xl-plugin-manager-71e1d5f3534ea1663d136fef238f7d4786ed15bd.zip |
Added in --trace flag.
-rw-r--r-- | .github/workflows/build.yml | 5 | ||||
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | src/lpm.c | 18 | ||||
-rw-r--r-- | src/lpm.lua | 6 |
4 files changed, 28 insertions, 9 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 018125c..a8dbc5f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,9 +57,8 @@ jobs: env: { GITHUB_TOKEN: "${{ github.token }}" } run: | ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$VERSION-x86_64-darwin-`git rev-parse --short HEAD`'"' && tar -czvf lpm-$VERSION-x86_64-darwin.tar.gz lpm - cp lpm lpm.x86_64-darwin - gh release upload continuous lpm.x86_64-darwin + gh release upload continuous *.tar.gz if [[ `git tag --points-at HEAD | head -c 4` == "v"* ]]; then export RELEASE=`git tag --points-at HEAD | head -c 4 | sed 's/^v//'` - gh release upload v$RELEASE lpm.x86_64-darwin + gh release upload v$RELEASE *.tar.gz fi @@ -84,15 +84,15 @@ lpm uninstall aligncarets lpm --help ``` -## Building +## Building & Running -### Linux +### Linux & MacOS & Windows MSYS ``` -./build.sh -DLPM_STATIC -DLPM_VERSION='"'0.1-x86_64-linux-`git rev-parse --short HEAD`'"' +./build.sh && ./lpm ``` -### Linux to Windows +### Linux -> Windows ``` CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-gcc-ar WINDRES=x86_64-w64-mingw32-windres @@ -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 |