Skip to content

Commit c74b34a

Browse files
Merge pull request #216 from mxkrsv/apk-support
Add APK (Alpine Package Keeper) support
2 parents e3cdf9d + b2e0034 commit c74b34a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, Debian,
6060

6161
##### Package managers
6262
```
63-
Pacman, dpkg, rpm, emerge, xbps, nix, Flatpak, Snap
63+
Pacman, dpkg, rpm, emerge, xbps, nix, Flatpak, Snap, apk
6464
```
6565

6666
##### WM themes

src/fastfetch.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static inline void printCommandHelp(const char* command)
107107
}
108108
else if(strcasecmp(command, "packages-format") == 0)
109109
{
110-
constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (xbps), {8} (nix-user), {9} (nix-default), {10} (flatpak), {11} (snap)", 11,
110+
constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (xbps), {8} (nix-user), {9} (nix-default), {10} (flatpak), {11} (snap), {12} (apk)", 12,
111111
"Number of all packages",
112112
"Number of pacman packages",
113113
"Pacman branch on manjaro",
@@ -119,7 +119,8 @@ static inline void printCommandHelp(const char* command)
119119
"Number of nix-user packages",
120120
"Number of nix-default packages",
121121
"Number of flatpak packages",
122-
"Number of snap packages"
122+
"Number of snap packages",
123+
"Number of apk packages"
123124
);
124125
}
125126
else if(strcasecmp(command, "shell-format") == 0)

src/modules/packages.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ typedef struct PackageCounts
2525
uint32_t nixDefault;
2626
uint32_t flatpak;
2727
uint32_t snap;
28+
uint32_t apk;
2829

2930
FFstrbuf pacmanBranch;
3031
} PackageCounts;
@@ -270,6 +271,11 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, Pack
270271
packageCounts->snap += (snap - 1); //Accounting for the /snap/bin folder
271272
ffStrbufSubstrBefore(baseDir, baseDirLength);
272273

274+
//apk
275+
ffStrbufAppendS(baseDir, "/lib/apk/db/installed");
276+
packageCounts->apk += getNumStrings(baseDir->chars, "C:Q");
277+
ffStrbufSubstrBefore(baseDir, baseDirLength);
278+
273279
//pacman branch
274280
ffStrbufAppendS(baseDir, "/etc/pacman-mirrors.conf");
275281
if(ffParsePropFile(baseDir->chars, "Branch =", &packageCounts->pacmanBranch) && packageCounts->pacmanBranch.length == 0)
@@ -337,7 +343,7 @@ void ffPrintPackages(FFinstance* instance)
337343

338344
ffStrbufDestroy(&baseDir);
339345

340-
uint32_t all = counts.pacman + counts.dpkg + counts.rpm + counts.emerge + counts.xbps + counts.nixSystem + nixUser + counts.nixDefault + counts.flatpak + counts.snap;
346+
uint32_t all = counts.pacman + counts.dpkg + counts.rpm + counts.emerge + counts.xbps + counts.nixSystem + nixUser + counts.nixDefault + counts.flatpak + counts.snap + counts.apk;
341347
if(all == 0)
342348
{
343349
ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packages, "No packages from known package managers found");
@@ -393,6 +399,7 @@ void ffPrintPackages(FFinstance* instance)
393399

394400
FF_PRINT_PACKAGE(flatpak)
395401
FF_PRINT_PACKAGE(snap)
402+
FF_PRINT_PACKAGE(apk)
396403

397404
//Fix linter warning of unused value of all
398405
(void) all;

0 commit comments

Comments
 (0)