mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-01 14:56:30 +00:00
refactoring in metadata module, pacman database creation function
This commit is contained in:
parent
8974d27ba3
commit
784b4f9304
@ -166,25 +166,25 @@ func (m *DbDesc) String() string {
|
||||
Key string
|
||||
Value string
|
||||
}{
|
||||
{Key: "FILENAME", Value: m.Filename},
|
||||
{Key: "NAME", Value: m.Name},
|
||||
{Key: "BASE", Value: m.Base},
|
||||
{Key: "VERSION", Value: m.Version},
|
||||
{Key: "DESC", Value: m.Description},
|
||||
{Key: "CSIZE", Value: fmt.Sprintf("%d", m.CompressedSize)},
|
||||
{Key: "ISIZE", Value: fmt.Sprintf("%d", m.InstalledSize)},
|
||||
{Key: "MD5SUM", Value: m.MD5},
|
||||
{Key: "SHA256SUM", Value: m.SHA256},
|
||||
{Key: "URL", Value: m.URL},
|
||||
{Key: "LICENSE", Value: strings.Join(m.License, "\n")},
|
||||
{Key: "ARCH", Value: strings.Join(m.Arch, "\n")},
|
||||
{Key: "BUILDDATE", Value: fmt.Sprintf("%d", m.BuildDate)},
|
||||
{Key: "PACKAGER", Value: m.Packager},
|
||||
{Key: "PROVIDES", Value: strings.Join(m.Provides, "\n")},
|
||||
{Key: "DEPENDS", Value: strings.Join(m.Depends, "\n")},
|
||||
{Key: "OPTDEPENDS", Value: strings.Join(m.OptDepends, "\n")},
|
||||
{Key: "MAKEDEPENDS", Value: strings.Join(m.MakeDepends, "\n")},
|
||||
{Key: "CHECKDEPENDS", Value: strings.Join(m.CheckDepends, "\n")},
|
||||
{"FILENAME", m.Filename},
|
||||
{"NAME", m.Name},
|
||||
{"BASE", m.Base},
|
||||
{"VERSION", m.Version},
|
||||
{"DESC", m.Description},
|
||||
{"CSIZE", fmt.Sprintf("%d", m.CompressedSize)},
|
||||
{"ISIZE", fmt.Sprintf("%d", m.InstalledSize)},
|
||||
{"MD5SUM", m.MD5},
|
||||
{"SHA256SUM", m.SHA256},
|
||||
{"URL", m.URL},
|
||||
{"LICENSE", strings.Join(m.License, "\n")},
|
||||
{"ARCH", strings.Join(m.Arch, "\n")},
|
||||
{"BUILDDATE", fmt.Sprintf("%d", m.BuildDate)},
|
||||
{"PACKAGER", m.Packager},
|
||||
{"PROVIDES", strings.Join(m.Provides, "\n")},
|
||||
{"DEPENDS", strings.Join(m.Depends, "\n")},
|
||||
{"OPTDEPENDS", strings.Join(m.OptDepends, "\n")},
|
||||
{"MAKEDEPENDS", strings.Join(m.MakeDepends, "\n")},
|
||||
{"CHECKDEPENDS", strings.Join(m.CheckDepends, "\n")},
|
||||
}
|
||||
|
||||
var result string
|
||||
|
@ -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
|
||||
// starting from latest in descending order is checked to be compatible with
|
||||
// requested combination of architecture and distribution. When/If the first
|
||||
// compatible version is found, related desc file will be loaded from database
|
||||
// and added to resulting .db.tar.gz archive.
|
||||
// compatible version is found, related desc file will be loaded from package
|
||||
// properties and added to resulting .db.tar.gz archive.
|
||||
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)
|
||||
if err != nil {
|
||||
@ -120,21 +120,14 @@ func CreatePacmanDb(ctx *context.Context, owner, arch, distro string) (io.ReadSe
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var descvalue string
|
||||
for _, pp := range pps {
|
||||
if pp.Name == "desc" {
|
||||
descvalue = pp.Value
|
||||
}
|
||||
}
|
||||
|
||||
if descvalue == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
entries[pkg.Name+"-"+ver.Version+"/desc"] = []byte(descvalue)
|
||||
entries[pkg.Name+"-"+ver.Version+"/desc"] = []byte(pp.Value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arch_module.CreatePacmanDb(entries)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user