Skip to content
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

add soar packages count #1531

Merged
merged 3 commits into from
Apr 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ if(NOT BINARY_LINK_TYPE IN_LIST BINARY_LINK_TYPE_OPTIONS)
message(FATAL_ERROR "BINARY_LINK_TYPE must be one of ${BINARY_LINK_TYPE_OPTIONS}")
endif()

set(PACKAGE_MANAGERS AM APK BREW CHOCO DPKG EMERGE EOPKG FLATPAK GUIX LINGLONG LPKG LPKGBUILD MACPORTS NIX OPKG PACMAN PACSTALL PALUDIS PISI PKG PKGTOOL RPM SCOOP SNAP SORCERY WINGET XBPS)
set(PACKAGE_MANAGERS AM APK BREW CHOCO DPKG EMERGE EOPKG FLATPAK GUIX LINGLONG LPKG LPKGBUILD MACPORTS NIX OPKG PACMAN PACSTALL PALUDIS PISI PKG PKGTOOL RPM SCOOP SNAP SOAR SORCERY WINGET XBPS)
foreach(package_manager ${PACKAGE_MANAGERS})
if(package_manager STREQUAL "WINGET")
option(PACKAGES_DISABLE_${package_manager} "Disable ${package_manager} package manager detection by default" ON)
Expand Down
2 changes: 1 addition & 1 deletion doc/json_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
"type": "string"
},
"packagesFormat": {
"description": "Output format of the module `Packages`. See Wiki for formatting syntax\n 1. {all}: Number of all packages\n 2. {pacman}: Number of pacman packages\n 3. {pacman-branch}: Pacman branch on manjaro\n 4. {dpkg}: Number of dpkg packages\n 5. {rpm}: Number of rpm packages\n 6. {emerge}: Number of emerge packages\n 7. {eopkg}: Number of eopkg packages\n 8. {xbps}: Number of xbps packages\n 9. {nix-system}: Number of nix-system packages\n 10. {nix-user}: Number of nix-user packages\n 11. {nix-default}: Number of nix-default packages\n 12. {apk}: Number of apk packages\n 13. {pkg}: Number of pkg packages\n 14. {flatpak-system}: Number of flatpak-system app packages\n 15. {flatpak-user}: Number of flatpak-user app packages\n 16. {snap}: Number of snap packages\n 17. {brew}: Number of brew packages\n 18. {brew-cask}: Number of brew-cask packages\n 19. {macports}: Number of macports packages\n 20. {scoop}: Number of scoop packages\n 21. {choco}: Number of choco packages\n 22. {pkgtool}: Number of pkgtool packages\n 23. {paludis}: Number of paludis packages\n 24. {winget}: Number of winget packages\n 25. {opkg}: Number of opkg packages\n 26. {am-system}: Number of am-system packages\n 27. {sorcery}: Number of sorcery packages\n 28. {lpkg}: Number of lpkg packages\n 29. {lpkgbuild}: Number of lpkgbuild packages\n 30. {guix-system}: Number of guix-system packages\n 31. {guix-user}: Number of guix-user packages\n 32. {guix-home}: Number of guix-home packages\n 33. {linglong}: Number of linglong packages\n 34. {pacstall}: Number of pacstall packages\n 35. {mport}: Number of mport packages\n 36. {qi}: Number of qi packages\n 37. {am-user}: Number of am-user (aka appman) packages\n 38. {pkgsrc}: Number of pkgsrc packages\n 39. {hpkg-system}: Number of hpkg-system packages\n 40. {hpkg-user}: Number of hpkg-user packages\n 41. {pisi}: Number of pisi packages\n 42. {nix-all}: Total number of all nix packages\n 43. {flatpak-all}: Total number of all flatpak app packages\n 44. {brew-all}: Total number of all brew packages\n 45. {guix-all}: Total number of all guix packages\n 46. {hpkg-all}: Total number of all hpkg packages",
"description": "Output format of the module `Packages`. See Wiki for formatting syntax\n 1. {all}: Number of all packages\n 2. {pacman}: Number of pacman packages\n 3. {pacman-branch}: Pacman branch on manjaro\n 4. {dpkg}: Number of dpkg packages\n 5. {rpm}: Number of rpm packages\n 6. {emerge}: Number of emerge packages\n 7. {eopkg}: Number of eopkg packages\n 8. {xbps}: Number of xbps packages\n 9. {nix-system}: Number of nix-system packages\n 10. {nix-user}: Number of nix-user packages\n 11. {nix-default}: Number of nix-default packages\n 12. {apk}: Number of apk packages\n 13. {pkg}: Number of pkg packages\n 14. {flatpak-system}: Number of flatpak-system app packages\n 15. {flatpak-user}: Number of flatpak-user app packages\n 16. {snap}: Number of snap packages\n 17. {brew}: Number of brew packages\n 18. {brew-cask}: Number of brew-cask packages\n 19. {macports}: Number of macports packages\n 20. {scoop}: Number of scoop packages\n 21. {choco}: Number of choco packages\n 22. {pkgtool}: Number of pkgtool packages\n 23. {paludis}: Number of paludis packages\n 24. {winget}: Number of winget packages\n 25. {opkg}: Number of opkg packages\n 26. {am-system}: Number of am-system packages\n 27. {sorcery}: Number of sorcery packages\n 28. {lpkg}: Number of lpkg packages\n 29. {lpkgbuild}: Number of lpkgbuild packages\n 30. {guix-system}: Number of guix-system packages\n 31. {guix-user}: Number of guix-user packages\n 32. {guix-home}: Number of guix-home packages\n 33. {linglong}: Number of linglong packages\n 34. {pacstall}: Number of pacstall packages\n 35. {mport}: Number of mport packages\n 36. {qi}: Number of qi packages\n 37. {am-user}: Number of am-user (aka appman) packages\n 38. {pkgsrc}: Number of pkgsrc packages\n 39. {hpkg-system}: Number of hpkg-system packages\n 40. {hpkg-user}: Number of hpkg-user packages\n 41. {pisi}: Number of pisi packages\n 42. {soar}: Number of soar packages\n 43. {nix-all}: Total number of all nix packages\n 44. {flatpak-all}: Total number of all flatpak app packages\n 45. {brew-all}: Total number of all brew packages\n 46. {guix-all}: Total number of all guix packages\n 47. {hpkg-all}: Total number of all hpkg packages",
"type": "string"
},
"physicaldiskFormat": {
Expand Down
1 change: 1 addition & 0 deletions src/detection/packages/packages.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typedef struct FFPackagesResult
uint32_t rpm;
uint32_t scoop;
uint32_t snap;
uint32_t soar;
uint32_t sorcery;
uint32_t winget;
uint32_t xbps;
Expand Down
3 changes: 3 additions & 0 deletions src/detection/packages/packages_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,4 +682,7 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options)

if (!(options->disabled & FF_PACKAGES_FLAG_AM_BIT))
result->amUser = getAMUser();

if (!(options->disabled & FF_PACKAGES_FLAG_SOAR_BIT))
result->soar += getSQLite3Int(&baseDir, ".local/share/soar/db/soar.db", "SELECT COUNT(DISTINCT pkg_id || pkg_name) FROM packages WHERE is_installed = true", "soar");
}
67 changes: 34 additions & 33 deletions src/modules/packages/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,41 @@
typedef enum __attribute__((__packed__)) FFPackagesFlags
{
FF_PACKAGES_FLAG_NONE = 0,
FF_PACKAGES_FLAG_APK_BIT = 1 << 0,
FF_PACKAGES_FLAG_BREW_BIT = 1 << 1,
FF_PACKAGES_FLAG_CHOCO_BIT = 1 << 2,
FF_PACKAGES_FLAG_DPKG_BIT = 1 << 3,
FF_PACKAGES_FLAG_EMERGE_BIT = 1 << 4,
FF_PACKAGES_FLAG_EOPKG_BIT = 1 << 5,
FF_PACKAGES_FLAG_FLATPAK_BIT = 1 << 6,
FF_PACKAGES_FLAG_NIX_BIT = 1 << 7,
FF_PACKAGES_FLAG_OPKG_BIT = 1 << 8,
FF_PACKAGES_FLAG_PACMAN_BIT = 1 << 9,
FF_PACKAGES_FLAG_PALUDIS_BIT = 1 << 10,
FF_PACKAGES_FLAG_PKG_BIT = 1 << 11,
FF_PACKAGES_FLAG_PKGTOOL_BIT = 1 << 12,
FF_PACKAGES_FLAG_MACPORTS_BIT = 1 << 13,
FF_PACKAGES_FLAG_RPM_BIT = 1 << 14,
FF_PACKAGES_FLAG_SCOOP_BIT = 1 << 15,
FF_PACKAGES_FLAG_SNAP_BIT = 1 << 16,
FF_PACKAGES_FLAG_WINGET_BIT = 1 << 17,
FF_PACKAGES_FLAG_XBPS_BIT = 1 << 18,
FF_PACKAGES_FLAG_AM_BIT = 1 << 19,
FF_PACKAGES_FLAG_SORCERY_BIT = 1 << 20,
FF_PACKAGES_FLAG_LPKG_BIT = 1 << 21,
FF_PACKAGES_FLAG_LPKGBUILD_BIT = 1 << 22,
FF_PACKAGES_FLAG_GUIX_BIT = 1 << 23,
FF_PACKAGES_FLAG_LINGLONG_BIT = 1 << 24,
FF_PACKAGES_FLAG_PACSTALL_BIT = 1 << 25,
FF_PACKAGES_FLAG_MPORT_BIT = 1 << 26,
FF_PACKAGES_FLAG_QI_BIT = 1 << 27,
FF_PACKAGES_FLAG_PKGSRC_BIT = 1 << 28,
FF_PACKAGES_FLAG_HPKG_BIT = 1 << 29,
FF_PACKAGES_FLAG_PISI_BIT = 1 << 30,
FF_PACKAGES_FLAG_FORCE_UNSIGNED = UINT32_MAX,
FF_PACKAGES_FLAG_APK_BIT = 1ULL << 0,
FF_PACKAGES_FLAG_BREW_BIT = 1ULL << 1,
FF_PACKAGES_FLAG_CHOCO_BIT = 1ULL << 2,
FF_PACKAGES_FLAG_DPKG_BIT = 1ULL << 3,
FF_PACKAGES_FLAG_EMERGE_BIT = 1ULL << 4,
FF_PACKAGES_FLAG_EOPKG_BIT = 1ULL << 5,
FF_PACKAGES_FLAG_FLATPAK_BIT = 1ULL << 6,
FF_PACKAGES_FLAG_NIX_BIT = 1ULL << 7,
FF_PACKAGES_FLAG_OPKG_BIT = 1ULL << 8,
FF_PACKAGES_FLAG_PACMAN_BIT = 1ULL << 9,
FF_PACKAGES_FLAG_PALUDIS_BIT = 1ULL << 10,
FF_PACKAGES_FLAG_PKG_BIT = 1ULL << 11,
FF_PACKAGES_FLAG_PKGTOOL_BIT = 1ULL << 12,
FF_PACKAGES_FLAG_MACPORTS_BIT = 1ULL << 13,
FF_PACKAGES_FLAG_RPM_BIT = 1ULL << 14,
FF_PACKAGES_FLAG_SCOOP_BIT = 1ULL << 15,
FF_PACKAGES_FLAG_SNAP_BIT = 1ULL << 16,
FF_PACKAGES_FLAG_WINGET_BIT = 1ULL << 17,
FF_PACKAGES_FLAG_XBPS_BIT = 1ULL << 18,
FF_PACKAGES_FLAG_AM_BIT = 1ULL << 19,
FF_PACKAGES_FLAG_SORCERY_BIT = 1ULL << 20,
FF_PACKAGES_FLAG_LPKG_BIT = 1ULL << 21,
FF_PACKAGES_FLAG_LPKGBUILD_BIT = 1ULL << 22,
FF_PACKAGES_FLAG_GUIX_BIT = 1ULL << 23,
FF_PACKAGES_FLAG_LINGLONG_BIT = 1ULL << 24,
FF_PACKAGES_FLAG_PACSTALL_BIT = 1ULL << 25,
FF_PACKAGES_FLAG_MPORT_BIT = 1ULL << 26,
FF_PACKAGES_FLAG_QI_BIT = 1ULL << 27,
FF_PACKAGES_FLAG_PKGSRC_BIT = 1ULL << 28,
FF_PACKAGES_FLAG_HPKG_BIT = 1ULL << 29,
FF_PACKAGES_FLAG_PISI_BIT = 1ULL << 30,
FF_PACKAGES_FLAG_SOAR_BIT = 1ULL << 31,
FF_PACKAGES_FLAG_FORCE_UNSIGNED = UINT64_MAX,
} FFPackagesFlags;
static_assert(sizeof(FFPackagesFlags) == sizeof(uint32_t), "");
static_assert(sizeof(FFPackagesFlags) == sizeof(uint64_t), "");

