From 4aa4fcfa83a7866ce1868465b473239326f92c7c Mon Sep 17 00:00:00 2001 From: Gyorgy Sarvari Date: Sat, 30 Aug 2025 18:51:20 +0200 Subject: fix compiling with musl In case apt is compiled against musl-libc, then compilation fails with the following error: cmdline/apt-internal-solver.cc:122:20: error: 'basename' was not declared in this scope; did you mean 'rename'? | 122 | if (strcmp(basename(argv[0]), "solver3") == 0) | | ^~~~~~~~ | | rename To fix it, include libgen header where musl can find this function also. Once this is fixed, compilation fails once again with musl-libc, because the basename function takes *char argument instead of const *char: this is because the musl implementation cuts off the trailing slashes of the path, in case the argument is a folder path. To account for this, instead of passing argv[0] directly, create a non-const string copy of it, and pass that to base. Signed-off-by: Gyorgy Sarvari --- cmdline/apt-internal-solver.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index ceedd96c7..517b50747 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -119,7 +120,8 @@ int main(int argc,const char *argv[]) /*{{{*/ _config->Set("Debug::EDSP::WriteSolution", true); _config->Set("APT::System", "Debian APT solver interface"); - if (strcmp(basename(argv[0]), "solver3") == 0) + std::string self = argv[0]; + if (strcmp(basename(self.data()), "solver3") == 0) _config->Set("APT::Solver", "3.0"); else if (_config->Find("APT::Solver") != "3.0") _config->Set("APT::Solver", "internal"); -- cgit v1.2.3-70-g09d2