1
0

feat: check for mirrored packages

This commit is contained in:
2023-05-15 13:07:56 +00:00
parent e1ac75d0fa
commit d118ab03c3
2 changed files with 35 additions and 0 deletions

26
cache/cache.go vendored
View File

@ -6,6 +6,7 @@ package cache
import (
"fmt"
"net/http"
"net/url"
"os"
"os/exec"
@ -14,6 +15,7 @@ import (
"github.com/cavaliergopher/grab/v3"
"github.com/rs/zerolog/log"
"code.dumpstack.io/tools/out-of-tree/config"
"code.dumpstack.io/tools/out-of-tree/fs"
)
@ -88,3 +90,27 @@ func DownloadDebianCache(cachePath string) (err error) {
return os.Rename(resp.Filename, cachePath)
}
func PackageURL(dt config.DistroType, orig string) (found bool, fileurl string) {
if dt != config.Debian {
return
}
filename := filepath.Base(orig)
fileurl, err := url.JoinPath(URL, "packages/debian", filename)
if err != nil {
return
}
resp, err := http.Head(fileurl)
if err != nil {
return
}
if resp.StatusCode != http.StatusOK {
return
}
found = true
return
}