refactoring in metadata module, pacman database creation function

This commit is contained in:
Danila Fominykh 2023-10-02 22:00:44 -03:00
parent 8974d27ba3
commit 784b4f9304
No known key found for this signature in database
GPG Key ID: 1134F8EBF98AA06F
2 changed files with 23 additions and 30 deletions

View File

@ -166,25 +166,25 @@ func (m *DbDesc) String() string {
Key string Key string
Value string Value string
}{ }{
{Key: "FILENAME", Value: m.Filename}, {"FILENAME", m.Filename},
{Key: "NAME", Value: m.Name}, {"NAME", m.Name},
{Key: "BASE", Value: m.Base}, {"BASE", m.Base},
{Key: "VERSION", Value: m.Version}, {"VERSION", m.Version},
{Key: "DESC", Value: m.Description}, {"DESC", m.Description},
{Key: "CSIZE", Value: fmt.Sprintf("%d", m.CompressedSize)}, {"CSIZE", fmt.Sprintf("%d", m.CompressedSize)},
{Key: "ISIZE", Value: fmt.Sprintf("%d", m.InstalledSize)}, {"ISIZE", fmt.Sprintf("%d", m.InstalledSize)},
{Key: "MD5SUM", Value: m.MD5}, {"MD5SUM", m.MD5},
{Key: "SHA256SUM", Value: m.SHA256}, {"SHA256SUM", m.SHA256},
{Key: "URL", Value: m.URL}, {"URL", m.URL},
{Key: "LICENSE", Value: strings.Join(m.License, "\n")}, {"LICENSE", strings.Join(m.License, "\n")},
{Key: "ARCH", Value: strings.Join(m.Arch, "\n")}, {"ARCH", strings.Join(m.Arch, "\n")},
{Key: "BUILDDATE", Value: fmt.Sprintf("%d", m.BuildDate)}, {"BUILDDATE", fmt.Sprintf("%d", m.BuildDate)},
{Key: "PACKAGER", Value: m.Packager}, {"PACKAGER", m.Packager},
{Key: "PROVIDES", Value: strings.Join(m.Provides, "\n")}, {"PROVIDES", strings.Join(m.Provides, "\n")},
{Key: "DEPENDS", Value: strings.Join(m.Depends, "\n")}, {"DEPENDS", strings.Join(m.Depends, "\n")},
{Key: "OPTDEPENDS", Value: strings.Join(m.OptDepends, "\n")}, {"OPTDEPENDS", strings.Join(m.OptDepends, "\n")},
{Key: "MAKEDEPENDS", Value: strings.Join(m.MakeDepends, "\n")}, {"MAKEDEPENDS", strings.Join(m.MakeDepends, "\n")},
{Key: "CHECKDEPENDS", Value: strings.Join(m.CheckDepends, "\n")}, {"CHECKDEPENDS", strings.Join(m.CheckDepends, "\n")},
} }
var result string var result string

View File

@ -81,8 +81,8 @@ func getPackageFile(ctx *context.Context, distro, file string) (*pkg_model.Packa
// Finds all arch packages in user/organization scope, each package version // Finds all arch packages in user/organization scope, each package version
// starting from latest in descending order is checked to be compatible with // starting from latest in descending order is checked to be compatible with
// requested combination of architecture and distribution. When/If the first // requested combination of architecture and distribution. When/If the first
// compatible version is found, related desc file will be loaded from database // compatible version is found, related desc file will be loaded from package
// and added to resulting .db.tar.gz archive. // properties and added to resulting .db.tar.gz archive.
func CreatePacmanDb(ctx *context.Context, owner, arch, distro string) (io.ReadSeeker, error) { func CreatePacmanDb(ctx *context.Context, owner, arch, distro string) (io.ReadSeeker, error) {
pkgs, err := pkg_model.GetPackagesByType(ctx, ctx.Package.Owner.ID, pkg_model.TypeArch) pkgs, err := pkg_model.GetPackagesByType(ctx, ctx.Package.Owner.ID, pkg_model.TypeArch)
if err != nil { if err != nil {
@ -120,19 +120,12 @@ func CreatePacmanDb(ctx *context.Context, owner, arch, distro string) (io.ReadSe
return nil, err return nil, err
} }
var descvalue string
for _, pp := range pps { for _, pp := range pps {
if pp.Name == "desc" { if pp.Name == "desc" {
descvalue = pp.Value entries[pkg.Name+"-"+ver.Version+"/desc"] = []byte(pp.Value)
break
} }
} }
if descvalue == "" {
continue
}
entries[pkg.Name+"-"+ver.Version+"/desc"] = []byte(descvalue)
break
} }
} }