ref: explicit link and unlink params
This commit is contained in:
25
brew.py
25
brew.py
@@ -445,7 +445,7 @@ def cli_unlink(args: ArgParams) -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# perform unlink
|
# perform unlink
|
||||||
pkg.unlink(unlinkOpt=not args.bin, dryRun=args.dry)
|
pkg.unlink(unlinkOpt=not args.bin, unlinkBin=True, dryRun=args.dry)
|
||||||
Log.main('==> Unlinked', 'binaries from' if args.bin else '', prev)
|
Log.main('==> Unlinked', 'binaries from' if args.bin else '', prev)
|
||||||
|
|
||||||
|
|
||||||
@@ -471,8 +471,8 @@ def cli_switch(args: ArgParams) -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
hasBinLinks = bool(pkg.binLinks)
|
hasBinLinks = bool(pkg.binLinks)
|
||||||
pkg.unlink(unlinkBin=hasBinLinks)
|
pkg.unlink(unlinkOpt=True, unlinkBin=hasBinLinks)
|
||||||
pkg.version(args.version).link(linkBin=hasBinLinks)
|
pkg.version(args.version).link(linkOpt=True, linkBin=hasBinLinks)
|
||||||
Log.main('==> switched to version', pkg.activeVersion)
|
Log.main('==> switched to version', pkg.activeVersion)
|
||||||
if not hasBinLinks:
|
if not hasBinLinks:
|
||||||
Log.warn('no binary links found. Skipped for new version as well.')
|
Log.warn('no binary links found. Skipped for new version as well.')
|
||||||
@@ -490,12 +490,12 @@ def cli_toggle(args: ArgParams) -> None:
|
|||||||
if x.name == baseName or x.name.startswith(baseName + '@')]
|
if x.name == baseName or x.name.startswith(baseName + '@')]
|
||||||
|
|
||||||
for prev in allVersions:
|
for prev in allVersions:
|
||||||
prev.unlink()
|
prev.unlink(unlinkOpt=False, unlinkBin=True)
|
||||||
|
|
||||||
if isActive:
|
if isActive:
|
||||||
Log.info('==> disabled', pkg.name)
|
Log.info('==> disabled', pkg.name)
|
||||||
else:
|
else:
|
||||||
pkg.anyVersion().link()
|
pkg.anyVersion().link(linkOpt=False, linkBin=True)
|
||||||
Log.info('==> enabled', pkg.name, pkg.activeVersion)
|
Log.info('==> enabled', pkg.name, pkg.activeVersion)
|
||||||
|
|
||||||
|
|
||||||
@@ -1263,7 +1263,7 @@ class LocalPackage:
|
|||||||
if lnk.target.startswith(self.path + '/')]
|
if lnk.target.startswith(self.path + '/')]
|
||||||
|
|
||||||
def unlink(
|
def unlink(
|
||||||
self, *, unlinkOpt: bool = True, unlinkBin: bool = True,
|
self, *, unlinkOpt: bool, unlinkBin: bool,
|
||||||
dryRun: bool = False, quiet: bool = False,
|
dryRun: bool = False, quiet: bool = False,
|
||||||
) -> list[LinkTarget]:
|
) -> list[LinkTarget]:
|
||||||
''' remove symlinks `@/opt/<pkg>` and `@/bin/...` matching target '''
|
''' remove symlinks `@/opt/<pkg>` and `@/bin/...` matching target '''
|
||||||
@@ -1350,7 +1350,7 @@ class LocalPackageVersion:
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
def link(
|
def link(
|
||||||
self, *, linkOpt: bool = True, linkBin: bool = True,
|
self, *, linkOpt: bool, linkBin: bool,
|
||||||
dryRun: bool = False, quiet: bool = False,
|
dryRun: bool = False, quiet: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
''' create symlinks `@/opt/<pkg>` and `@/bin/...` matching target '''
|
''' create symlinks `@/opt/<pkg>` and `@/bin/...` matching target '''
|
||||||
@@ -1854,14 +1854,12 @@ class InstallQueue:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if vpkg.isKegOnly:
|
if vpkg.isKegOnly:
|
||||||
if not pkg.optLink:
|
linkBin = False
|
||||||
vpkg.link(linkBin=False)
|
|
||||||
Log.warn('keg-only, must link manually ({}, {})'.format(
|
Log.warn('keg-only, must link manually ({}, {})'.format(
|
||||||
pkg.name, vpkg.version), summary=True)
|
pkg.name, vpkg.version), summary=True)
|
||||||
continue
|
|
||||||
|
|
||||||
pkg.unlink()
|
pkg.unlink(unlinkOpt=True, unlinkBin=True) # cleanup prev install
|
||||||
vpkg.link(linkBin=linkBin)
|
vpkg.link(linkOpt=True, linkBin=linkBin)
|
||||||
|
|
||||||
Log.endCounter()
|
Log.endCounter()
|
||||||
Log.dumpErrorSummary()
|
Log.dumpErrorSummary()
|
||||||
@@ -2030,7 +2028,8 @@ class UninstallQueue:
|
|||||||
Log.info('==> Remove symlinks for', countPkgs, 'packages')
|
Log.info('==> Remove symlinks for', countPkgs, 'packages')
|
||||||
countSym = 0
|
countSym = 0
|
||||||
for pkg in self.uninstallQueue:
|
for pkg in self.uninstallQueue:
|
||||||
links = pkg.unlink(dryRun=dryRun, quiet=dryRun and Log.LEVEL <= 2)
|
links = pkg.unlink(unlinkOpt=True, unlinkBin=True,
|
||||||
|
dryRun=dryRun, quiet=dryRun and Log.LEVEL <= 2)
|
||||||
countSym += len(links)
|
countSym += len(links)
|
||||||
Log.main('Would remove' if dryRun else 'Removed', countSym, 'symlinks')
|
Log.main('Would remove' if dryRun else 'Removed', countSym, 'symlinks')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user