-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel_deb_downloader.go
49 lines (39 loc) · 1.15 KB
/
kernel_deb_downloader.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
package main
import (
"flag"
"fmt"
"net/http"
"os"
"github.com/pmalek/kernel_deb_downloader/ubuntukernelpageutils"
)
var (
onlyPrintVersion bool
showChanges bool
)
func init() {
flag.BoolVar(&onlyPrintVersion, "n", false, "Print newest version - do not download the .debs")
flag.BoolVar(&showChanges, "c", false, "Show changes included in particular kernel package")
}
func main() {
flag.Parse()
version, packageURL, err := ubuntukernelpageutils.GetMostActualKernelVersion(http.DefaultClient)
if err != nil {
fmt.Printf("Error connecting to Ubuntu's kernel ppa webpage, error: %q", err)
os.Exit(1)
}
fmt.Printf("Most recent (non RC) version: %v, link: %v\n", version, packageURL)
if showChanges {
if changes, err := ubuntukernelpageutils.GetChangesFromPackageURL(http.DefaultClient, packageURL); err != nil {
fmt.Printf("Error downloading changes: %v", err.Error())
os.Exit(1)
} else {
fmt.Printf("Changes: \n%v", changes)
}
}
if onlyPrintVersion == false {
_, err = ubuntukernelpageutils.DownloadKernelDebs(http.DefaultClient, packageURL)
if err != nil {
fmt.Printf("Error downloading .deb files: %q", err)
}
}
}