Browse Source

Working on copying function, to allow SPM to maintain versions and export them to an external media.

environments/development/deployments/29
Drew Short 6 years ago
parent
commit
36a6c98908
  1. 44
      src/spm/spm.lua

44
src/spm/spm.lua

@ -475,6 +475,48 @@ local function installPackage(requestedPackage, installPath, doUpdate)
print("Successfully installed package " .. requestedPackage)
end
local function copyPackage(requestedPackage, copyLocation)
local packageInformation, repositoryLocation = getInformation(requestedPackage)
if not packageInformation then
print("Package does not exist")
return
end
local locallyInstalledFiles = readFromLocalInstallFile()
if not locallyInstalledFiles then
io.stderr:write("Error while trying to read package names")
return
elseif locallyInstalledFiles[1] == -1 then
table.remove(locallyInstalledFiles, 1)
end
if not locallyInstalledFiles[requestedPackage] then
print("Package has not been installed.")
print("It must be installed to be copied.")
return
end
term.write("Copying package files...")
for installedFilePath, fileLocalInstallPath in pairs(locallyInstalledFiles[requestedPackage]) do
fs.copy(fileLocalInstallPath, copyLocation .. fileLocalInstallPath)
end
if packageInfo.dependencies then
term.write("Done\nCopying Dependencies...")
for packageDependency, _ in pairs(packageInfo.dependencies) do
if not locallyInstalledFiles[packageDependency] then
print("Dependency has not been installed.")
print("If it has, it is not recognized. Reinstall the parent package: " .. requestedPackage)
return
end
copyPackage(packageDependency, copyLocation)
end
end
term.write("Done.\n")
print("Successfully copied package " .. requestedPackage)
end
local function uninstallPackage(requestedPackage)
local packageInformation, repositoryLocation = getInformation(requestedPackage)
if not packageInformation then
@ -542,6 +584,8 @@ elseif args[1] == "update" or args[1] == "upgrade" then
updatePackage(args[2])
elseif args[1] == "uninstall" or args[1] == "remove" then
uninstallPackage(args[2])
elseif args[1] == "copy" then
copyPackage(args[2], args[3])
else
printUsage()
return
Loading…
Cancel
Save