Compare commits
	
		
			8 Commits
		
	
	
		
			05af0969e9
			...
			test
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3b6a582937 | |||
| 9b15d014c1 | |||
| 39d315c09e | |||
| 3f5a0e3898 | |||
| e556b4c982 | |||
| bd63bf8b1f | |||
| f75808b8c4 | |||
| 2abcec6384 | 
							
								
								
									
										7
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								go.mod
									
									
									
									
									
								
							@@ -1,7 +0,0 @@
 | 
			
		||||
module github.com/roboogg133/packets
 | 
			
		||||
 | 
			
		||||
go 1.25.3
 | 
			
		||||
 | 
			
		||||
require github.com/yuin/gopher-lua v1.1.1
 | 
			
		||||
 | 
			
		||||
require github.com/klauspost/compress v1.18.1
 | 
			
		||||
							
								
								
									
										4
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.sum
									
									
									
									
									
								
							@@ -1,4 +0,0 @@
 | 
			
		||||
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
 | 
			
		||||
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
 | 
			
		||||
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
 | 
			
		||||
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
 | 
			
		||||
							
								
								
									
										10
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								main.go
									
									
									
									
									
								
							@@ -1,10 +0,0 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"runtime"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	fmt.Println(runtime.GOARCH)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								ola@3000.pkt.tar.zst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ola@3000.pkt.tar.zst
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -1,289 +0,0 @@
 | 
			
		||||
