diff options
Diffstat (limited to 'src/lpm.lua')
-rw-r--r-- | src/lpm.lua | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/lpm.lua b/src/lpm.lua index 6303354..18d34bc 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -373,6 +373,7 @@ function common.sort(t, f) table.sort(t, f) return t end function common.write(path, contents) local f, err = io.open(path, "wb") if not f then error("can't write to " .. path .. ": " .. err) end f:write(contents) f:flush() f:close() end function common.read(path) local f, err = io.open(path, "rb") if not f then error("can't read from " .. path .. ": " .. err) end return f:read("*all") end function common.uniq(l) local t = {} local k = {} for i,v in ipairs(l) do if not k[v] then table.insert(t, v) k[v] = true end end return t end +function common.delete(h, d) local t = {} for k,v in pairs(h) do if k ~= d then t[k] = v end end return t end function common.split(splitter, str) local o = 1 local res = {} @@ -667,6 +668,7 @@ function Addon:unstub() local remote_entry = common.grep(manifest['addons'] or manifest['plugins'], function(e) return e.id == self.id end)[1] if not remote_entry then error("can't find " .. self.type .. " on " .. self.remote) end local addon = Addon.new(repo, remote_entry) + -- merge in attribtues that are probably more accurate than the stub if addon.version ~= self.version then log_warning(self.id .. " stub on " .. self.repository:url() .. " has differing version from remote (" .. self.version .. " vs " .. addon.version .. "); may lead to install being inconsistent") end -- if addon.mod_version ~= self.mod_version then log_warning(self.id .. " stub on " .. self.repository:url() .. " has differing mod_version from remote (" .. self.mod_version .. " vs " .. addon.mod_version .. ")") end @@ -1094,15 +1096,26 @@ function Repository:generate_manifest(repo_id) if file:find("%.lua$") then local filename = common.basename(file):gsub("%.lua$", "") local name = filename - if repo_id and name == "init" then name = repo_id end + if name == "init" then name = repo_id or common.basename(self.remote) end if name ~= "init" then local type = folder == "colors" and "color" or (folder == "libraries" and "library" or "plugin") local addon = { description = nil, id = name:lower():gsub("[^a-z0-9%-_]", ""), name = name, mod_version = LATEST_MOD_VERSION, version = "0.1", path = (filename ~= "init" and (addon_dir .. PATHSEP .. file) or nil), type = type } for line in io.lines(path .. PATHSEP .. addon_dir .. PATHSEP .. file) do local _, _, mod_version = line:find("%-%-.*mod%-version:%s*(%w+)") if mod_version then addon.mod_version = mod_version end - local _, _, required_addon = line:find("require [\"']plugins.([%w_-]+)") - if required_addon and not CORE_PLUGINS[required_addon] then if required_addon ~= addon.id then if not addon.dependencies then addon.dependencies = {} end addon.dependencies[required_addon] = ">=0.1" end end + local _, _, required_addon = line:find("require [\"']plugins%.([%w_-]+)") + if required_addon and not CORE_PLUGINS[required_addon] then + if required_addon ~= addon.id then + if not addon.dependencies then addon.dependencies = {} end + addon.dependencies[required_addon] = ">=0.1" + end + end + local _, _, name_override = line:find("config%.plugins%.([%w_-]+)%s*=%s*common%.merge") + if not repo_id and name_override then + addon.name = name_override + addon.id = name_override:lower():gsub("[^a-z0-9%-_]", "") + addon.dependencies = common.delete(addon.dependencies, addon.id) + end end if addon_map[addon.id] then addon = common.merge(addon, addon_map[addon.id]) @@ -1423,7 +1436,8 @@ function Bottle:all_addons() local_path = path, mod_version = self.lite_xl.mod_version, path = addon_type .. PATHSEP .. v, - description = (hash[id] and hash[id][1].description or nil) + description = (hash[id] and hash[id][1].description or nil), + repo_path = (hash[id] and hash[id][1].local_path or nil) })) end end @@ -1788,6 +1802,7 @@ local function print_addon_info(type, addons, filters) organization = addon.organization, repository = addon.repository and addon.repository:url(), path = addon:get_path(system_bottle), + repo_path = addon.repo_path, url = url } if addon_matches_filter(hash, filters or {}) then @@ -1955,7 +1970,7 @@ local function run_command(ARGS) elseif (ARGS[2] == "plugin" or ARGS[2] == "color" or ARGS[2] == "library") and (#ARGS == 2 or ARGS[3] == "list") then return lpm_addon_list(ARGS[2], ARGS[4], ARGS) elseif ARGS[2] == "upgrade" then return lpm_addon_upgrade(table.unpack(common.slice(ARGS, 3))) elseif ARGS[2] == "install" then lpm_install(nil, table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "unstub" then lpm_unstub(nil, table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "unstub" then return lpm_unstub(nil, table.unpack(common.slice(ARGS, 3))) elseif ARGS[2] == "uninstall" then lpm_addon_uninstall(nil, table.unpack(common.slice(ARGS, 3))) elseif ARGS[2] == "reinstall" then lpm_addon_reinstall(nil, table.unpack(common.slice(ARGS, 3))) elseif ARGS[2] == "describe" then lpm_describe(nil, table.unpack(common.slice(ARGS, 3))) |