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
|
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
|
||||||
|
@ -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,21 +120,14 @@ 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)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if descvalue == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
entries[pkg.Name+"-"+ver.Version+"/desc"] = []byte(descvalue)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return arch_module.CreatePacmanDb(entries)
|
return arch_module.CreatePacmanDb(entries)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user