forked from lhcb-org/lbpkr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_check.go
54 lines (45 loc) · 1.06 KB
/
cmd_check.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
)
func lbpkr_make_cmd_check() *commander.Command {
cmd := &commander.Command{
Run: lbpkr_run_cmd_check,
UsageLine: "check [options]",
Short: "check for RPM updates from the yum repository",
Long: `
check checks for RPM updates from the yum repository.
ex:
$ lbpkr check
`,
Flag: *flag.NewFlagSet("lbpkr-check", flag.ExitOnError),
}
add_default_options(cmd)
return cmd
}
func lbpkr_run_cmd_check(cmd *commander.Command, args []string) error {
var err error
debug := cmd.Flag.Lookup("v").Value.Get().(bool)
siteroot := cmd.Flag.Lookup("siteroot").Value.Get().(string)
switch len(args) {
case 0:
// no-op
default:
return fmt.Errorf("lbpkr: invalid number of arguments. expected none. got=%d (%v)",
len(args),
args,
)
}
cfg := NewConfig(siteroot)
ctx, err := New(cfg, Debug(debug))
if err != nil {
return err
}
defer ctx.Close()
ctx.msg.Infof("checking for RPMs upgrades+updates\n")
checkOnly := true
err = ctx.Update(checkOnly)
return err
}