Browse Source

Attempting to add cascadingrepository lookup

environments/development/deployments/43
Drew Short 7 years ago
parent
commit
bbb9a0d560
  1. 5
      src/bootstrap.moon
  2. 3
      src/repos.cfg
  3. 7
      src/spm/spm.cfg
  4. 15
      src/spm/spm.moon

5
src/bootstrap.moon

@ -13,8 +13,13 @@ if not component.isAvailable("internet")
downloadSrc = "{URL_BASE}/spm/spm.min.lua" downloadSrc = "{URL_BASE}/spm/spm.min.lua"
saveLocation = "/tmp/spm.lua" saveLocation = "/tmp/spm.lua"
downloadCfgSrc = "{URL_BASE}/spm/spm.cfg"
saveCfgLocation = "/etc/spm.cfg"
print("Downloading Temporary SPM") print("Downloading Temporary SPM")
wget("-qf", downloadSrc, saveLocation) wget("-qf", downloadSrc, saveLocation)
if not fs.exists(saveCfgLocation)
wget("-qf", downloadCfgSrc, saveCfgLocation)
spm = loadfile(saveLocation) spm = loadfile(saveLocation)

3
src/repos.cfg

@ -5,4 +5,7 @@
["Warrick's Software"] = { ["Warrick's Software"] = {
src = "{URL_BASE}/warricksothr" src = "{URL_BASE}/warricksothr"
} }
["OPPM Repositories"] = {
link = "https://raw.githubusercontent.com/OpenPrograms/openprograms.github.io/master/repos.cfg"
}
} }

7
src/spm/spm.cfg

@ -0,0 +1,7 @@
{
--default installation path
path="/usr",
--Additional repositories and packages go here, for correct package syntax, check https://github.com/OpenPrograms/Vexatos-Programs/blob/master/oppm/etc/example-config.cfg
repos={
}
}

15
src/spm/spm.moon

@ -57,8 +57,8 @@ getContent = (url) ->
return content return content
-- Request repository information -- Request repository information
getRepositories = ->
success, raw_repositories = pcall(getContent, defaultRepoLocationConfig)
getRepositories = (repoLocation) ->
success, raw_repositories = pcall(getContent, repoLocation)
if not success if not success
io.stderr\write("Could not connect to the Internet. Please ensure you have an Internet connection.") io.stderr\write("Could not connect to the Internet. Please ensure you have an Internet connection.")
@ -68,6 +68,13 @@ getRepositories = ->
repositories = {} repositories = {}
for repositoryName, repository in pairs(deserialized_repositories) for repositoryName, repository in pairs(deserialized_repositories)
if repository.link != nil
linked_repositories = getRepositories(repository.link)
for linkedRepositoryName, linkedRepository in pairs(linked_repositories)
repositories[linkedRepositoryName] = linkedRepository
continue
src = repository.src or nil src = repository.src or nil
if src == nil if src == nil
src = githubContentRoot .. repository.repo .."/master" src = githubContentRoot .. repository.repo .."/master"
@ -154,7 +161,7 @@ listPackages = (filter) ->
packageTable = {} packageTable = {}
print("Receiving Package list...") print("Receiving Package list...")
if not options.i if not options.i
success, repositories = pcall(getRepositories)
success, repositories = pcall(getRepositories, defaultRepoLocationConfig)
if not success or repositories == -1 if not success or repositories == -1
io.stderr\write("Unable to connect to the Internet.\n") io.stderr\write("Unable to connect to the Internet.\n")
@ -216,7 +223,7 @@ printPackages = (packages) ->
-- Retrieve package information -- Retrieve package information
getInformation = (requestedPackage) -> getInformation = (requestedPackage) ->
success, repositories = pcall(getRepositories)
success, repositories = pcall(getRepositories, defaultRepoLocationConfig)
if not success or repositories == -1 if not success or repositories == -1
io.stderr\write("Unable to connect to the Internet.\n") io.stderr\write("Unable to connect to the Internet.\n")

Loading…
Cancel
Save