added lua VM for installation, and changed the standard os library from lua

This commit is contained in:
2025-08-01 18:00:08 -03:00
parent a4373f7254
commit bab7c39770
2 changed files with 81 additions and 9 deletions

View File

@@ -531,21 +531,28 @@ func Install(packagepath string, serial uint) error {
}
}
bar.Finish()
// TODO LUA SCRIPT
L := lua.NewState()
defer L.Close()
osObject := L.GetGlobal("os").(*lua.LTable)
L.SetGlobal("packets_package_dir", lua.LString(cfg.Config.DataDir))
L.SetGlobal("packets_bin_dir", lua.LString(cfg.Config.BinDir))
L.SetField(L.GetGlobal("os"), "remove", L.NewFunction(internal.SafeRemove))
osObject.RawSetString("execute", lua.LNil)
osObject.RawSetString("exit", lua.LNil)
osObject.RawSetString("getenv", lua.LNil)
osObject.RawSetString("remove", L.NewFunction(internal.SafeRemove))
osObject.RawSetString("rename", L.NewFunction(internal.SafeRename))
osObject.RawSetString("copy", L.NewFunction(internal.SafeCopy))
if err := L.DoFile(manifest.Hooks.Install); err != nil {
log.Panic(err)
}
bar.Finish()
fmt.Printf("Package %s fully installed\n", name)
var insert = Installed{
@@ -1408,8 +1415,6 @@ func Upgrade(packagepath string, og_realname string, serial uint) error {
os.Rename(destDir, filepath.Join(cfg.Config.DataDir, name))
destDir = filepath.Join(cfg.Config.DataDir, name)
//TODO manifest.toml things
fmt.Printf("Package %s fully installed", name)