@@ -15,6 +15,12 @@ import (
1515 "github.com/roemer/gover"
1616)
1717
18+ //////////
19+ // Configuration
20+ //////////
21+
22+ const nvidiaDownloadBaseURL = "https://developer.download.nvidia.com"
23+
1824//////////
1925// Main
2026//////////
@@ -29,6 +35,7 @@ func main() {
2935func runMain () error {
3036 // Handle the flags
3137 version := flag .String ("version" , "latest" , "" )
38+ keyringVersion := flag .String ("keyringVersion" , "" , "" )
3239 installLibraries := flag .Bool ("installLibraries" , true , "" )
3340 installDevLibraries := flag .Bool ("installDevLibraries" , true , "" )
3441 installCompiler := flag .Bool ("installCompiler" , true , "" )
@@ -42,12 +49,12 @@ func runMain() error {
4249 return err
4350 }
4451
45- installer .HandleOverride (downloadUrl , "https://developer.download.nvidia.com" , "nvidia-cuda-download-url" )
52+ installer .HandleOverride (downloadUrl , nvidiaDownloadBaseURL , "nvidia-cuda-download-url" )
4653
4754 // Create and process the feature
4855 feature := installer .NewFeature ("NVIDIA CUDA" , false ,
4956 & cudaKeyringComponent {
50- ComponentBase : installer .NewComponentBase ("Keyring" , installer . VERSION_LATEST ),
57+ ComponentBase : installer .NewComponentBase ("Keyring" , * keyringVersion ),
5158 DownloadUrl : * downloadUrl ,
5259 },
5360 )
@@ -96,7 +103,7 @@ type cudaKeyringComponent struct {
96103 DownloadUrl string
97104}
98105
99- func (c * cudaKeyringComponent ) getCudaRepo () (string , error ) {
106+ func (c * cudaKeyringComponent ) getCudaRepo (baseUrl string ) (string , error ) {
100107 osInfo , err := installer .Tools .System .GetOsInfo ()
101108 if err != nil {
102109 return "" , err
@@ -114,19 +121,20 @@ func (c *cudaKeyringComponent) getCudaRepo() (string, error) {
114121 if archPart == "arm64" {
115122 return "" , fmt .Errorf ("No CUDA binaries are available for ARM64" )
116123 }
117- return fmt .Sprintf ("%s/compute/cuda/repos/%s%d/%s/" , c . DownloadUrl , osInfo .Vendor , osInfo .MajorVersion (), archPart ), nil
124+ return fmt .Sprintf ("%s/compute/cuda/repos/%s%d/%s/" , baseUrl , osInfo .Vendor , osInfo .MajorVersion (), archPart ), nil
118125 }
119126 if osInfo .IsUbuntu () {
120- return fmt .Sprintf ("%s/compute/cuda/repos/%s%s/%s/" , c . DownloadUrl , osInfo .Vendor , strings .ReplaceAll (osInfo .VersionId , "." , "" ), archPart ), nil
127+ return fmt .Sprintf ("%s/compute/cuda/repos/%s%s/%s/" , baseUrl , osInfo .Vendor , strings .ReplaceAll (osInfo .VersionId , "." , "" ), archPart ), nil
121128 }
122129 return "" , fmt .Errorf ("unsupported OS: %s" , osInfo .Vendor )
123130}
124131
125132func (c * cudaKeyringComponent ) GetAllVersions () ([]* gover.Version , error ) {
126- indexUrl , err := c .getCudaRepo ()
133+ cudaRepo , err := c .getCudaRepo (nvidiaDownloadBaseURL )
127134 if err != nil {
128135 return nil , err
129136 }
137+ indexUrl := fmt .Sprintf ("%s%s" , cudaRepo , "index.html" )
130138
131139 allVersions , err := installer .Tools .Http .GetVersionsFromHtmlIndex (
132140 indexUrl ,
@@ -140,7 +148,7 @@ func (c *cudaKeyringComponent) GetAllVersions() ([]*gover.Version, error) {
140148
141149func (c * cudaKeyringComponent ) InstallVersion (version * gover.Version ) error {
142150 // Download the file
143- cudaRepo , err := c .getCudaRepo ()
151+ cudaRepo , err := c .getCudaRepo (c . DownloadUrl )
144152 if err != nil {
145153 return err
146154 }
0 commit comments