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
55
56
57
|
// Copyright 2025 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package patching
import (
"github.com/google/syzkaller/pkg/aflow"
"github.com/google/syzkaller/pkg/aflow/action/kernel"
"github.com/google/syzkaller/pkg/vcs"
)
var baseCommitPicker = aflow.NewFuncAction("base-commit-picker", pickBaseCommit)
type baseCommitArgs struct {
// Can be used to override the selected base commit (for manual testing).
FixedBaseCommit string
}
type baseCommitResult struct {
KernelRepo string
KernelCommit string
}
func pickBaseCommit(ctx *aflow.Context, args baseCommitArgs) (baseCommitResult, error) {
// Currently we use the latest RC of the mainline tree as the base.
// This is a reasonable choice overall in lots of cases, and it enables good caching
// of all artifacts (we need to rebuild them only approx every week).
// Potentially we can use subsystem trees for few important, well-maintained subsystems
// (mm, net, etc). However, it will work poorly for all subsystems. First, there is no
// machine-usable mapping of subsystems to repo/branch; second, lots of them are poorly
// maintained (can be much older than latest RC); third, it will make artifact caching
// much worse.
// In the future we ought to support automated rebasing of patches to requested trees/commits.
// We need it anyway, but it will also alleviate imperfect base commit picking.
const (
baseRepo = "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git"
baseBranch = "master"
)
res := baseCommitResult{
KernelRepo: baseRepo,
KernelCommit: args.FixedBaseCommit,
}
if args.FixedBaseCommit != "" {
return res, nil
}
err := kernel.UseLinuxRepo(ctx, func(_ string, repo vcs.Repo) error {
head, err := repo.Poll(baseRepo, baseBranch)
if err != nil {
return err
}
res.KernelCommit, err = repo.ReleaseTag(head.Hash)
return err
})
return res, err
}
|