github.com/metux/go-metabuild@v0.0.0-20240118143255-d9ed5ab697f9/spec/distro/main.go (about)

     1  package distro
     2  
     3  import (
     4  	"github.com/metux/go-metabuild/util"
     5  	"github.com/metux/go-metabuild/util/specobj"
     6  )
     7  
     8  const (
     9  	ErrPkgFormatUnsupported = util.Error("unsupported package format")
    10  )
    11  
    12  type Distro struct {
    13  	specobj.SpecObj
    14  	DistroName string
    15  }
    16  
    17  func (d Distro) PackageFormat() string {
    18  	return d.EntryStr(KeyPackageFormat)
    19  }
    20  
    21  func (d Distro) Name() string {
    22  	return d.DistroName
    23  }
    24  
    25  func (d Distro) PackageNameTrans(pkg string) string {
    26  	return d.EntryStr(KeyPackages.AppendStr(pkg).Append("name"))
    27  }
    28  
    29  func (d Distro) PackageIds() []Key {
    30  	return d.EntryKeys(KeyPackages)
    31  }
    32  
    33  func (d Distro) Packages() []DistPkg {
    34  	return specobj.SpecXformSpecList(
    35  		d.SpecObj,
    36  		KeyPackages,
    37  		func(so specobj.SpecObj) DistPkg { return NewDistPkg(so, d) })
    38  }
    39  
    40  func (d Distro) Package(p string) DistPkg {
    41  	return NewDistPkg(d.EntrySpec(KeyPackages.AppendStr(p)), d)
    42  }
    43  
    44  func NewDistro(so specobj.SpecObj, name string) Distro {
    45  	return Distro{so, name}
    46  }