Add symlink creation to updates module and uptool

This commit is contained in:
Daniel
2019-08-16 16:46:20 +02:00
parent 9cbf98fc98
commit ca9834effa
3 changed files with 98 additions and 2 deletions

44
updates/uptool/update.go Normal file
View File

@@ -0,0 +1,44 @@
package main
import (
"encoding/json"
"io/ioutil"
"github.com/safing/portmaster/updates"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(updateCmd)
}
var updateCmd = &cobra.Command{
Use: "update",
Short: "Update scans the current directory and updates the index and symlink structure",
RunE: update,
}
func update(cmd *cobra.Command, args []string) error {
latest, err := updates.ScanForLatest(".", true)
if err != nil {
return err
}
data, err := json.MarshalIndent(latest, "", " ")
if err != nil {
return err
}
err = ioutil.WriteFile("stable.json", data, 0755)
if err != nil {
return err
}
err = updates.CreateSymlinks(updatesStorage.ChildDir("latest", 0755), updatesStorage, latest)
if err != nil {
return err
}
return nil
}