typedef struct FFPackagesOptions
{
Expand Down
7 changes: 7 additions & 0 deletions src/modules/packages/packages.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void ffPrintPackages(FFPackagesOptions* options)
FF_PRINT_PACKAGE(mport)
FF_PRINT_PACKAGE(qi)
FF_PRINT_PACKAGE(pisi)
FF_PRINT_PACKAGE(soar)

putchar('\n');
}
Expand Down Expand Up @@ -130,6 +131,7 @@ void ffPrintPackages(FFPackagesOptions* options)
FF_FORMAT_ARG(counts.hpkgSystem, "hpkg-system"),
FF_FORMAT_ARG(counts.hpkgUser, "hpkg-user"),
FF_FORMAT_ARG(counts.pisi, "pisi"),
FF_FORMAT_ARG(counts.soar, "soar"),
FF_FORMAT_ARG(nixAll, "nix-all"),
FF_FORMAT_ARG(flatpakAll, "flatpak-all"),
FF_FORMAT_ARG(brewAll, "brew-all"),
Expand Down Expand Up @@ -222,6 +224,7 @@ bool ffParsePackagesCommandOptions(FFPackagesOptions* options, const char* key,
case 'S': if (false);
FF_TEST_PACKAGE_NAME(SCOOP)
FF_TEST_PACKAGE_NAME(SNAP)
FF_TEST_PACKAGE_NAME(SOAR)
FF_TEST_PACKAGE_NAME(SORCERY)
break;
case 'W': if (false);
Expand Down Expand Up @@ -341,6 +344,7 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module)
case 'S': if (false);
FF_TEST_PACKAGE_NAME(SCOOP)
FF_TEST_PACKAGE_NAME(SNAP)
FF_TEST_PACKAGE_NAME(SOAR)
FF_TEST_PACKAGE_NAME(SORCERY)
break;
case 'W': if (false);
Expand Down Expand Up @@ -400,6 +404,7 @@ void ffGeneratePackagesJsonConfig(FFPackagesOptions* options, yyjson_mut_doc* do
FF_TEST_PACKAGE_NAME(RPM)
FF_TEST_PACKAGE_NAME(SCOOP)
FF_TEST_PACKAGE_NAME(SNAP)
FF_TEST_PACKAGE_NAME(SOAR)
FF_TEST_PACKAGE_NAME(SORCERY)
FF_TEST_PACKAGE_NAME(WINGET)
FF_TEST_PACKAGE_NAME(XBPS)
Expand Down Expand Up @@ -459,6 +464,7 @@ void ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yy
FF_APPEND_PACKAGE_COUNT(rpm)
FF_APPEND_PACKAGE_COUNT(scoop)
FF_APPEND_PACKAGE_COUNT(snap)
FF_APPEND_PACKAGE_COUNT(soar)
FF_APPEND_PACKAGE_COUNT(sorcery)
FF_APPEND_PACKAGE_COUNT(winget)
FF_APPEND_PACKAGE_COUNT(xbps)
Expand Down Expand Up @@ -515,6 +521,7 @@ static FFModuleBaseInfo ffModuleInfo = {
{"Number of hpkg-system packages", "hpkg-system"},
{"Number of hpkg-user packages", "hpkg-user"},
{"Number of pisi packages", "pisi"},
{"Number of soar packages", "soar"},
{"Total number of all nix packages", "nix-all"},
{"Total number of all flatpak app packages", "flatpak-all"},
{"Total number of all brew packages", "brew-all"},
Expand Down
Loading