Skip to content

Commit 474bdf9

Browse files
committed
Bind new flag --additional-paths and add new function LoadIndexNoSign
1 parent 411f10d commit 474bdf9

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

arduino/cores/packageindex/index.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,20 @@ func LoadIndex(jsonIndexFile *paths.Path) (*Index, error) {
312312
}
313313
return &index, nil
314314
}
315+
316+
// LoadIndex reads a package_index.json from a file and returns the corresponding Index structure.
317+
func LoadIndexNoSign(jsonIndexFile *paths.Path, valid_signature bool) (*Index, error) {
318+
buff, err := jsonIndexFile.ReadFile()
319+
if err != nil {
320+
return nil, err
321+
}
322+
var index Index
323+
err = json.Unmarshal(buff, &index)
324+
if err != nil {
325+
return nil, err
326+
}
327+
328+
index.IsTrusted = true
329+
330+
return &index, nil
331+
}

cli/cli.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func createCliCommandTree(cmd *cobra.Command) {
104104
cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", "The output format, can be {text|json}.")
105105
cmd.PersistentFlags().StringVar(&configFile, "config-file", "", "The custom config file (if not specified the default will be used).")
106106
cmd.PersistentFlags().StringSlice("additional-urls", []string{}, "Comma-separated list of additional URLs for the Boards Manager.")
107+
cmd.PersistentFlags().StringSlice("additional-paths", []string{}, "Comma-separated list of additional file paths for the Boards Manager.")
107108
configuration.BindFlags(cmd, configuration.Settings)
108109
}
109110

commands/instances.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,27 +203,19 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
203203
json_paths := []string{}
204204
json_paths = append(json_paths, configuration.Settings.GetStringSlice("board_manager.additional_paths")...)
205205
for _, x := range json_paths {
206+
logrus.Info("JSON_PATH: ", x)
206207
//path_to_json, err := paths.New(x).Abs()
207208
path_to_json := indexpath.Join(x)
208209

209-
if _, err := packageindex.LoadIndex(path_to_json); err != nil {
210+
if _, err := packageindex.LoadIndexNoSign(path_to_json, false); err != nil {
210211
return nil, fmt.Errorf("invalid package index in %s: %s", path_to_json, err)
211212
}
212213

213-
if err := indexpath.MkdirAll(); err != nil {
214-
return nil, fmt.Errorf("can't create data directory %s: %s", indexpath, err)
215-
}
216-
217-
//may not be necessary
218-
//coreIndexPath := indexpath.Join(path.Base(path_to_json.Path))
219-
//if err := tmp.CopyTo(coreIndexPath); err != nil {
220-
// return nil, fmt.Errorf("saving downloaded index %s: %s", path_to_json, err)
221-
//}
222214
}
223215
urls := []string{globals.DefaultIndexURL}
224216
urls = append(urls, configuration.Settings.GetStringSlice("board_manager.additional_urls")...)
225217
for _, u := range urls {
226-
logrus.Info("URL: %s", u)
218+
logrus.Info("URL: ", u)
227219
URL, err := url.Parse(u)
228220
if err != nil {
229221
logrus.Warnf("unable to parse additional URL: %s", u)
@@ -259,7 +251,7 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
259251
// Check for signature
260252
var tmpSig *paths.Path
261253
var coreIndexSigPath *paths.Path
262-
if URL.Hostname() == "downloads.WRONG.net" {
254+
if URL.Hostname() == "downloads.arduino.cc" {
263255
URLSig, err := url.Parse(URL.String())
264256
if err != nil {
265257
return nil, fmt.Errorf("parsing url for index signature check: %s", err)

0 commit comments

Comments
 (0)