Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- GCorp Package Manager
- -- /etc/gcpm/packages.db
- -- Libary / Component Requirements
- local file = require "filesystem"
- local serialization = require "serialization"
- -- Package DB location
- local package_list = "https://gitlab.com/amberkowalski/opencomputers-files/raw/master/package_list"
- -- Package DB
- local package_db = {}
- installed_packages = {}
- -- Functions
- local function download_file(file, file_path)
- os.execute("cd " .. file_path .. " && wget " .. file)
- end
- local function reload_packages()
- local data = ""
- for line in io.lines("/etc/.gcpm/package_list") do
- data = data .. line
- end
- print(data)
- local db = serialization.unserialize(data)
- return db
- end
- -- Check for important files
- if file.exists("/etc/.gcpm/packages.db") == false then
- io.stderr:write("[WARN] No package DB exists or your installation is corrupt, creating a new one!\n")
- if file.isDirectory("/etc/.gcpm") ~= true then
- file.makeDirectory("/etc/.gcpm")
- local db = file.open("/etc/.gcpm/packages.db", "w")
- db:write("")
- db:close()
- else
- local db = file.open("/etc/.gcpm/packages.db", "w")
- db:write("")
- db:close()
- end
- end
- if file.exists("/etc/.gcpm/package_list") == false then
- io.stderr:write("[WARN] Package list has not been synced, syncing now!\n")
- download_file(package_list, "/etc/.gcpm")
- end
- -- Read the packages.db and store in package_db
- package_db = reload_packages()
- print(package_db)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement