Compare commits

...

2 Commits

Author SHA1 Message Date
p2vman 4f545783ac a 2025-04-26 16:26:20 +03:00
p2vman bc0f759850 init2 2025-04-26 16:19:54 +03:00
1 changed files with 18 additions and 5 deletions

View File

@ -3,14 +3,14 @@
Supports multiple repositories, dependency resolution, index and package caching. Supports multiple repositories, dependency resolution, index and package caching.
]] ]]
local PKG = {} local CKG = {}
local INSTALL_DIR = "/ckg" local INSTALL_DIR = "/ckg"
local CACHE_DIR = fs.combine(INSTALL_DIR, "cache") local CACHE_DIR = fs.combine(INSTALL_DIR, "cache")
local REPO_CACHE_DIR = fs.combine(CACHE_DIR, "repos") local REPO_CACHE_DIR = fs.combine(CACHE_DIR, "repos")
local CONFIG_FILE = fs.combine(INSTALL_DIR, "config.txt") local CONFIG_FILE = fs.combine(INSTALL_DIR, "config.txt")
local DEFAULT_REPOS = { local DEFAULT_REPOS = {
"https://example.com/repo/packages.json" "http://193.23.220.51:3000/p2vman/cpkg/raw/branch/main/packages.json"
} }
local function load_config() local function load_config()
@ -85,7 +85,14 @@ local function install_single(name, list, installed)
if installed[name] then return end if installed[name] then return end
local pkg = list[name] local pkg = list[name]
if not pkg then if not pkg then
error("Package not found: " .. name) local cfg = load_config()
print("Package not found. Updating repositories...")
CKG.update()
list = fetch_package_lists(cfg)
pkg = list[name]
if not pkg then
error("Package still not found: " .. name)
end
end end
if pkg.dependencies then if pkg.dependencies then
@ -129,7 +136,13 @@ function CKG.fetch(name)
local list = fetch_package_lists(cfg) local list = fetch_package_lists(cfg)
local pkg = list[name] local pkg = list[name]
if not pkg then if not pkg then
error("Package not found: " .. name) print("Package not found. Updating repositories...")
CKG.update()
list = fetch_package_lists(cfg)
pkg = list[name]
if not pkg then
error("Package still not found: " .. name)
end
end end
if not fs.exists(CACHE_DIR) then fs.makeDir(CACHE_DIR) end if not fs.exists(CACHE_DIR) then fs.makeDir(CACHE_DIR) end
local cache_path = fs.combine(CACHE_DIR, name) local cache_path = fs.combine(CACHE_DIR, name)