package packet
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	lua "github.com/yuin/gopher-lua"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func getStringFromTable(table *lua.LTable, key string) string {
 | 
			
		||||
	value := table.RawGetString(key)
 | 
			
		||||
	if value.Type() == lua.LTString {
 | 
			
		||||
		return value.String()
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getIntFromTable(table *lua.LTable, key string) int {
 | 
			
		||||
	value := table.RawGetString(key)
 | 
			
		||||
	if value.Type() == lua.LTNumber {
 | 
			
		||||
		if num, ok := value.(lua.LNumber); ok {
 | 
			
		||||
			return int(num)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return -133
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getStringArrayFromTable(table *lua.LTable, key string) []string {
 | 
			
		||||
	value := table.RawGetString(key)
 | 
			
		||||
	if value.Type() != lua.LTTable {
 | 
			
		||||
		return []string{}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	arrayTable := value.(*lua.LTable)
 | 
			
		||||
	var result []string
 | 
			
		||||
 | 
			
		||||
	arrayTable.ForEach(func(_, value lua.LValue) {
 | 
			
		||||
		if value.Type() == lua.LTString {
 | 
			
		||||
			result = append(result, value.String())
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	return result
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getFunctionFromTable(table *lua.LTable, key string) *lua.LFunction {
 | 
			
		||||
	value := table.RawGetString(key)
 | 
			
		||||
	if value.Type() == lua.LTFunction {
 | 
			
		||||
		return value.(*lua.LFunction)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type version struct {
 | 
			
		||||
	Name       string
 | 
			
		||||
	Constraint VersionConstraint
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getDependenciesFromTable(table *lua.LTable, key string) *PkgDependencies {
 | 
			
		||||
	value := table.RawGetString(key)
 | 
			
		||||
	if value.Type() != lua.LTTable {
 | 
			
		||||
		return &PkgDependencies{}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var pkgDeps PkgDependencies
 | 
			
		||||
 | 
			
		||||
	depnTable := value.(*lua.LTable)
 | 
			
		||||
 | 
			
		||||
	pkgDeps.RuntimeDependencies = depsParse(depnTable, "runtime")
 | 
			
		||||
	pkgDeps.BuildDependencies = depsParse(depnTable, "build")
 | 
			
		||||
	pkgDeps.Conflicts = depsParse(depnTable, "conflicts")
 | 
			
		||||
 | 
			
		||||
	return &pkgDeps
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getSourcesFromTable(table *lua.LTable, key string) *[]Source {
 | 
			
		||||
	value := table.RawGetString(key)
 | 
			
		||||
	if value.Type() != lua.LTTable {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var srcList []Source
 | 
			
		||||
 | 
			
		||||
	srcTable := value.(*lua.LTable)
 | 
			
		||||
 | 
			
		||||
	srcTable.ForEach(func(_, value lua.LValue) {
 | 
			
		||||
		if value.Type() == lua.LTTable {
 | 
			
		||||
			src := value.(*lua.LTable)
 | 
			
		||||
 | 
			
		||||
			var srcInfo Source
 | 
			
		||||
 | 
			
		||||
			method := src.RawGetString("method")
 | 
			
		||||
			if method.Type() == lua.LTString {
 | 
			
		||||
				srcInfo.Method = method.String()
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			url := src.RawGetString("url")
 | 
			
		||||
 | 
			
		||||
			if url.Type() == lua.LTString {
 | 
			
		||||
				srcInfo.Url = url.String()
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		switchlabel:
 | 
			
		||||
			switch srcInfo.Method {
 | 
			
		||||
			case "GET":
 | 
			
		||||
				var getSpecs GETSpecs
 | 
			
		||||
 | 
			
		||||
				getSpecs.SHA256 = new(string)
 | 
			
		||||
				sha256sumL := src.RawGetString("sha256")
 | 
			
		||||
				if sha256sumL.Type() == lua.LTString {
 | 
			
		||||
					*getSpecs.SHA256 = sha256sumL.String()
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				headersLT := src.RawGetString("headers")
 | 
			
		||||
				if headersLT.Type() == lua.LTTable {
 | 
			
		||||
 | 
			
		||||
					headers := headersLT.(*lua.LTable)
 | 
			
		||||
 | 
			
		||||
					tmpMap := make(map[string]string)
 | 
			
		||||
					headers.ForEach(func(headerKey, value lua.LValue) {
 | 
			
		||||
						if value.Type() == lua.LTString {
 | 
			
		||||
							tmpMap[headerKey.String()] = value.String()
 | 
			
		||||
						}
 | 
			
		||||
					})
 | 
			
		||||
 | 
			
		||||
					getSpecs.Headers = &tmpMap
 | 
			
		||||
				}
 | 
			
		||||
				srcInfo.Specs = getSpecs
 | 
			
		||||
				break switchlabel
 | 
			
		||||
 | 
			
		||||
			case "git":
 | 
			
		||||
				var gitSpecs GitSpecs
 | 
			
		||||
 | 
			
		||||
				branchL := src.RawGetString("branch")
 | 
			
		||||
 | 
			
		||||
				if branchL.Type() == lua.LTString {
 | 
			
		||||
					gitSpecs.Branch = branchL.String()
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				tagL := src.RawGetString("tag")
 | 
			
		||||
 | 
			
		||||
				if tagL.Type() == lua.LTString {
 | 
			
		||||
					*gitSpecs.Tag = tagL.String()
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				srcInfo.Specs = gitSpecs
 | 
			
		||||
				break switchlabel
 | 
			
		||||
			case "POST":
 | 
			
		||||
				var postSpecs POSTSpecs
 | 
			
		||||
 | 
			
		||||
				sha256sumL := src.RawGetString("sha256")
 | 
			
		||||
				if sha256sumL.Type() == lua.LTString {
 | 
			
		||||
					*postSpecs.SHA256 = sha256sumL.String()
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				headersLT := src.RawGetString("headers")
 | 
			
		||||
				if headersLT.Type() == lua.LTTable {
 | 
			
		||||
 | 
			
		||||
					headers := headersLT.(*lua.LTable)
 | 
			
		||||
 | 
			
		||||
					tmpMap := make(map[string]string)
 | 
			
		||||
					headers.ForEach(func(headerKey, value lua.LValue) {
 | 
			
		||||
						if value.Type() == lua.LTString {
 | 
			
		||||
							tmpMap[headerKey.String()] = value.String()
 | 
			
		||||
						}
 | 
			
		||||
					})
 | 
			
		||||
 | 
			
		||||
					postSpecs.Headers = &tmpMap
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				bodyLt := src.RawGetString("body")
 | 
			
		||||
 | 
			
		||||
				if bodyLt.Type() == lua.LTString {
 | 
			
		||||
					*postSpecs.Body = bodyLt.String()
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				srcInfo.Specs = postSpecs
 | 
			
		||||
				break switchlabel
 | 
			
		||||
			}
 | 
			
		||||
			srcList = append(srcList, srcInfo)
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	return &srcList
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getPlataformsFromTable(table *lua.LTable, key string) *map[OperationalSystem]Plataform {
 | 
			
		||||
	value := table.RawGetString(key)
 | 
			
		||||
 | 
			
		||||
	if value.Type() != lua.LTTable {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tmpMap := make(map[OperationalSystem]Plataform)
 | 
			
		||||
 | 
			
		||||
	plataform := value.(*lua.LTable)
 | 
			
		||||
 | 
			
		||||
	plataform.ForEach(func(osString, value lua.LValue) {
 | 
			
		||||
		if value.Type() != lua.LTTable {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var plat Plataform
 | 
			
		||||
		plat.Architetures = getStringArrayFromTable(value.(*lua.LTable), "arch")
 | 
			
		||||
		plat.Name = osString.String()
 | 
			
		||||
		plat.Sources = getSourcesFromTable(value.(*lua.LTable), "sources")
 | 
			
		||||
		plat.Dependencies = getDependenciesFromTable(value.(*lua.LTable), "dependencies")
 | 
			
		||||
 | 
			
		||||
		tmpMap[OperationalSystem(osString.String())] = plat
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	if len(tmpMap) == 0 {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &tmpMap
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func depsParse(depnTable *lua.LTable, key string) *map[string]*VersionConstraint {
 | 
			
		||||
	if runLTable := depnTable.RawGetString(key); runLTable.Type() == lua.LTTable {
 | 
			
		||||
		runtimeTable := runLTable.(*lua.LTable)
 | 
			
		||||
 | 
			
		||||
		mapTemp := make(map[string]*VersionConstraint)
 | 
			
		||||
 | 
			
		||||
		var found bool
 | 
			
		||||
 | 
			
		||||
		runtimeTable.ForEach(func(_, value lua.LValue) {
 | 
			
		||||
			if value.Type() == lua.LTString {
 | 
			
		||||
				version := parseVersionString(value.String())
 | 
			
		||||
				mapTemp[version.Name] = &version.Constraint
 | 
			
		||||
				found = true
 | 
			
		||||
			}
 | 
			
		||||
		})
 | 
			
		||||
		if !found {
 | 
			
		||||
			return nil
 | 
			
		||||
		} else {
 | 
			
		||||
			return &mapTemp
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func parseVersionString(s string) version {
 | 
			
		||||
	// >=go@1.25.3 | <=go@1.25.3 | go | >go@1.25.3 | <go@1.25.3 | go@1.25.3
 | 
			
		||||
	if strings.ContainsAny(s, "@") {
 | 
			
		||||
		slice := strings.Split(s, "@")
 | 
			
		||||
 | 
			
		||||
		switch {
 | 
			
		||||
		case !strings.ContainsAny(s, "<=>"):
 | 
			
		||||
			return version{
 | 
			
		||||
				Name:       slice[0],
 | 
			
		||||
				Constraint: VersionConstraint(slice[1]),
 | 
			
		||||
			}
 | 
			
		||||
		case s[0] == '>' && s[1] == '=':
 | 
			
		||||
 | 
			
		||||
			return version{
 | 
			
		||||
				Name:       slice[0][2:],
 | 
			
		||||
				Constraint: VersionConstraint(">=" + slice[1]),
 | 
			
		||||
			}
 | 
			
		||||
		case s[0] == '<' && s[1] == '=':
 | 
			
		||||
 | 
			
		||||
			return version{
 | 
			
		||||
				Name:       slice[0][2:],
 | 
			
		||||
				Constraint: VersionConstraint("<=" + slice[1]),
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		case s[0] == '>' && s[1] != '=':
 | 
			
		||||
 | 
			
		||||
			return version{
 | 
			
		||||
				Name:       slice[0][1:],
 | 
			
		||||
				Constraint: VersionConstraint(">" + slice[1]),
 | 
			
		||||
			}
 | 
			
		||||
		case s[0] == '<' && s[1] != '=':
 | 
			
		||||
 | 
			
		||||
			return version{
 | 
			
		||||
				Name:       slice[0][1:],
 | 
			
		||||
				Constraint: VersionConstraint("<" + slice[1]),
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	} else if !strings.ContainsAny(s, "@=<>") {
 | 
			
		||||
		return version{
 | 
			
		||||
			Name:       s,
 | 
			
		||||
			Constraint: VersionConstraint(0x000),
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return version{}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,24 +0,0 @@
 | 
			
		||||
package packet
 | 
			
		||||
 | 
			
		||||
type Config struct {
 | 
			
		||||
	BinDir string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const defaultBinDir = "/usr/bin"
 | 
			
		||||
 | 
			
		||||
func checkConfig(cfg *Config) *Config {
 | 
			
		||||
 | 
			
		||||
	if cfg == nil {
 | 
			
		||||
		return &Config{
 | 
			
		||||
			BinDir: defaultBinDir,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if cfg.BinDir == "" {
 | 
			
		||||
		return &Config{
 | 
			
		||||
			BinDir: defaultBinDir,
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		return cfg
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,166 +0,0 @@
 | 
			
		||||
package packet
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"archive/tar"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"runtime"
 | 
			
		||||
 | 
			
		||||
	"github.com/klauspost/compress/zstd"
 | 
			
		||||
 | 
			
		||||
	lua "github.com/yuin/gopher-lua"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type OperationalSystem string
 | 
			
		||||
 | 
			
		||||
type PacketLua struct {
 | 
			
		||||
	Name        string
 | 
			
		||||
	Version     string
 | 
			
		||||
	Maintaner   string
 | 
			
		||||
	Description string
 | 
			
		||||
	Serial      int
 | 
			
		||||
 | 
			
		||||
	Plataforms         *map[OperationalSystem]Plataform
 | 
			
		||||
	GlobalSources      *[]Source
 | 
			
		||||
	GlobalDependencies *PkgDependencies
 | 
			
		||||
 | 
			
		||||
	Build   *lua.LFunction
 | 
			
		||||
	Install *lua.LFunction
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Source struct {
 | 
			
		||||
	Method string
 | 
			
		||||
	Url    string
 | 
			
		||||
	Specs  interface{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type VersionConstraint string
 | 
			
		||||
 | 
			
		||||
type PkgDependencies struct {
 | 
			
		||||
	RuntimeDependencies *map[string]*VersionConstraint
 | 
			
		||||
	BuildDependencies   *map[string]*VersionConstraint
 | 
			
		||||
	Conflicts           *map[string]*VersionConstraint
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Plataform struct {
 | 
			
		||||
	Name         string
 | 
			
		||||
	Architetures []string
 | 
			
		||||
	Sources      *[]Source
 | 
			
		||||
	Dependencies *PkgDependencies
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GitSpecs struct {
 | 
			
		||||
	Branch string
 | 
			
		||||
	Tag    *string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type POSTSpecs struct {
 | 
			
		||||
	SHA256  *string
 | 
			
		||||
	Body    *string
 | 
			
		||||
	Headers *map[string]string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GETSpecs struct {
 | 
			
		||||
	SHA256  *string
 | 
			
		||||
	Headers *map[string]string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var ErrCantFindPacketDotLua = errors.New("can't find Packet.lua in .tar.zst file")
 | 
			
		||||
var ErrFileDontReturnTable = errors.New("invalid Packet.lua format: the file do not return a table")
 | 
			
		||||
var ErrCannotFindPackageTable = errors.New("invalid Packet.lua format: can't find package table")
 | 
			
		||||
 | 
			
		||||
// ReadPacket read a Packet.lua and alredy set global vars
 | 
			
		||||
func ReadPacket(f []byte, cfg *Config) (PacketLua, error) {
 | 
			
		||||
	cfg = checkConfig(cfg)
 | 
			
		||||
 | 
			
		||||
	L := lua.NewState()
 | 
			
		||||
	defer L.Close()
 | 
			
		||||
 | 
			
		||||
	osObject := L.GetGlobal("os").(*lua.LTable)
 | 
			
		||||
	ioObject := L.GetGlobal("io").(*lua.LTable)
 | 
			
		||||
 | 
			
		||||
	L.SetGlobal("os", lua.LNil)
 | 
			
		||||
	L.SetGlobal("io", lua.LNil)
 | 
			
		||||
 | 
			
		||||
	L.SetGlobal("BIN_DIR", lua.LString(cfg.BinDir))
 | 
			
		||||
	L.SetGlobal("CURRENT_ARCH", lua.LString(runtime.GOARCH))
 | 
			
		||||
	L.SetGlobal("CURRENT_PLATAFORM", lua.LString(runtime.GOOS))
 | 
			
		||||
 | 
			
		||||
	if err := L.DoString(string(f)); err != nil {
 | 
			
		||||
		return PacketLua{}, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	L.SetGlobal("os", osObject)
 | 
			
		||||
	L.SetGlobal("io", ioObject)
 | 
			
		||||
 | 
			
		||||
	tableLua := L.Get(-1)
 | 
			
		||||
 | 
			
		||||
	if tableLua.Type() != lua.LTTable {
 | 
			
		||||
		return PacketLua{}, ErrFileDontReturnTable
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	table := tableLua.(*lua.LTable)
 | 
			
		||||
 | 
			
		||||
	pkgTableLua := table.RawGetString("package")
 | 
			
		||||
	if pkgTableLua.Type() != lua.LTTable {
 | 
			
		||||
		return PacketLua{}, ErrCannotFindPackageTable
 | 
			
		||||
	}
 | 
			
		||||
	pkgTable := pkgTableLua.(*lua.LTable)
 | 
			
		||||
 | 
			
		||||
	packetLua := &PacketLua{
 | 
			
		||||
		Name:        getStringFromTable(pkgTable, "name"),
 | 
			
		||||
		Version:     getStringFromTable(pkgTable, "version"),
 | 
			
		||||
		Maintaner:   getStringFromTable(pkgTable, "maintainer"),
 | 
			
		||||
		Description: getStringFromTable(pkgTable, "description"),
 | 
			
		||||
		Serial:      getIntFromTable(pkgTable, "serial"),
 | 
			
		||||
 | 
			
		||||
		Plataforms: getPlataformsFromTable(pkgTable, "plataforms"),
 | 
			
		||||
 | 
			
		||||
		GlobalDependencies: getDependenciesFromTable(pkgTable, "build_dependencies"),
 | 
			
		||||
		GlobalSources:      getSourcesFromTable(pkgTable, "sources"),
 | 
			
		||||
 | 
			
		||||
		Build:   getFunctionFromTable(table, "build"),
 | 
			
		||||
		Install: getFunctionFromTable(table, "install"),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if packetLua.Install == nil {
 | 
			
		||||
		return PacketLua{}, fmt.Errorf("install() does not exist")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return *packetLua, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ReadPacketFromZSTDF(file io.Reader, cfg *Config) (PacketLua, error) {
 | 
			
		||||
	cfg = checkConfig(cfg)
 | 
			
		||||
 | 
			
		||||
	zstdReader, err := zstd.NewReader(file)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return PacketLua{}, err
 | 
			
		||||
	}
 | 
			
		||||
	defer zstdReader.Close()
 | 
			
		||||
 | 
			
		||||
	tarReader := tar.NewReader(zstdReader)
 | 
			
		||||
	for {
 | 
			
		||||
		header, err := tarReader.Next()
 | 
			
		||||
		if err == io.EOF {
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return PacketLua{}, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if filepath.Base(header.Name) == "Packet.lua" {
 | 
			
		||||
 | 
			
		||||
			packageLuaBlob, err := io.ReadAll(tarReader)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return PacketLua{}, err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return ReadPacket(packageLuaBlob, cfg)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return PacketLua{}, ErrCantFindPacketDotLua
 | 
			
		||||
}
 | 
			
		||||
@@ -1,32 +0,0 @@
 | 
			
		||||
package packet
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func (pkg PacketLua) IsValid() bool {
 | 
			
		||||
 | 
			
		||||
	var a, b int
 | 
			
		||||
 | 
			
		||||
	for _, v := range *pkg.Plataforms {
 | 
			
		||||
		a += len(*v.Sources)
 | 
			
		||||
		b += len(v.Architetures)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	a += len(*pkg.GlobalSources)
 | 
			
		||||
 | 
			
		||||
	if a <= 0 || b <= 0 {
 | 
			
		||||
		fmt.Println("invalid")
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	switch {
 | 
			
		||||
	case pkg.Serial == -133:
 | 
			
		||||
		return false
 | 
			
		||||
	case pkg.Description == "" || pkg.Maintaner == "" || pkg.Name == "" || pkg.Version == "":
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fmt.Println("valid")
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								realtime@1.25.0.pkt.tar.zst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								realtime@1.25.0.pkt.tar.zst
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -1,61 +0,0 @@
 | 
			
		||||
local arch_map = {
 | 
			
		||||
    amd64 = "x86_64",
 | 
			
		||||
    aarch64 = "aarch64",
 | 
			
		||||
    arm64 = "aarch64",
 | 
			
		||||
    ['386'] = "i686" 
 | 
			
		||||
}
 | 
			
		||||
local srcarch = arch_map[CURRENT_ARCH]
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
    package = {
 | 
			
		||||
        name = "bat-bin", -- required
 | 
			
		||||
        version = "0.26.0", -- required
 | 
			
		||||
        maintainer = "robogg133", -- required
 | 
			
		||||
        description = "A cat(1) clone with syntax highlighting and Git integration.", -- required
 | 
			
		||||
        serial = 0,-- required
 | 
			
		||||
 | 
			
		||||
        plataforms = {
 | 
			
		||||
            windows = {
 | 
			
		||||
                arch = {"amd64"},
 | 
			
		||||
                sources = {
 | 
			
		||||
                    {
 | 
			
		||||
                        url = "https://github.com/sharkdp/bat/releases/download/v0.26.0/bat-v0.26.0-" ..srcarch .."-pc-windows-msvc.zip",
 | 
			
		||||
                        method = "GET",
 | 
			
		||||
                        sha256="a8a6862f14698b45e101b0932c69bc47a007f4c0456f3a129fdcef54d443d501"
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
                dependencies = {
 | 
			
		||||
                    build = {},
 | 
			
		||||
                    runtime = {},
 | 
			
		||||
                    conflicts = {}
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            linux = {
 | 
			
		||||
                arch = {"amd64"},
 | 
			
		||||
                sources = {
 | 
			
		||||
                    {
 | 
			
		||||
                        url = "https://github.com/sharkdp/bat/releases/download/v0.26.0/bat-v0.26.0-".. srcarch .."-unknown-linux-gnu.tar.gz",
 | 
			
		||||
                        method = "GET",
 | 
			
		||||
                        sha256 = "7efed0c768fae36f18ddbbb4a38f5c4b64db7c55a170dfc89fd380805809a44b"
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
                dependencies = {
 | 
			
		||||
                    build = {},
 | 
			
		||||
                    runtime = {},
 | 
			
		||||
                    conflicts = {}
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        sources = {}
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
        
 | 
			
		||||
    build = function() 
 | 
			
		||||
    end,
 | 
			
		||||
    
 | 
			
		||||
    install = function() -- required 
 | 
			
		||||
    print("oi amores")
 | 
			
		||||
    end,
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,34 +0,0 @@
 | 
			
		||||
return {
 | 
			
		||||
    package = {
 | 
			
		||||
        name = "utctimerightnow", -- required
 | 
			
		||||
        version = "0.1.0", -- required
 | 
			
		||||
        maintainer = "robogg133", -- required
 | 
			
		||||
        description = "shows utc time", -- required
 | 
			
		||||
        serial = 0,-- required
 | 
			
		||||
 | 
			
		||||
        dependencies = {
 | 
			
		||||
            build = {"go"},
 | 
			
		||||
            runtime = {},
 | 
			
		||||
            conflicts = {}
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        sources = { --optional 
 | 
			
		||||
            { 
 | 
			
		||||
                url = "https://git.opentty.xyz/robogg133/utctimerightnow.git", -- required
 | 
			
		||||
                method = "git", -- required
 | 
			
		||||
                branch = "main" -- required 
 | 
			
		||||
            --  tag = ""
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
        
 | 
			
		||||
    build = function()
 | 
			
		||||
 | 
			
		||||
    end,
 | 
			
		||||
    
 | 
			
		||||
    install  = function() -- required 
 | 
			
		||||
        print("goku")
 | 
			
		||||
    end,
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								teste@1.0.pkt.tar.zst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								teste@1.0.pkt.tar.zst
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user