Skip to content

Packages (pkgsrc): add dynamic prefix discovery#2440

Open
Suyun114 wants to merge 2 commits into
fastfetch-cli:devfrom
Suyun114:pkgin
Open

Packages (pkgsrc): add dynamic prefix discovery#2440
Suyun114 wants to merge 2 commits into
fastfetch-cli:devfrom
Suyun114:pkgin

Conversation

@Suyun114

@Suyun114 Suyun114 commented Jul 5, 2026

Copy link
Copy Markdown

Summary

Previously pkgsrc detection hardcoded /usr/pkg/pkgdb, which missed installations at non-standard prefixes (e.g. /opt/pkg) and database directory layouts (e.g. .pkgdb).

Now ffPackagesGetPkgsrc finds the pkgin binary via PATH, derives the prefix, reads <prefix>/etc/mk.conf for PKG_DBDIR, and falls back to <prefix>/pkgdb. Analogous to ffPackagesGetNix, the function appends to baseDir for Bedrock Linux compatibility.

Support added for Linux, NetBSD, SunOS, and macOS.

Changes

  • New src/detection/packages/packages_pkgsrc.c — shared helper
  • packages_linux.c / packages_apple.c / packages_nbsd.c / packages_sunos.c — all four now call ffPackagesGetPkgsrc
  • packages.h — declaration guarded
  • CMakeLists.txt — includes the new file

Checklist

  • I have tested my changes locally.

@codacy-production

codacy-production Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@CarterLi

CarterLi commented Jul 6, 2026

Copy link
Copy Markdown
Member

Cleaned a bit.

I'm pretty sure that this PR will break bedrock. As this PR searches pkgin in $PATH, if pkgin is installed in one of bedrock strat, it will prepend the bedrock strat prefix twice. For example:

  • baseDir: /bedrock/strata/distro
  • pkgin path found in $PATH: /bedrock/strata/distro/usr/bin/pkgin
  • ffStrbufAppendF(baseDir, "%s/pkgdb", pkginPath.chars): /bedrock/strata/distro/bedrock/strata/distro/usr/pkgdb

In addition, how bedrock strat handles PKG_DBDIR is still unknown.

Unless this is properly tested in bedrock, I don't think I want to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants