Implements basic version guessing
This commit is contained in:
parent
e91af205f4
commit
8b421f2cf0
@ -44,3 +44,7 @@ If you already have Go, Qemu and Docker installed, there's cross-platform instal
|
|||||||
Test only with one kernel:
|
Test only with one kernel:
|
||||||
|
|
||||||
$ out-of-tree pew --kernel='Ubuntu:4.10.0-30-generic'
|
$ out-of-tree pew --kernel='Ubuntu:4.10.0-30-generic'
|
||||||
|
|
||||||
|
Guess work kernels:
|
||||||
|
|
||||||
|
$ out-of-tree pew --guess
|
||||||
|
32
main.go
32
main.go
@ -95,6 +95,11 @@ const (
|
|||||||
|
|
||||||
var distroTypeStrings = [...]string{"Ubuntu", "CentOS", "Debian"}
|
var distroTypeStrings = [...]string{"Ubuntu", "CentOS", "Debian"}
|
||||||
|
|
||||||
|
func newDistroType(dType string) (dt distroType, err error) {
|
||||||
|
err = dt.UnmarshalTOML([]byte(dType))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (dt distroType) String() string {
|
func (dt distroType) String() string {
|
||||||
return distroTypeStrings[dt]
|
return distroTypeStrings[dt]
|
||||||
}
|
}
|
||||||
@ -407,7 +412,7 @@ func exists(path string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func pewHandler(workPath, kcfgPath, overridedKernel string) (err error) {
|
func pewHandler(workPath, kcfgPath, ovrrdKrnl string, guess bool) (err error) {
|
||||||
ka, err := readArtifactConfig(workPath + "/.out-of-tree.toml")
|
ka, err := readArtifactConfig(workPath + "/.out-of-tree.toml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -417,14 +422,14 @@ func pewHandler(workPath, kcfgPath, overridedKernel string) (err error) {
|
|||||||
ka.SourcePath = workPath
|
ka.SourcePath = workPath
|
||||||
}
|
}
|
||||||
|
|
||||||
if overridedKernel != "" {
|
if ovrrdKrnl != "" {
|
||||||
parts := strings.Split(overridedKernel, ":")
|
parts := strings.Split(ovrrdKrnl, ":")
|
||||||
if len(parts) != 2 {
|
if len(parts) != 2 {
|
||||||
return errors.New("Kernel is not 'distroType:regex'")
|
return errors.New("Kernel is not 'distroType:regex'")
|
||||||
}
|
}
|
||||||
|
|
||||||
var dt distroType
|
var dt distroType
|
||||||
err = dt.UnmarshalTOML([]byte(parts[0]))
|
dt, err = newDistroType(parts[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -433,6 +438,20 @@ func pewHandler(workPath, kcfgPath, overridedKernel string) (err error) {
|
|||||||
ka.SupportedKernels = []kernelMask{km}
|
ka.SupportedKernels = []kernelMask{km}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if guess {
|
||||||
|
ka.SupportedKernels = []kernelMask{}
|
||||||
|
for _, dType := range distroTypeStrings {
|
||||||
|
var dt distroType
|
||||||
|
dt, err = newDistroType(dType)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
km := kernelMask{DistroType: dt, ReleaseMask: ".*"}
|
||||||
|
ka.SupportedKernels = append(ka.SupportedKernels, km)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
kcfg, err := readKernelConfig(kcfgPath)
|
kcfg, err := readKernelConfig(kcfgPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -465,10 +484,13 @@ func main() {
|
|||||||
pewKernelFlag := pewCommand.Flag("kernel", "Override kernel regex")
|
pewKernelFlag := pewCommand.Flag("kernel", "Override kernel regex")
|
||||||
pewKernel := pewKernelFlag.String()
|
pewKernel := pewKernelFlag.String()
|
||||||
|
|
||||||
|
pewGuessFlag := pewCommand.Flag("guess", "Try all defined kernels")
|
||||||
|
pewGuess := pewGuessFlag.Bool()
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
|
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
|
||||||
case pewCommand.FullCommand():
|
case pewCommand.FullCommand():
|
||||||
err = pewHandler(*path, *kcfg, *pewKernel)
|
err = pewHandler(*path, *kcfg, *pewKernel, *pewGuess)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user