Added normal up functionality
This commit is contained in:
parent
c1eb7b0e94
commit
ecdf09c63b
2 changed files with 65 additions and 4 deletions
14
main.go
14
main.go
|
|
@ -52,7 +52,7 @@ func printHelp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
usage := fmt.Sprintf(`%susage%s: vlcro [-h] [-v] [-y] [-j N] [--debug] [--no-color]
|
usage := fmt.Sprintf(`%susage%s: vlcro [-h] [-v] [-y] [-j N] [--debug] [--no-color]
|
||||||
%s {refresh,ref,dist-upgrade,dup,install,in,install-new-recommends,inr} ...
|
%s {refresh,ref,dist-upgrade,dup,update,up,install,in,install-new-recommends,inr} ...
|
||||||
|
|
||||||
%s%s%s (%sv%s%s) makes zypper faster by running slow operations in parallel.
|
%s%s%s (%sv%s%s) makes zypper faster by running slow operations in parallel.
|
||||||
|
|
||||||
|
|
@ -71,6 +71,9 @@ func printHelp() {
|
||||||
%sdist-upgrade%s (%sdup%s) perform distribution upgrade
|
%sdist-upgrade%s (%sdup%s) perform distribution upgrade
|
||||||
%s-d, --download-only%s download packages without installing
|
%s-d, --download-only%s download packages without installing
|
||||||
|
|
||||||
|
%supdate%s (%sup%s) update all installed packages
|
||||||
|
%s-d, --download-only%s download packages without installing
|
||||||
|
|
||||||
%sinstall%s (%sin%s) install one or more packages
|
%sinstall%s (%sin%s) install one or more packages
|
||||||
%s-d, --download-only%s download packages without installing
|
%s-d, --download-only%s download packages without installing
|
||||||
%s<package>%s package name(s) to install
|
%s<package>%s package name(s) to install
|
||||||
|
|
@ -86,6 +89,7 @@ func printHelp() {
|
||||||
hi, d,
|
hi, d,
|
||||||
hd, d, hd, d, he, d,
|
hd, d, hd, d, he, d,
|
||||||
hd, d, hd, d, he, d,
|
hd, d, hd, d, he, d,
|
||||||
|
hd, d, hd, d, he, d,
|
||||||
hd, d, hd, d, he, d, hd, d,
|
hd, d, hd, d, he, d, hd, d,
|
||||||
hd, d, hd, d, he, d)
|
hd, d, hd, d, he, d)
|
||||||
|
|
||||||
|
|
@ -123,8 +127,8 @@ func isInstallCommand(cmd string) bool {
|
||||||
|
|
||||||
func isKnownCommand(cmd string) bool {
|
func isKnownCommand(cmd string) bool {
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case "refresh", "ref", "dist-upgrade", "dup", "install", "in",
|
case "refresh", "ref", "dist-upgrade", "dup", "update", "up",
|
||||||
"install-new-recommends", "inr":
|
"install", "in", "install-new-recommends", "inr":
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
@ -340,6 +344,10 @@ func main() {
|
||||||
if err := handleDistUpgrade(ctx, tmpDir); err != nil {
|
if err := handleDistUpgrade(ctx, tmpDir); err != nil {
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
}
|
}
|
||||||
|
case "update", "up":
|
||||||
|
if err := handleUpdate(ctx, tmpDir); err != nil {
|
||||||
|
exitCode = 1
|
||||||
|
}
|
||||||
case "install", "in":
|
case "install", "in":
|
||||||
if err := handleInstall(ctx, tmpDir); err != nil {
|
if err := handleInstall(ctx, tmpDir); err != nil {
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
|
|
|
||||||
53
zypper.go
53
zypper.go
|
|
@ -742,6 +742,59 @@ func handleDistUpgrade(ctx context.Context, tmpDir string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleUpdate(ctx context.Context, tmpDir string) error {
|
||||||
|
tracker := &MountTracker{}
|
||||||
|
defer vlcroCleanup(tmpDir, tracker)
|
||||||
|
|
||||||
|
statusMsg("Reading package lists")
|
||||||
|
statusMsg("Building dependency tree")
|
||||||
|
info, err := dryRunAndParse([]string{"update", "--dry-run"})
|
||||||
|
if err != nil {
|
||||||
|
errorf("%s", colorText(colorError, fmt.Sprintf("Error: %v", err)))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if info.nothingToDo {
|
||||||
|
infof("%s", colorText(colorInfo, "Nothing to do. Exiting..."))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.txInfo = info.installs
|
||||||
|
|
||||||
|
if !showTransactionAndConfirm(info) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
getZyppLock()
|
||||||
|
|
||||||
|
if info.downloadSize > 0 {
|
||||||
|
statusMsg("Downloading packages")
|
||||||
|
err := mainTask(ctx, pkgNames(info.installs), tmpDir, false, tracker)
|
||||||
|
if err == context.Canceled {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
warningf("%s", colorText(colorWarning, fmt.Sprintf("Parallel execution failed (%v). Falling back to standard zypper...", err)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vlcroCleanup(tmpDir, tracker)
|
||||||
|
|
||||||
|
if !cfg.downloadOnly {
|
||||||
|
infof("%s", colorText(colorInfo, "Vlcro has finished its tasks. Handing you over to zypper..."))
|
||||||
|
nonInteractive := ""
|
||||||
|
if cfg.noConfirm {
|
||||||
|
nonInteractive = "--non-interactive"
|
||||||
|
}
|
||||||
|
code := handover(fmt.Sprintf("env ZYPP_CURL2=1 ZYPP_PCK_PRELOAD=1 ZYPP_SINGLE_RPMTRANS=1 zypper %s --no-cd update", nonInteractive))
|
||||||
|
if code != 0 {
|
||||||
|
return fmt.Errorf("zypper update failed with exit code %d", code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func handleInstall(ctx context.Context, tmpDir string) error {
|
func handleInstall(ctx context.Context, tmpDir string) error {
|
||||||
if len(cfg.packages) == 0 {
|
if len(cfg.packages) == 0 {
|
||||||
errorf("%s", colorText(colorError, "No packages specified for installation"))
|
errorf("%s", colorText(colorError, "No packages specified for installation"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue