diff options
| author | Gyorgy Sarvari <skandigraun@gmail.com> | 2025-08-30 18:51:20 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2025-10-06 15:27:14 +0000 |
| commit | 4aa4fcfa83a7866ce1868465b473239326f92c7c (patch) | |
| tree | 65623505a450881bc9fb0a499fad1e04d743aae7 /cmdline | |
| parent | a9d40153f823bb1f4e1103d760f5d117d679c35b (diff) | |
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 <skandigraun@gmail.com>
Diffstat (limited to 'cmdline')
| -rw-r--r-- | cmdline/apt-internal-solver.cc | 4 |
1 files changed, 3 insertions, 1 deletions
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 <list> #include <sstream> #include <string> +#include <libgen.h> #include <unistd.h> #include <apti18n.h> @@ -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"); |
