summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-11-29 13:12:38 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2015-11-29 13:12:38 +0100
commit90986d4dbbd38e2e89f986d621e301304210452e (patch)
treecb7959bfc62be9765e55d2591f71a532f832a896
parent875a9e54ba956dace823866bca7935f6ab8e8d06 (diff)
use function pointers instead of weak symbols for cmdline parsing
Passing function pointers around while working on this was very icky, but if weak symbols are too much to ask for… Reverts "do not use "-Wl,-Bsymbolic-functions" during the build to avoid breakage" aka a5fc9be36211a290a7abc3ca2a8bf98943bc1f57.
-rw-r--r--apt-private/private-cmndline.cc16
-rw-r--r--apt-private/private-cmndline.h3
-rw-r--r--cmdline/apt-cache.cc2
-rw-r--r--cmdline/apt-cdrom.cc2
-rw-r--r--cmdline/apt-config.cc2
-rw-r--r--cmdline/apt-extracttemplates.cc2
-rw-r--r--cmdline/apt-get.cc2
-rw-r--r--cmdline/apt-helper.cc2
-rw-r--r--cmdline/apt-internal-solver.cc2
-rw-r--r--cmdline/apt-mark.cc2
-rw-r--r--cmdline/apt-sortpkgs.cc2
-rw-r--r--cmdline/apt.cc2
-rwxr-xr-xdebian/rules5
-rw-r--r--ftparchive/apt-ftparchive.cc2
14 files changed, 21 insertions, 25 deletions
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index 9c5eae470..6cffbcb48 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -378,7 +378,8 @@ static void ShowHelpListCommands(std::vector<aptDispatchWithHelp> const &Cmds)/*
}
}
/*}}}*/
-static bool ShowCommonHelp(APT_CMD const Binary, CommandLine &CmdL, std::vector<aptDispatchWithHelp> const &Cmds)/*{{{*/
+static bool ShowCommonHelp(APT_CMD const Binary, CommandLine &CmdL, std::vector<aptDispatchWithHelp> const &Cmds,/*{{{*/
+ bool (*ShowHelp)(CommandLine &))
{
std::cout << PACKAGE << " " << PACKAGE_VERSION << " (" << COMMON_ARCH << ")" << std::endl;
if (_config->FindB("version") == true && Binary != APT_CMD::APT_GET)
@@ -442,7 +443,8 @@ static void BinarySpecificConfiguration(char const * const Binary) /*{{{*/
}
/*}}}*/
std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD const Binary,/*{{{*/
- Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char *argv[])
+ Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char *argv[],
+ bool (*ShowHelp)(CommandLine &), std::vector<aptDispatchWithHelp> (*GetCommands)(void))
{
if (Cnf != NULL && pkgInitConfig(**Cnf) == false)
{
@@ -477,7 +479,7 @@ std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD c
(Sys != NULL && pkgInitSystem(*_config, *Sys) == false))
{
if (_config->FindB("version") == true)
- ShowCommonHelp(Binary, CmdL, CmdsWithHelp);
+ ShowCommonHelp(Binary, CmdL, CmdsWithHelp, ShowHelp);
_error->DumpErrors();
exit(100);
@@ -487,12 +489,12 @@ std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD c
if (_config->FindB("help") == true || _config->FindB("version") == true ||
(CmdL.FileSize() > 0 && strcmp(CmdL.FileList[0], "help") == 0))
{
- ShowCommonHelp(Binary, CmdL, CmdsWithHelp);
+ ShowCommonHelp(Binary, CmdL, CmdsWithHelp, ShowHelp);
exit(0);
}
if (Cmds.empty() == false && CmdL.FileSize() == 0)
{
- ShowCommonHelp(Binary, CmdL, CmdsWithHelp);
+ ShowCommonHelp(Binary, CmdL, CmdsWithHelp, ShowHelp);
exit(1);
}
return Cmds;
@@ -514,7 +516,3 @@ unsigned short DispatchCommandLine(CommandLine &CmdL, std::vector<CommandLine::D
return Errors == true ? 100 : 0;
}
/*}}}*/
-
-// weak symbols
-bool ShowHelp(CommandLine &) { return false; }
-std::vector<aptDispatchWithHelp> GetCommands() { return {}; }
diff --git a/apt-private/private-cmndline.h b/apt-private/private-cmndline.h
index 4819adce1..05690964d 100644
--- a/apt-private/private-cmndline.h
+++ b/apt-private/private-cmndline.h
@@ -33,7 +33,8 @@ struct aptDispatchWithHelp
APT_PUBLIC std::vector<aptDispatchWithHelp> GetCommands() APT_WEAK;
APT_PUBLIC std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD const Binary,
- Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char * argv[]);
+ Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char * argv[],
+ bool (*ShowHelp)(CommandLine &), std::vector<aptDispatchWithHelp> (*GetCommands)(void));
APT_PUBLIC unsigned short DispatchCommandLine(CommandLine &CmdL, std::vector<CommandLine::Dispatch> const &Cmds);
APT_PUBLIC std::vector<CommandLine::Args> getCommandArgs(APT_CMD const Program, char const * const Cmd);
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index b70e1db38..4a592da8f 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -1247,7 +1247,7 @@ int main(int argc,const char *argv[]) /*{{{*/
// Parse the command line and initialize the package library
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CACHE, &_config, &_system, argc, argv);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CACHE, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
InitOutput();
diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc
index 4a24f198c..d8a2d84cf 100644
--- a/cmdline/apt-cdrom.cc
+++ b/cmdline/apt-cdrom.cc
@@ -229,7 +229,7 @@ int main(int argc,const char *argv[]) /*{{{*/
// Parse the command line and initialize the package library
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CDROM, &_config, &_system, argc, argv);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CDROM, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
InitOutput();
diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc
index c364b8cdf..b86a0fd97 100644
--- a/cmdline/apt-config.cc
+++ b/cmdline/apt-config.cc
@@ -101,7 +101,7 @@ int main(int argc,const char *argv[]) /*{{{*/
// Parse the command line and initialize the package library
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CONFIG, &_config, &_system, argc, argv);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CONFIG, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
std::vector<std::string> const langs = APT::Configuration::getLanguages(true);
_config->Clear("Acquire::Languages");
diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc
index 0e60ff5fb..d1345400b 100644
--- a/cmdline/apt-extracttemplates.cc
+++ b/cmdline/apt-extracttemplates.cc
@@ -342,7 +342,7 @@ int main(int argc, const char **argv) /*{{{*/
InitLocale();
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_EXTRACTTEMPLATES, &_config, &_system, argc, argv);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_EXTRACTTEMPLATES, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
Go(CmdL);
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 5002ec1b8..b8d72a0bc 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -434,7 +434,7 @@ int main(int argc,const char *argv[]) /*{{{*/
// Parse the command line and initialize the package library
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_GET, &_config, &_system, argc, argv);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_GET, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
InitSignals();
InitOutput();
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc
index 176a67e03..1be122ad0 100644
--- a/cmdline/apt-helper.cc
+++ b/cmdline/apt-helper.cc
@@ -131,7 +131,7 @@ int main(int argc,const char *argv[]) /*{{{*/
InitLocale();
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_HELPER, &_config, &_system, argc, argv);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_HELPER, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
InitOutput();
diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc
index ae90c1655..90800e1d9 100644
--- a/cmdline/apt-internal-solver.cc
+++ b/cmdline/apt-internal-solver.cc
@@ -71,7 +71,7 @@ int main(int argc,const char *argv[]) /*{{{*/
DropPrivileges();
CommandLine CmdL;
- ParseCommandLine(CmdL, APT_CMD::APT_INTERNAL_SOLVER, &_config, NULL, argc, argv);
+ ParseCommandLine(CmdL, APT_CMD::APT_INTERNAL_SOLVER, &_config, NULL, argc, argv, &ShowHelp, &GetCommands);
if (CmdL.FileList[0] != 0 && strcmp(CmdL.FileList[0], "scenario") == 0)
{
diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc
index 132bd7ef6..2491a8ebf 100644
--- a/cmdline/apt-mark.cc
+++ b/cmdline/apt-mark.cc
@@ -322,7 +322,7 @@ int main(int argc,const char *argv[]) /*{{{*/
InitLocale();
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_MARK, &_config, &_system, argc, argv);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_MARK, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
InitOutput();
diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc
index a4707a974..7e3301a05 100644
--- a/cmdline/apt-sortpkgs.cc
+++ b/cmdline/apt-sortpkgs.cc
@@ -155,7 +155,7 @@ int main(int argc,const char *argv[]) /*{{{*/
InitLocale();
CommandLine CmdL;
- ParseCommandLine(CmdL, APT_CMD::APT_SORTPKG, &_config, &_system, argc, argv);
+ ParseCommandLine(CmdL, APT_CMD::APT_SORTPKG, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
// Match the operation
for (unsigned int I = 0; I != CmdL.FileSize(); I++)
diff --git a/cmdline/apt.cc b/cmdline/apt.cc
index 761ad60db..64d374e1f 100644
--- a/cmdline/apt.cc
+++ b/cmdline/apt.cc
@@ -100,7 +100,7 @@ int main(int argc, const char *argv[]) /*{{{*/
InitLocale();
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT, &_config, &_system, argc, argv);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
int const quiet = _config->FindI("quiet", 0);
if (quiet == 2)
diff --git a/debian/rules b/debian/rules
index 9a7c72080..c8e7cb285 100755
--- a/debian/rules
+++ b/debian/rules
@@ -29,10 +29,7 @@ ifneq (,$(shell which dpkg-buildflags))
# (http://savannah.gnu.org/bugs/?10593)
dpkg_buildflags = DEB_BUILD_MAINT_OPTIONS=hardening=+all dpkg-buildflags
export CXXFLAGS = $(shell $(dpkg_buildflags) --get CXXFLAGS)
- # we can not use "-Wl,-Bsymbolic-functions" with the new weak symbols
- # in libapt-private (commit 28f24d3d added those)
- comma:= ,
- export LDFLAGS = $(subst -Wl$(comma)-Bsymbolic-functions,,$(shell $(dpkg_buildflags) --get LDFLAGS))
+ export LDFLAGS = $(shell $(dpkg_buildflags) --get LDFLAGS)
export CPPFLAGS = $(shell $(dpkg_buildflags) --get CPPFLAGS)
else
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc
index bb3ade1e8..003a186be 100644
--- a/ftparchive/apt-ftparchive.cc
+++ b/ftparchive/apt-ftparchive.cc
@@ -1048,7 +1048,7 @@ int main(int argc, const char *argv[]) /*{{{*/
// Parse the command line and initialize the package library
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_FTPARCHIVE, &_config, NULL, argc, argv);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_FTPARCHIVE, &_config, NULL, argc, argv, ShowHelp, &GetCommands);
_config->CndSet("quiet",0);
Quiet = _config->FindI("quiet",0);