now packets can get LICENSE and pageurl from package table

This commit is contained in:
2025-11-04 19:15:29 -03:00
parent eb14177d7a
commit 3f370adda1
4 changed files with 38 additions and 26 deletions

View File

@@ -31,6 +31,8 @@ type PacketLua struct {
Maintainer string Maintainer string
Description string Description string
Serial int Serial int
Page string
License []string
Plataforms *map[OperationalSystem]Plataform Plataforms *map[OperationalSystem]Plataform
GlobalSources *[]Source GlobalSources *[]Source
@@ -136,6 +138,8 @@ func ReadPacket(f []byte, cfg *Config) (PacketLua, error) {
Maintainer: getStringFromTable(pkgTable, "maintainer"), Maintainer: getStringFromTable(pkgTable, "maintainer"),
Description: getStringFromTable(pkgTable, "description"), Description: getStringFromTable(pkgTable, "description"),
Serial: getIntFromTable(pkgTable, "serial"), Serial: getIntFromTable(pkgTable, "serial"),
Page: getStringFromTable(pkgTable, "pageurl"),
License: getStringArrayFromTable(pkgTable, "LICENSE"),
Plataforms: getPlataformsFromTable(pkgTable, "plataforms"), Plataforms: getPlataformsFromTable(pkgTable, "plataforms"),

View File

@@ -1,25 +0,0 @@
package packet
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 < 1 || len(*pkg.Plataforms) > b {
return false
}
switch {
case pkg.Serial == -133:
return false
case pkg.Description == "" || pkg.Maintainer == "" || pkg.Name == "" || pkg.Version == "":
return false
}
return true
}

View File

@@ -32,3 +32,34 @@ func NewId(id string) PackageID {
ID.ID = id ID.ID = id
return ID return ID
} }
func (pkg PacketLua) IsValid() bool {
var a, b int
for _, v := range *pkg.Plataforms {
for _, src := range *v.Sources {
a++
if src.Method == "git" {
if src.Specs.(GitSpecs).Branch == "" && src.Specs.(GitSpecs).Tag == nil {
return false
}
}
}
b += len(v.Architetures)
}
a += len(*pkg.GlobalSources)
if a < 1 || len(*pkg.Plataforms) > b {
return false
}
switch {
case pkg.Serial == -133:
return false
case pkg.Description == "" || pkg.Maintainer == "" || pkg.Name == "" || pkg.Version == "":
return false
}
return true
}

View File

@@ -4,7 +4,9 @@ return {
version = "0.26.0", -- required version = "0.26.0", -- required
maintainer = "robogg133", -- required maintainer = "robogg133", -- required
description = "A cat(1) clone with syntax highlighting and Git integration.", -- required description = "A cat(1) clone with syntax highlighting and Git integration.", -- required
serial = 0, -- required serial = 0,
LICENSE = {"APACHE", "MIT"},
pageurl = "https://github.com/sharkdp/bat"
plataforms = { plataforms = {
windows = { windows = {