feat: indicator for primary package

This commit is contained in:
relikd
2025-08-31 13:09:19 +02:00
parent 676cb71665
commit a5590bb2ee

22
brew.py
View File

@@ -1171,10 +1171,15 @@ class Cellar:
return os.path.join(Cellar.CELLAR, pkg, version) return os.path.join(Cellar.CELLAR, pkg, version)
@staticmethod @staticmethod
def rubyPath(pkg: str, version: str, otherName: str = '') -> str: def configPath(pkg: str, version: str, fileName: str) -> str:
''' Returns `@/cellar/<pkg>/<version>/.brew/{<pkg>.rb|<otherName>}` ''' ''' Returns `@/cellar/<pkg>/<version>/.brew/<fileName>` '''
pkgRoot = Cellar.installPath(pkg, version) pkgRoot = Cellar.installPath(pkg, version)
return os.path.join(pkgRoot, '.brew', otherName or (pkg + '.rb')) return os.path.join(pkgRoot, '.brew', fileName)
@staticmethod
def rubyPath(pkg: str, version: str) -> str:
''' Returns `@/cellar/<pkg>/<version>/.brew/<pkg>.rb` '''
return Cellar.configPath(pkg, version, pkg + '.rb')
# Version handling # Version handling
@@ -1473,9 +1478,12 @@ class InstallQueue:
skipLink: bool, linkExe: bool, isPrimary: bool, skipLink: bool, linkExe: bool, isPrimary: bool,
) -> None: ) -> None:
# copy digest of tar file into install dir # copy digest of tar file into install dir
with open(Cellar.rubyPath(pkg, version, 'digest'), 'w') as fp: with open(Cellar.configPath(pkg, version, 'digest'), 'w') as fp:
fp.write(digest) fp.write(digest)
File.touch(Cellar.configPath(
pkg, version, 'primary' if isPrimary else 'secondary'))
# relink dylibs # relink dylibs
Fixer.run(pkg, version) Fixer.run(pkg, version)
@@ -1941,6 +1949,12 @@ class File:
rv.update(data) rv.update(data)
return rv.hexdigest() return rv.hexdigest()
@staticmethod
def touch(fname: str) -> None:
''' Update access time of file (or create new file) '''
with open(fname, 'a'):
os.utime(fname, None)
@staticmethod @staticmethod
def folderSize(path: str) -> tuple[int, int]: def folderSize(path: str) -> tuple[int, int]:
'''Calculate total size of folder and all it's content (recursively)''' '''Calculate total size of folder and all it's content (recursively)'''