use .SRCINFO if available

This commit is contained in:
2024-08-09 02:11:35 +02:00
parent 453c6d8a3a
commit 8dccbbee84
3 changed files with 39 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ import (
"gopkg.in/yaml.v2"
"io"
"io/fs"
"net/http"
"os"
"os/exec"
"path/filepath"
@@ -699,3 +700,26 @@ func Copy(srcPath, dstPath string) (err error) {
_, err = io.Copy(w, r)
return err
}
func downloadSRCINFO(pkg string, tag string) (*srcinfo.Srcinfo, error) {
resp, err := http.Get(fmt.Sprintf("https://gitlab.archlinux.org/archlinux/packaging/packages/%s/-/raw/%s/.SRCINFO", pkg, tag))
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, errors.New(resp.Status)
}
bResp, err := io.ReadAll(resp.Body)
defer resp.Body.Close()
if err != nil {
return nil, err
}
nSrcInfo, err := srcinfo.Parse(string(bResp))
if err != nil {
return nil, err
}
return nSrcInfo, nil
}