diff options
-rw-r--r-- | README.md | 4 | ||||
-rwxr-xr-x | build.sh | 2 | ||||
-rw-r--r-- | lpm.c | 11 | ||||
-rw-r--r-- | lpm.lua | 22 | ||||
-rw-r--r-- | plugins/plugin_manager/init.lua | 9 |
5 files changed, 29 insertions, 19 deletions
@@ -43,11 +43,11 @@ lpm rm https://github.com/lite-xl/lite-xl-plugins.git ### Linux ``` -./build.sh -DLPM_VERSION='"'$VERSION-x86_64-linux-`git rev-parse --short HEAD`'"' +VERSION=0.1 ./build.sh -DLPM_VERSION='"'$VERSION-x86_64-linux-`git rev-parse --short HEAD`'"' ``` ### Linux to Windows ``` -CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-gcc-ar WINDRES=x86_64-w64-mingw32-windres CURL_CONFIGURE="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_SYSTEM_NAME=Windows" GIT2_CONFIGURE="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DBUILD_CLAR=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_SYSTEM_NAME=Windows -DDLLTOOL=x86_64-w64-mingw32-dlltool" SSL_CONFIGURE=mingw ./build.sh -DLPM_VERSION='"'$VERSION-x86_64-linux-`git rev-parse --short HEAD`'"' +VERSION=0.1 CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-gcc-ar WINDRES=x86_64-w64-mingw32-windres CURL_CONFIGURE="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_SYSTEM_NAME=Windows" GIT2_CONFIGURE="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DBUILD_CLAR=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_SYSTEM_NAME=Windows -DDLLTOOL=x86_64-w64-mingw32-dlltool" SSL_CONFIGURE=mingw ./build.sh -DLPM_VERSION='"'$VERSION-x86_64-windows-`git rev-parse --short HEAD`'"' ``` @@ -26,7 +26,7 @@ if [[ "$@" != *"-lgit2"* ]]; then LDFLAGS="-Llib/libgit2/build -l:libgit2.a $LDFLAGS -Llib/prefix/lib -Llib/prefix/lib64" && CFLAGS="$CFLAGS -Ilib/prefix/include" fi if [[ "$@" != *"-lcurl"* ]]; then - [ ! -e "lib/curl/build" ] && cd lib/curl && mkdir build && cd build && cmake .. $CURL_CONFIGURE -DCURL_DISABLE_LDAPS=ON -DCURL_DISABLE_LDAP=ON -DCMAKE_INSTALL_PREFIX=`pwd`/../../prefix -DUSE_LIBIDN2=OFF -DENABLE_UNICODE=OFF -DBUILD_CURL_EXE=OFF -DCURL_USE_LIBSSH2=OFF -DOPENSSL_ROOT_DIR=`pwd`/../../prefix -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_LIBDIR=lib && $MAKE -j $JOBS && $MAKE install && cd ../../../ + [ ! -e "lib/curl/build" ] && cd lib/curl && mkdir build && cd build && cmake .. $CURL_CONFIGURE -DCURL_DISABLE_LDAPS=ON -DUSE_OPENSSL=ON -DCURL_DISABLE_LDAP=ON -DCMAKE_INSTALL_PREFIX=`pwd`/../../prefix -DUSE_LIBIDN2=OFF -DENABLE_UNICODE=OFF -DBUILD_CURL_EXE=OFF -DCURL_USE_LIBSSH2=OFF -DOPENSSL_ROOT_DIR=`pwd`/../../prefix -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_LIBDIR=lib && $MAKE -j $JOBS && $MAKE install && cd ../../../ LDFLAGS="-Llib/curl/build -Llib/prefix/lib -l:libcurl.a $LDFLAGS" && CFLAGS="$CFLAGS -Ilib/prefix/include -DCURL_STATICLIB" fi [[ "$@" != *"-llua"* ]] && CFLAGS="$CFLAGS -Ilib/lua -DMAKE_LIB=1" && SRCS="$SRCS lib/lua/onelua.c" @@ -430,6 +430,9 @@ static int lpm_get(lua_State* L) { // curl_easy_reset(curl); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); + #ifdef _WIN32 + curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA); + #endif if (path) { FILE* file = fopen(path, "wb"); if (!file) @@ -439,12 +442,12 @@ static int lpm_get(lua_State* L) { CURLcode res = curl_easy_perform(curl); if (res != CURLE_OK) { fclose(file); - return luaL_error(L, "curl error: %d", res); + return luaL_error(L, "curl error accessing %s: %s", url, curl_easy_strerror(res)); } fclose(file); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); if (response_code != 200) - return luaL_error(L, "curl error, non-200 response code: %d", response_code); + return luaL_error(L, "curl error accessing %s, non-200 response code: %d", url, response_code); lua_pushnil(L); lua_newtable(L); return 2; @@ -455,10 +458,10 @@ static int lpm_get(lua_State* L) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, &B); CURLcode res = curl_easy_perform(curl); if (res != CURLE_OK) - return luaL_error(L, "curl error: %d", res); + return luaL_error(L, "curl error accessing %s: %s", url, curl_easy_strerror(res)); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); if (response_code != 200) - return luaL_error(L, "curl error, non-200 response code: %d", response_code); + return luaL_error(L, "curl error accessing %s, non-200 response code: %d", url, response_code); luaL_pushresult(&B); lua_newtable(L); } @@ -384,7 +384,7 @@ end function common.basename(path) - local s = path:reverse():find(PATHSEP) + local s = path:reverse():find("[/\\]") if not s then return path end return path:sub(#path - s + 2) end @@ -459,7 +459,7 @@ local function is_commit_hash(hash) end -local HOME, USERDIR, CACHEDIR, JSON, VERBOSE, MOD_VERSION, QUIET, FORCE, AUTO_PULL_REMOTES, ARCH, ASSUME_YES, repositories +local HOME, USERDIR, CACHEDIR, JSON, VERBOSE, MOD_VERSION, QUIET, FORCE, AUTO_PULL_REMOTES, ARCH, ASSUME_YES, INSTALL_OPTIONAL, repositories local actions, warnings = {}, {} local function log_action(message) @@ -504,6 +504,7 @@ function Plugin.__index(self, idx) return rawget(self, idx) or Plugin[idx] end function Plugin.new(repository, metadata) local type = metadata.type or "plugin" local folder = metadata.type == "library" and "libraries" or "plugins" + if metadata.path then metadata.path = metadata.path:gsub("/", PATHSEP) end local self = setmetatable(common.merge({ repository = repository, tags = {}, @@ -517,7 +518,7 @@ function Plugin.new(repository, metadata) install_path = USERDIR .. PATHSEP .. folder .. PATHSEP .. (metadata.path and common.basename(metadata.path):gsub("%.lua$", "") or metadata.name), }, metadata), Plugin) -- Directory. - self.organization = ((self.files and #self.files > 0) or self.remote or not self.path) and "complex" or "singleton" + self.organization = ((self.files and #self.files > 0) or self.remote or (not self.path and not self.url)) and "complex" or "singleton" if self.organization == "singleton" then self.install_path = self.install_path .. ".lua" end local stat = system.stat(self.install_path) local compatible = (not metadata.mod_version or tonumber(metadata.mod_version) == tonumber(MOD_VERSION)) @@ -640,10 +641,10 @@ function Plugin:install(installing) if self.organization == "complex" and self.path and system.stat(self.local_path).type ~= "dir" then common.mkdirp(self.install_path) end if self.url then log_action("Downloading file " .. self.url .. "...") - local path = self.install_path .. (self.organization == 'complex' and (PATHSEP .. "init.lua") or "") - system.get(file.url, path) + local path = self.install_path .. (self.organization == 'complex' and self.path and system.stat(self.local_path).type ~= "dir" and (PATHSEP .. "init.lua") or "") + system.get(self.url, path) log_action("Downloaded file " .. self.url .. " to " .. path) - if system.hash(path, "file") ~= file.checksum then fatal_warning("checksum doesn't match for " .. path) end + if system.hash(path, "file") ~= self.checksum then fatal_warning("checksum doesn't match for " .. path) end elseif self.remote then log_action("Cloning repository " .. self.remote .. " into " .. self.install_path) common.mkdirp(self.install_path) @@ -1108,7 +1109,8 @@ xpcall(function() local ARGS = parse_arguments(ARGV, { 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" + remotes = "flag", ssl_certs = "string", force = "flag", arch = "string", ["assume-yes"] = "flag", + ["install-optional"] = "flag" }) if ARGS["version"] then io.stdout:write(VERSION .. "\n") @@ -1128,7 +1130,8 @@ affiliated repositories), directly into your lite-xl user directory. It can be called independently, for from the lite-xl `plugin_manager` plugin. LPM will always use https://github.com/lite-xl/lite-xl-plugins as its base -repository, though others can be added. +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: @@ -1170,6 +1173,8 @@ Flags have the following effects: --arch Overrides the inferred architecture (default: ]] .. _G.ARCH .. [[). --force Ignores checksum inconsitencies. Not recommended. --assume-yes Ignores any prompts, and automatically answers yes to all. + --install-optional On install, any dependencies marked as optional that can be installed + will be installled. ]] ) return 0 @@ -1179,6 +1184,7 @@ Flags have the following effects: JSON = ARGS["json"] or os.getenv("LPM_JSON") QUIET = ARGS["quiet"] or os.getenv("LPM_QUIET") FORCE = ARGS["force"] + INSTALL_OPTIONAL = ARGS["install-optional"] ARCH = ARGS["arch"] or _G.ARCH ASSUME_YES = ARGS["assume-yes"] or FORCE MOD_VERSION = ARGS["mod-version"] or os.getenv("LPM_MODVERSION") or 3 diff --git a/plugins/plugin_manager/init.lua b/plugins/plugin_manager/init.lua index 0520030..20a5b9d 100644 --- a/plugins/plugin_manager/init.lua +++ b/plugins/plugin_manager/init.lua @@ -11,8 +11,9 @@ local PluginManager = { last_refresh = nil, requires_restart = false } +local binary_extension = (PLATFORM == "Windows" and ".exe" or "") config.plugins.plugin_manager = common.merge({ - lpm_binary_name = "lpm." .. ARCH .. (PLATFORM == "Windows" and ".exe" or ""), + lpm_binary_name = "lpm." .. ARCH .. binary_extension, lpm_binary_path = nil, -- Restarts the plugin manager on changes. restart_on_change = true, @@ -34,13 +35,13 @@ if not config.plugins.plugin_manager.lpm_binary_path then local paths = { DATADIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. config.plugins.plugin_manager.lpm_binary_name, DATADIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. config.plugins.plugin_manager.lpm_binary_name, - USERDIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. "lpm", - USERDIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. "lpm", + USERDIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. "lpm" .. binary_extension, + USERDIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. "lpm" .. binary_extension, } local path, s = os.getenv("PATH"), 1 while true do local _, e = path:find(":", s) - table.insert(paths, path:sub(s, e and (e-1) or #path) .. PATHSEP .. "lpm") + table.insert(paths, path:sub(s, e and (e-1) or #path) .. PATHSEP .. "lpm" .. binary_extension) if not e then break end s = e + 1 end |