diff options
author | kitsunyan | 2018-06-02 12:18:38 +0000 |
---|---|---|
committer | kitsunyan | 2018-06-02 12:18:38 +0000 |
commit | 1b3cca2815e8d8c3aa3fa11ed6cdccd7eae0421e (patch) | |
tree | b38ef720bde5279c1cec47844e5cada3003970f4 /src/feature/syncinstall.nim | |
parent | 3d420e1b546c5636e38653cb21d5dc0f4306a30a (diff) |
Abort sync operation if "--refresh" fails
Diffstat (limited to 'src/feature/syncinstall.nim')
-rw-r--r-- | src/feature/syncinstall.nim | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index 4bb3837..1ca1083 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -1307,53 +1307,55 @@ proc resolveBuildTargets(config: Config, targets: seq[PackageTarget], finalPkgInfos, additionalPkgInfos, buildPaths & aurPaths) proc handleSyncInstall*(args: seq[Argument], config: Config): int = - let (_, callArgs) = checkAndRefresh(config.color, args) - - let upgradeCount = args.count(%%%"sysupgrade") - let nodepsCount = args.count(%%%"nodeps") - let needed = args.check(%%%"needed") - let noaur = args.check(%%%"noaur") - let build = args.check(%%%"build") - - let printModeArg = args.check(%%%"print") - let printModeFormat = args.filter(arg => arg.matchOption(%%%"print-format")).optLast - let printFormat = if printModeArg or printModeFormat.isSome: - some(printModeFormat.map(arg => arg.value.get).get("%l")) - else: - none(string) + let (refreshCode, callArgs) = checkAndRefresh(config.color, args) + if refreshCode != 0: + refreshCode + else: + let upgradeCount = args.count(%%%"sysupgrade") + let nodepsCount = args.count(%%%"nodeps") + let needed = args.check(%%%"needed") + let noaur = args.check(%%%"noaur") + let build = args.check(%%%"build") + + let printModeArg = args.check(%%%"print") + let printModeFormat = args.filter(arg => arg.matchOption(%%%"print-format")).optLast + let printFormat = if printModeArg or printModeFormat.isSome: + some(printModeFormat.map(arg => arg.value.get).get("%l")) + else: + none(string) - let noconfirm = args - .filter(arg => arg.matchOption(%%%"confirm") or - arg.matchOption(%%%"noconfirm")).optLast - .map(arg => arg.key == "noconfirm").get(false) or - args.check(%%%"ask") - - let targets = args.packageTargets(false) - - withAur(): - let (code, installed, targetNamesSet, pacmanTargets, - pkgInfos, additionalPkgInfos, paths) = resolveBuildTargets(config, targets, - printFormat.isSome, upgradeCount, noconfirm, needed, noaur, build) - - let pacmanArgs = callArgs.filterExtensions(true, true, - commonOptions, transactionOptions, upgradeOptions, syncOptions) - if code != 0: - code - elif printFormat.isSome: - handlePrint(pacmanArgs, config, printFormat.unsafeGet, upgradeCount, nodepsCount, - pacmanTargets, pkgInfos, additionalPkgInfos, noaur) - else: - let explicitsNamesSet = installed.filter(i => i.explicit).map(i => i.name).toSet - let depsNamesSet = installed.filter(i => not i.explicit).map(i => i.name).toSet - let keepNames = explicitsNamesSet + depsNamesSet + targetNamesSet - - let explicits = if args.check(%%%"asexplicit"): - targetNamesSet + explicitsNamesSet + depsNamesSet - elif args.check(%%%"asdeps"): - initSet[string]() - else: - explicitsNamesSet + (targetNamesSet - depsNamesSet) + let noconfirm = args + .filter(arg => arg.matchOption(%%%"confirm") or + arg.matchOption(%%%"noconfirm")).optLast + .map(arg => arg.key == "noconfirm").get(false) or + args.check(%%%"ask") + + let targets = args.packageTargets(false) + + withAur(): + let (code, installed, targetNamesSet, pacmanTargets, + pkgInfos, additionalPkgInfos, paths) = resolveBuildTargets(config, targets, + printFormat.isSome, upgradeCount, noconfirm, needed, noaur, build) + + let pacmanArgs = callArgs.filterExtensions(true, true, + commonOptions, transactionOptions, upgradeOptions, syncOptions) + if code != 0: + code + elif printFormat.isSome: + handlePrint(pacmanArgs, config, printFormat.unsafeGet, upgradeCount, nodepsCount, + pacmanTargets, pkgInfos, additionalPkgInfos, noaur) + else: + let explicitsNamesSet = installed.filter(i => i.explicit).map(i => i.name).toSet + let depsNamesSet = installed.filter(i => not i.explicit).map(i => i.name).toSet + let keepNames = explicitsNamesSet + depsNamesSet + targetNamesSet + + let explicits = if args.check(%%%"asexplicit"): + targetNamesSet + explicitsNamesSet + depsNamesSet + elif args.check(%%%"asdeps"): + initSet[string]() + else: + explicitsNamesSet + (targetNamesSet - depsNamesSet) - handleInstall(pacmanArgs, config, upgradeCount, nodepsCount, noconfirm, - explicits, installed, pacmanTargets, pkgInfos, additionalPkgInfos, keepNames, - paths, build, noaur) + handleInstall(pacmanArgs, config, upgradeCount, nodepsCount, noconfirm, + explicits, installed, pacmanTargets, pkgInfos, additionalPkgInfos, keepNames, + paths, build, noaur) |