-
-
Notifications
You must be signed in to change notification settings - Fork 660
Packages(Linux): Auto detect the DBPath directory for pacman on archlinux #2154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
…inux Replace the original hardcoded pacman database path. Now it will auto detect the DBPath directory configured by `/etc/pacman.conf`. If `DBPath` is not set, it will fall back to the default `/var/lib/pacman/local`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request implements automatic detection of the pacman database path from /etc/pacman.conf configuration file, replacing the hardcoded path. The change allows fastfetch to correctly detect package counts on Arch Linux systems where the DBPath has been customized from the default location.
Changes:
- Added
getPacmanPackages()function to parse the DBPath from/etc/pacman.conf - Modified package counting to use the new function instead of hardcoded path
| ffStrbufAppendS(&pacmanDir, "/etc/pacman.conf"); | ||
|
|
||
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)) | ||
| ffStrbufSetS(&pacmanDir, "/var/lib/pacman"); | ||
|
|
||
| ffStrbufSubstrBefore(&pacmanDir, baseDirLen); |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first parameter to ffParsePropFile should be the full path to the config file, not just baseDir->chars. The function should first build the complete path to /etc/pacman.conf by appending it to baseDir, parse the config file from that path, and then restore baseDir to its original length. The correct pattern is: save baseDir->length, append /etc/pacman.conf to baseDir, call ffParsePropFile(baseDir->chars, ...), then restore using ffStrbufSubstrBefore(baseDir, baseDirLen).
| ffStrbufAppendS(&pacmanDir, "/etc/pacman.conf"); | |
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)) | |
| ffStrbufSetS(&pacmanDir, "/var/lib/pacman"); | |
| ffStrbufSubstrBefore(&pacmanDir, baseDirLen); | |
| ffStrbufAppendS(baseDir, "/etc/pacman.conf"); | |
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)) | |
| ffStrbufSetS(&pacmanDir, "/var/lib/pacman"); | |
| ffStrbufSubstrBefore(baseDir, baseDirLen); |
| ffStrbufAppendS(&pacmanDir, "/etc/pacman.conf"); | ||
|
|
||
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)) | ||
| ffStrbufSetS(&pacmanDir, "/var/lib/pacman"); | ||
|
|
||
| ffStrbufSubstrBefore(&pacmanDir, baseDirLen); |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable pacmanDir is initially set to /etc/pacman.conf but is later used to store the database path value. This is confusing. Instead, baseDir should be used to build the config file path (which will be reset later), and a separate variable should hold the parsed DBPath value, or pacmanDir should start empty and only receive the parsed value.
| ffStrbufAppendS(&pacmanDir, "/etc/pacman.conf"); | |
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)) | |
| ffStrbufSetS(&pacmanDir, "/var/lib/pacman"); | |
| ffStrbufSubstrBefore(&pacmanDir, baseDirLen); | |
| ffStrbufAppendS(baseDir, "/etc/pacman.conf"); | |
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)) | |
| ffStrbufSetS(&pacmanDir, "/var/lib/pacman"); | |
| ffStrbufSubstrBefore(baseDir, baseDirLen); |
|
What about |
|
Hi! First, I've checked up arch wiki and found that wiki states for
Thus, I suppose if And for the cases when Meanwhile, for bedrock, I think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
| ffStrbufAppendS(baseDir, "/etc/pacman.conf"); | ||
|
|
||
| // Get DBPath for packages | ||
| // If DBpath is specified |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment has a typo: "DBpath" should be "DBPath" to match the actual configuration option name used in pacman.conf and elsewhere in the code (see line 425 where "DBPath =" is used).
| // If DBpath is specified | |
| // If DBPath is specified |
| // If DBpath is specified | ||
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)){ | ||
| // If DBpath is not specified and RootDir is specified |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment has a typo: "DBpath" should be "DBPath" to match the actual configuration option name used in pacman.conf and elsewhere in the code (see line 425 where "DBPath =" is used).
| // If DBpath is specified | |
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)){ | |
| // If DBpath is not specified and RootDir is specified | |
| // If DBPath is specified | |
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)){ | |
| // If DBPath is not specified and RootDir is specified |
| // If DBpath is specified | ||
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)){ | ||
| // If DBpath is not specified and RootDir is specified |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment has a typo: "DBpath" should be "DBPath" to match the actual configuration option name used in pacman.conf and elsewhere in the code (see line 425 where "DBPath =" is used).
| // If DBpath is specified | |
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)){ | |
| // If DBpath is not specified and RootDir is specified | |
| // If DBPath is specified | |
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)){ | |
| // If DBPath is not specified and RootDir is specified |
| if (!ffParsePropFile(baseDir->chars, "DBPath =", &pacmanDir)){ | ||
| // If DBpath is not specified and RootDir is specified | ||
| if (!ffParsePropFile(baseDir->chars, "RootDir =", &pacmanDir)) | ||
| // If both are not specified | ||
| ffStrbufClear(&pacmanDir); | ||
|
|
||
| ffStrbufTrimRight(&pacmanDir, '/'); | ||
| ffStrbufAppendS(&pacmanDir, "/var/lib/pacman"); | ||
| } |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for handling the pacman.conf parsing is incorrect. The function ffParsePropFile returns true if the file exists (regardless of whether the property was found), and false only if the file doesn't exist.
The current implementation has the following issues:
- When the file doesn't exist, line 425 enters the if block, then line 427 tries to parse the same non-existent file again for "RootDir", which will always fail.
- When the file exists but DBPath is not specified, line 425 won't enter the if block, skipping the RootDir fallback logic entirely.
The correct logic should be:
- First check if the file exists
- If it exists, try to parse DBPath
- If DBPath is not found (buffer is empty), try RootDir and append "/var/lib/pacman"
- If RootDir is also not found (buffer is empty), use the default "/var/lib/pacman"
- If the file doesn't exist, use the default "/var/lib/pacman"
|
Needs testing on Bedrock |
|
I'm setting up a VM to test this out and will share you the results later. Any help from Bedrock Linux users are welcome. |
|
What if you set |
|
Can you help to test #2155? |
|
ok, working on it |


Summary
Replace the original hardcoded pacman database path. Now it will auto detect the DBPath directory configured by
/etc/pacman.conf. IfDBPathis not set, it will fall back to the default/var/lib/pacman/local.Related issue
Closes #2068
Changes
src/detection/packages/packages_linux.c. Added a static functiongetPacmanPackagesChecklist