1
0
mirror of https://github.com/kepler155c/opus synced 2025-11-18 00:05:12 +00:00

packages stored in compressed state - experimental (with config option)

This commit is contained in:
kepler155c@gmail.com
2020-06-03 20:40:48 -06:00
parent 6009f22d8e
commit 6a3b38922b
5 changed files with 449 additions and 1 deletions

27
sys/init/5.unpackage.lua Normal file
View File

@@ -0,0 +1,27 @@
local LZW = require('opus.compress.lzw')
local Tar = require('opus.compress.tar')
local Util = require('opus.util')
local fs = _G.fs
for _, name in pairs(fs.list('packages')) do
local fullName = fs.combine('packages', name)
local packageName = name:match('(.+)%.tar%.lzw$')
if packageName and not fs.isDir(fullName) then
local dir = fs.combine('packages', packageName)
if not fs.exists(dir) then
local s, m = pcall(function()
fs.mount(dir, 'ramfs', 'directory')
local c = Util.readFile(fullName, 'rb')
Tar.untar_string(LZW.decompress(c), dir)
end)
if not s then
fs.delete(dir)
print('failed to extract ' .. fullName)
print(m)
end
end
end
end