Example #1
0
func DeleteRepoPackage(c *gin.Context) {
	repo := session.Repo(c)
	pkgname := c.Param("package")
	arch := c.Param("arch")

	if !util.StrContains(arch, repo.Archs) {
		c.AbortWithStatus(http.StatusNotFound)
		return
	}

	pkg, err := repo.Package(pkgname, arch, true)
	if err != nil {
		log.Errorf("Failed to get repo package '%s': %s", pkgname, err)
		c.AbortWithStatus(http.StatusInternalServerError)
		return
	}

	if pkg == nil {
		c.AbortWithStatus(http.StatusNotFound)
		return
	}

	err = repo.Remove([]string{pkgname}, arch)
	if err != nil {
		log.Errorf("Failed to remove repo package '%s': %s", pkgname, err)
		c.AbortWithStatus(http.StatusInternalServerError)
		return
	}

	c.Status(http.StatusOK)
}
Example #2
0
func (r *Repo) obsolete(pkgs []string, pkgMap map[string]*pkgDep) []string {
	var obsolete map[string]struct{}

	for n := range pkgMap {
		if !util.StrContains(n, pkgs) {
			obsolete[n] = struct{}{}
		}
	}

	for _, p := range pkgs {
		if deps, ok := pkgMap[p]; ok {
			for _, dep := range deps.depends {
				if _, ok := obsolete[dep]; ok {
					delete(obsolete, dep)
					break
				}
			}
		}
	}

	obsol := make([]string, 0, len(obsolete))
	for pkg := range obsolete {
		obsol = append(obsol, pkg)
	}

	return obsol
}
Example #3
0
func GetRepoPackages(c *gin.Context) {
	repo := session.Repo(c)
	arch := c.Param("arch")

	if !util.StrContains(arch, repo.Archs) {
		c.AbortWithStatus(http.StatusNotFound)
		return
	}

	pkgs, err := repo.Packages(arch, false)
	if err != nil {
		log.Errorf("Failed to get repo packages: %s", err)
		c.AbortWithStatus(http.StatusInternalServerError)
		return
	}

	c.JSON(http.StatusOK, pkgs)
}
Example #4
0
func GetRepoPackageFiles(c *gin.Context) {
	repo := session.Repo(c)
	pkgname := c.Param("package")
	arch := c.Param("arch")

	if !util.StrContains(arch, repo.Archs) {
		c.AbortWithStatus(http.StatusNotFound)
		return
	}

	pkg, err := repo.Package(pkgname, arch, true)
	if err != nil {
		log.Errorf("Failed to get repo package '%s': %s", pkgname, err)
		c.AbortWithStatus(http.StatusInternalServerError)
		return
	}

	if pkg == nil {
		c.AbortWithStatus(http.StatusNotFound)
		return
	}

	c.JSON(http.StatusOK, pkg.Files)
}