Skip to content

Commit

Permalink
chore: Arch git migration and repo changes
Browse files Browse the repository at this point in the history
* fetch PKGBUILD files from Archlinux Gitlab instead of Github
* change list of official repositories

https://archlinux.org/news/git-migration-announcement/
Signed-off-by: moson-mo <[email protected]>
  • Loading branch information
moson-mo committed May 19, 2023
1 parent 6bc944c commit 1d77f3d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
23 changes: 17 additions & 6 deletions internal/pacseek/pkgbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ import (
"fmt"
"io"
"net/http"
"regexp"
"strings"

"github.com/moson-mo/pacseek/internal/util"
)

// regex replacements for Gitlab URL's
// https://gitlab.archlinux.org/archlinux/devtools/-/blob/b519c8128e59e5431e2854b322e8b3a0088643cc/src/lib/api/gitlab.sh#L87
var gitlabRepl = map[string]*regexp.Regexp{
`$1-$2`: regexp.MustCompile(`([a-zA-Z0-9]+)\+([a-zA-Z]+)`),
`plus`: regexp.MustCompile(`\+`),
`-`: regexp.MustCompile(`[^a-zA-Z0-9_\-\.]`),
}

// download the PKGBUILD file
func getPkgbuildContent(url string) (string, error) {
resp, err := http.Get(url)
Expand All @@ -28,16 +37,18 @@ func getPkgbuildContent(url string) (string, error) {
// composes the URL to a PKGBUILD file
func getPkgbuildUrl(source, base string) string {
if util.SliceContains(getArchRepos(), source) {
repo := "packages"
if strings.Contains(source, "community") ||
source == "multilib" {
repo = "community"
}
return fmt.Sprintf(UrlRepoPkgbuild, repo, base)
return fmt.Sprintf(UrlRepoPkgbuild, encodePackageGitlabUrl(base))
}
return fmt.Sprintf(UrlAurPkgbuild, base)
}

func encodePackageGitlabUrl(pkgname string) string {
for rep, regex := range gitlabRepl {
pkgname = regex.ReplaceAllString(pkgname, rep)
}
return pkgname
}

// returns command to download and display PKGBUILD
func (ps *UI) getPkgbuildCommand(source, base string) string {
return strings.Replace(ps.conf.ShowPkgbuildCommand, "{url}", getPkgbuildUrl(source, base), -1)
Expand Down
4 changes: 2 additions & 2 deletions internal/pacseek/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
UrlAurPkgbuild = "https://raw.githubusercontent.com/archlinux/aur/%s/PKGBUILD"
UrlPackage = "https://archlinux.org/packages/%s/%s/%s"
UrlArmPackage = "https://archlinuxarm.org/packages/%s/%s"
UrlRepoPkgbuild = "https://raw.githubusercontent.com/archlinux/svntogit-%s/packages/%s/trunk/PKGBUILD"
UrlRepoPkgbuild = "https://gitlab.archlinux.org/archlinux/packaging/packages/%s/-/raw/main/PKGBUILD"

UrlAurMaintainer = "https://aur.archlinux.org/packages?SeB=m&K=%s"

Expand Down Expand Up @@ -147,7 +147,7 @@ func (ps *UI) Start() error {

// getArchRepos returns a list of Arch Linux repositories
func getArchRepos() []string {
return []string{"core", "community", "community-testing", "extra", "kde-unstable", "multilib", "multilib-testing", "testing"}
return []string{"core", "core-testing", "extra", "extra-testing", "multilib", "multilib-testing", "kde-unstable"}
}

// getArchArmRepos returns a list of Arch Linux ARM repositories
Expand Down

0 comments on commit 1d77f3d

Please sign in to comment.