feat: check for mirrored packages
This commit is contained in:
parent
e1ac75d0fa
commit
d118ab03c3
26
cache/cache.go
vendored
26
cache/cache.go
vendored
@ -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
|
||||
}
|
||||
|
@ -421,6 +421,15 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
|
||||
}
|
||||
|
||||
for _, pkg := range pkgs {
|
||||
found, newurl := cache.PackageURL(
|
||||
sk.DistroType,
|
||||
pkg.Deb.URL,
|
||||
)
|
||||
if found {
|
||||
log.Debug().Msgf("cached deb found %s", newurl)
|
||||
pkg.Deb.URL = newurl
|
||||
}
|
||||
|
||||
cmd += fmt.Sprintf(" && wget --no-check-certificate %s",
|
||||
strings.Replace(pkg.Deb.URL, "https", "http", -1))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user