aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2023-07-09 17:01:43 -0400
committerAdam Harrison <adamdharrison@gmail.com>2023-07-09 17:01:43 -0400
commitc8390569f6eceedd71b7090ef52a4f88886bc475 (patch)
tree88a1a1159c3cbdf36eca2e58c8ed28fb85888fe7
parentc554678b9a08da51dec43a645bc420cc7fad445a (diff)
downloadlite-xl-plugin-manager-c8390569f6eceedd71b7090ef52a4f88886bc475.tar.gz
lite-xl-plugin-manager-c8390569f6eceedd71b7090ef52a4f88886bc475.zip
Updated LPM_DEFAULT_REPOSITORY to be a define, as well as fixed issue with downloading from domains without paths.
-rw-r--r--src/lpm.c7
-rw-r--r--src/lpm.lua9
2 files changed, 10 insertions, 6 deletions
diff --git a/src/lpm.c b/src/lpm.c
index c557542..005be6f 100644
--- a/src/lpm.c
+++ b/src/lpm.c
@@ -1128,7 +1128,9 @@ static const luaL_Reg system_lib[] = {
#ifndef LPM_VERSION
#define LPM_VERSION "unknown"
#endif
-
+#ifndef LPM_DEFAULT_REPO
+ #define LPM_DEFAULT_REPOSITORY "https://github.com/lite-xl/lite-xl-plugin-manager.git:latest"
+#endif
#ifndef ARCH_PROCESSOR
#if defined(__x86_64__) || defined(_M_AMD64) || defined(__MINGW64__)
@@ -1164,7 +1166,6 @@ static const luaL_Reg system_lib[] = {
#define LITE_ARCH_TUPLE ARCH_PROCESSOR "-" ARCH_PLATFORM
#endif
-
#ifdef LPM_STATIC
extern const char lpm_luac[];
extern unsigned int lpm_luac_len;
@@ -1195,6 +1196,8 @@ int main(int argc, char* argv[]) {
lua_setglobal(L, "PATHSEP");
lua_pushliteral(L, LITE_ARCH_TUPLE);
lua_setglobal(L, "ARCH");
+ lua_pushliteral(L, LPM_DEFAULT_REPOSITORY);
+ lua_setglobal(L, "DEFAULT_REPO_URL");
#ifndef LPM_STATIC
if (luaL_loadfile(L, "src/lpm.lua") || lua_pcall(L, 0, 1, 0)) {
#else
diff --git a/src/lpm.lua b/src/lpm.lua
index 5239797..2c66de1 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -552,6 +552,7 @@ function common.get(source, target, checksum, callback, depth)
log_progress_action("Downloading " .. source:sub(1, 100) .. "...")
if not protocol then error("malfomed url " .. source) end
if not port or port == "" then port = protocol == "https" and 443 or 80 end
+ if not rest or rest == "" then rest = "/" end
if not checksum then
local res, headers = system.get(protocol, hostname, port, rest, target, callback)
if headers.location then return common.get(headers.location, target, checksum, callback, (depth or 0) + 1) end
@@ -1466,7 +1467,7 @@ end
local DEFAULT_REPOS
local function lpm_repo_init(repos)
- DEFAULT_REPOS = { Repository.url("https://github.com/adamharrison/lite-xl-plugin-manager.git:latest") }
+ DEFAULT_REPOS = { Repository.url(DEFAULT_REPO_URL) }
common.mkdirp(CACHEDIR)
if not system.stat(CACHEDIR .. PATHSEP .. "settings.json") then
for i, repository in ipairs(repos or DEFAULT_REPOS) do
@@ -1906,9 +1907,9 @@ It's designed to install packages from our central github repository (and
affiliated repositories), directly into your lite-xl user directory. It can
be called independently, or from the lite-xl `plugin_manager` addon.
-LPM will always use https://github.com/lite-xl/lite-xl-plugin-manager as its base
-repository, if none are present, and the cache directory does't exist,
-but others can be added, and this base one can be removed.
+LPM will always use ]] .. DEFAULT_REPO_URL .. [[
+as its base repository, if none are present, and the cache directory
+does't exist, but others can be added, and this base one can be removed.
It has the following commands: