mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Packages (Linux): Auto detect the DBPath directory for pacman on archlinux (#2154)
Fixes #2068
This commit is contained in:
@@ -412,6 +412,33 @@ static uint32_t getFlatpakPackages(FFstrbuf* baseDir, const char* dirname)
|
||||
return num_elements;
|
||||
}
|
||||
|
||||
static uint32_t getPacmanPackages(FFstrbuf* baseDir)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY pacmanDir = ffStrbufCreate();
|
||||
// Get path to pacman.conf
|
||||
uint32_t baseDirLen = baseDir->length;
|
||||
ffStrbufAppendS(baseDir, "/etc/pacman.conf");
|
||||
|
||||
// Get DBPath for packages
|
||||
ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir);
|
||||
// If DBPath is specified
|
||||
if (pacmanDir.length == 0) {
|
||||
ffParsePropFile(baseDir->chars, "RootDir =", &pacmanDir);
|
||||
// If DBpath is not specified and RootDir is specified
|
||||
if (pacmanDir.length ==0)
|
||||
// If both are not specified
|
||||
ffStrbufClear(&pacmanDir);
|
||||
ffStrbufTrimRight(&pacmanDir, '/');
|
||||
ffStrbufAppendS(&pacmanDir, "/var/lib/pacman");
|
||||
}
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLen);
|
||||
|
||||
ffStrbufTrimRight(&pacmanDir, '/');
|
||||
ffStrbufAppendS(&pacmanDir, "/local");
|
||||
|
||||
return getNumElements(baseDir, pacmanDir.chars, true);
|
||||
}
|
||||
|
||||
static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts, FFPackagesOptions* options)
|
||||
{
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_APK_BIT)) packageCounts->apk += getNumStrings(baseDir, "/lib/apk/db/installed", "C:Q", "apk");
|
||||
@@ -426,7 +453,7 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts,
|
||||
packageCounts->nixDefault += ffPackagesGetNix(baseDir, "/nix/var/nix/profiles/default");
|
||||
packageCounts->nixSystem += ffPackagesGetNix(baseDir, "/run/current-system");
|
||||
}
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_PACMAN_BIT)) packageCounts->pacman += getNumElements(baseDir, "/var/lib/pacman/local", true);
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_PACMAN_BIT)) packageCounts->pacman += getPacmanPackages(baseDir);
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_LPKGBUILD_BIT)) packageCounts->lpkgbuild += getNumElements(baseDir, "/opt/Loc-OS-LPKG/lpkgbuild/remove", false);
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_PKGTOOL_BIT)) packageCounts->pkgtool += getNumElements(baseDir, "/var/log/packages", false);
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_RPM_BIT))
|
||||
|
||||
Reference in New Issue
Block a user