feat(new_engine): add support for --nocombinedupgrade (#2083)

* feat(new_engine): add support for --nocombinedupgrade

* update en.po
This commit is contained in:
Jo 2023-04-06 13:54:03 +02:00 committed by GitHub
parent d9b57790fa
commit ce0cb35510
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 150 additions and 27 deletions

View File

@ -461,7 +461,9 @@ func earlyPacmanCall(ctx context.Context, cfg *settings.Configuration,
func earlyRefresh(ctx context.Context, cfg *settings.Configuration, cmdBuilder exe.ICmdBuilder, cmdArgs *parser.Arguments) error {
arguments := cmdArgs.Copy()
arguments.DelArg("u", "sysupgrade")
if cfg.CombinedUpgrade {
arguments.DelArg("u", "sysupgrade")
}
arguments.DelArg("s", "search")
arguments.DelArg("i", "info")
arguments.DelArg("l", "list")

View File

@ -233,7 +233,7 @@ func DefaultConfig(version string) *Configuration {
DiffMenu: true,
EditMenu: false,
UseAsk: false,
CombinedUpgrade: false,
CombinedUpgrade: true,
SeparateSources: true,
NewInstallEngine: true,
Version: version,

View File

@ -249,7 +249,7 @@ func (u *UpgradeService) UserExcludeUpgrades(graph *topo.Graph[string, *dep.Inst
allUp := UpSlice{Up: append(repoUp.Up, aurUp.Up...), Repos: append(repoUp.Repos, aurUp.Repos...)}
u.log.Printf("%s"+text.Bold(" %d ")+"%s\n", text.Bold(text.Cyan("::")), allUpLen, text.Bold(gotext.Get("Packages to upgrade.")))
u.log.Printf("%s"+text.Bold(" %d ")+"%s\n", text.Bold(text.Cyan("::")), allUpLen, text.Bold(gotext.Get("Packages to upgrade/install.")))
allUp.Print(u.log)
u.log.Infoln(gotext.Get("Packages to exclude: (eg: \"1 2 3\", \"1-3\", \"^4\" or repo name)"))

View File

@ -39,7 +39,7 @@ msgid "%s [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)"
msgstr ""
#: aur_install.go:274
#: install.go:739
#: install.go:741
msgid "%s already made -- skipping build"
msgstr ""
@ -51,13 +51,13 @@ msgstr ""
msgid "%s is present."
msgstr ""
#: aur_install.go:271
#: install.go:725
#: pkg/dep/dep_graph.go:385
#: aur_install.go:271
#: install.go:727
msgid "%s is up to date -- skipping"
msgstr ""
#: install.go:640
#: install.go:642
msgid "%s not satisfied, flushing install queue"
msgstr ""
@ -144,8 +144,8 @@ msgstr ""
msgid "Check Deps"
msgstr ""
#: upgrade.go:95
#: pkg/upgrade/service.go:78
#: upgrade.go:95
msgid "Checking development packages..."
msgstr ""
@ -381,8 +381,8 @@ msgstr ""
msgid "Packages to cleanBuild?"
msgstr ""
#: upgrade.go:213
#: pkg/dep/dep_graph.go:215
#: upgrade.go:213
msgid "Packages to exclude"
msgstr ""
@ -395,10 +395,13 @@ msgid "Packages to install (eg: 1 2 3, 1-3 or ^4)"
msgstr ""
#: upgrade.go:210
#: pkg/upgrade/service.go:252
msgid "Packages to upgrade."
msgstr ""
#: pkg/upgrade/service.go:252
msgid "Packages to upgrade/install."
msgstr ""
#: print.go:42
msgid "Popularity"
msgstr ""
@ -428,8 +431,8 @@ msgstr ""
msgid "Repository AUR"
msgstr ""
#: print.go:25
#: pkg/db/ialpm/alpm.go:191
#: print.go:25
msgid "Repository"
msgstr ""
@ -437,13 +440,13 @@ msgstr ""
msgid "SRCINFO"
msgstr ""
#: upgrade.go:73
#: pkg/upgrade/service.go:63
#: upgrade.go:73
msgid "Searching AUR for updates..."
msgstr ""
#: upgrade.go:62
#: pkg/upgrade/service.go:142
#: upgrade.go:62
msgid "Searching databases for updates..."
msgstr ""
@ -471,14 +474,14 @@ msgstr ""
msgid "Ten biggest packages:"
msgstr ""
#: install.go:493
#: install.go:495
#: sync.go:183
msgid "The following packages are not compatible with your architecture:"
msgstr ""
#: pkg/db/ialpm/alpm.go:179
#: pkg/dep/depPool.go:499
#: pkg/dep/dep_graph.go:627
#: pkg/db/ialpm/alpm.go:179
msgid "There are %d providers available for %s:"
msgstr ""
@ -494,7 +497,7 @@ msgstr ""
msgid "Total installed packages: %s"
msgstr ""
#: install.go:501
#: install.go:503
#: sync.go:191
msgid "Try to build them anyway?"
msgstr ""
@ -542,9 +545,9 @@ msgstr ""
msgid "\nBuild directory:"
msgstr ""
#: pkg/db/ialpm/alpm.go:201
#: pkg/dep/depPool.go:513
#: pkg/dep/dep_graph.go:641
#: pkg/db/ialpm/alpm.go:201
msgid "\nEnter a number (default=1): "
msgstr ""
@ -560,7 +563,7 @@ msgstr ""
msgid "cannot find PKGBUILD and .SRCINFO in directory"
msgstr ""
#: install.go:530
#: install.go:532
msgid "cannot find package name: %v"
msgstr ""
@ -580,7 +583,7 @@ msgstr ""
msgid "could not find any package archives listed in %s"
msgstr ""
#: install.go:786
#: install.go:788
msgid "could not find srcinfo for: %s"
msgstr ""
@ -618,14 +621,14 @@ msgstr ""
#: aur_install.go:204
#: aur_install.go:208
#: install.go:681
#: install.go:722
#: install.go:736
#: install.go:750
#: install.go:683
#: install.go:724
#: install.go:738
#: install.go:752
msgid "error making: %s"
msgstr ""
#: install.go:586
#: install.go:588
msgid "error merging %s: %s"
msgstr ""
@ -639,7 +642,7 @@ msgid "error refreshing databases"
msgstr ""
#: clean.go:220
#: install.go:579
#: install.go:581
msgid "error resetting %s: %s"
msgstr ""
@ -687,9 +690,9 @@ msgstr ""
msgid "input too long"
msgstr ""
#: pkg/db/ialpm/alpm.go:222
#: pkg/dep/depPool.go:533
#: pkg/dep/dep_graph.go:662
#: pkg/db/ialpm/alpm.go:222
msgid "invalid number: %s"
msgstr ""
@ -705,9 +708,9 @@ msgstr ""
msgid "invalid repository"
msgstr ""
#: pkg/db/ialpm/alpm.go:227
#: pkg/dep/depPool.go:538
#: pkg/dep/dep_graph.go:668
#: pkg/db/ialpm/alpm.go:227
msgid "invalid value: %d is not between %d and %d"
msgstr ""

View File

@ -610,3 +610,121 @@ func sanitizeCall(s, tmpDir, makepkg, pacman, git string) string {
return s
}
func TestSyncUpgrade_NoCombinedUpgrade(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
combinedUpgrade bool
want []string
}{
{
name: "combined upgrade",
combinedUpgrade: true,
want: []string{"pacman -S -y -u --config /etc/pacman.conf --"},
},
{
name: "no combined upgrade",
combinedUpgrade: false,
want: []string{"pacman -S -y --config /etc/pacman.conf --"},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
makepkgBin := t.TempDir() + "/makepkg"
pacmanBin := t.TempDir() + "/pacman"
gitBin := t.TempDir() + "/git"
f, err := os.OpenFile(makepkgBin, os.O_RDONLY|os.O_CREATE, 0o755)
require.NoError(t, err)
require.NoError(t, f.Close())
f, err = os.OpenFile(pacmanBin, os.O_RDONLY|os.O_CREATE, 0o755)
require.NoError(t, err)
require.NoError(t, f.Close())
f, err = os.OpenFile(gitBin, os.O_RDONLY|os.O_CREATE, 0o755)
require.NoError(t, err)
require.NoError(t, f.Close())
captureOverride := func(cmd *exec.Cmd) (stdout string, stderr string, err error) {
return "", "", nil
}
showOverride := func(cmd *exec.Cmd) error {
return nil
}
mockRunner := &exe.MockRunner{CaptureFn: captureOverride, ShowFn: showOverride}
cmdBuilder := &exe.CmdBuilder{
MakepkgBin: makepkgBin,
SudoBin: "su",
PacmanBin: pacmanBin,
PacmanConfigPath: "/etc/pacman.conf",
GitBin: "git",
Runner: mockRunner,
SudoLoopEnabled: false,
}
cmdArgs := parser.MakeArguments()
cmdArgs.AddArg("S")
cmdArgs.AddArg("y")
cmdArgs.AddArg("u")
db := &mock.DBExecutor{
AlpmArchitecturesFn: func() ([]string, error) {
return []string{"x86_64"}, nil
},
RefreshHandleFn: func() error {
return nil
},
ReposFn: func() []string {
return []string{"core"}
},
InstalledRemotePackagesFn: func() map[string]alpm.IPackage {
return map[string]alpm.IPackage{}
},
InstalledRemotePackageNamesFn: func() []string {
return []string{}
},
SyncUpgradesFn: func(
bool,
) (map[string]db.SyncUpgrade, error) {
return map[string]db.SyncUpgrade{}, nil
},
}
cfg := &settings.Configuration{
NewInstallEngine: true,
RemoveMake: "no",
CombinedUpgrade: false,
Runtime: &settings.Runtime{
Logger: text.NewLogger(io.Discard, strings.NewReader("1\n"), true, "test"),
CmdBuilder: cmdBuilder,
VCSStore: &vcs.Mock{},
AURCache: &mockaur.MockAUR{
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
return []aur.Pkg{}, nil
},
},
},
}
err = handleCmd(context.Background(), cfg, cmdArgs, db)
require.NoError(t, err)
require.Len(t, mockRunner.ShowCalls, len(tc.want))
require.Len(t, mockRunner.CaptureCalls, 0)
for i, call := range mockRunner.ShowCalls {
show := call.Args[0].(*exec.Cmd).String()
show = strings.ReplaceAll(show, pacmanBin, "pacman")
// options are in a different order on different systems and on CI root user is used
assert.Subset(t, strings.Split(show, " "), strings.Split(tc.want[i], " "), fmt.Sprintf("%d - %s", i, show))
}
})
}
}