apt/apt-0.5.15lorg2-alt-manifest.patch

129 lines
3.6 KiB
Diff
Raw Normal View History

2007-10-22 16:22:08 +04:00
diff -Naur apt-0.5.15lorg2.orig/apt-pkg/contrib/cmndline.cc apt-0.5.15lorg2/apt-pkg/contrib/cmndline.cc
--- apt-0.5.15lorg2.orig/apt-pkg/contrib/cmndline.cc 2007-10-30 14:42:33 +0300
+++ apt-0.5.15lorg2/apt-pkg/contrib/cmndline.cc 2007-10-30 14:43:33 +0300
@@ -19,9 +19,23 @@
#include <apt-pkg/strutl.h>
#include <apti18n.h>
+
+#include <memory>
2007-10-22 16:22:08 +04:00
/*}}}*/
using namespace std;
+void CommandLine::FreeFileList()
+{
+ if (FileList)
+ {
+ for (const char **I=FileList; *I; ++I)
+ free(const_cast<char *>(*I));
+
+ delete [] FileList;
+ FileList = 0;
+ }
+}
+
// CommandLine::CommandLine - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -35,7 +49,7 @@
2007-10-22 16:22:08 +04:00
/* */
CommandLine::~CommandLine()
{
- delete [] FileList;
+ FreeFileList();
}
/*}}}*/
// CommandLine::Parse - Main action member /*{{{*/
@@ -43,8 +57,11 @@
2007-10-22 16:22:08 +04:00
/* */
bool CommandLine::Parse(int argc,const char **argv)
{
- delete [] FileList;
+ FreeFileList();
FileList = new const char *[argc];
+ std::uninitialized_fill(const_cast<char**>(FileList),
+ const_cast<char**>(FileList+argc),
+ static_cast<char*>(0));
2007-10-22 16:22:08 +04:00
const char **Files = FileList;
int I;
for (I = 1; I != argc; I++)
@@ -54,7 +71,7 @@
2007-10-22 16:22:08 +04:00
// It is not an option
if (*Opt != '-')
{
- *Files++ = Opt;
+ *Files++ = strdup(Opt);
continue;
}
@@ -136,7 +153,7 @@
2007-10-22 16:22:08 +04:00
// Copy any remaining file names over
for (; I != argc; I++)
- *Files++ = argv[I];
+ *Files++ = strdup(argv[I]);
*Files = 0;
return true;
diff -Naur apt-0.5.15lorg2.orig/apt-pkg/contrib/cmndline.h apt-0.5.15lorg2/apt-pkg/contrib/cmndline.h
--- apt-0.5.15lorg2.orig/apt-pkg/contrib/cmndline.h 2007-10-24 19:20:13 +0400
+++ apt-0.5.15lorg2/apt-pkg/contrib/cmndline.h 2007-10-30 14:42:59 +0300
2007-10-22 16:22:08 +04:00
@@ -52,6 +52,10 @@
class CommandLine
{
+ CommandLine(const CommandLine& other);
+ CommandLine& operator=(const CommandLine& other);
+
+
public:
struct Args;
struct Dispatch;
@@ -84,6 +88,7 @@
CommandLine(Args *AList,Configuration *Conf);
~CommandLine();
+ void FreeFileList();
};
struct CommandLine::Args
diff -Naur apt-0.5.15lorg2.orig/cmdline/apt-get.cc apt-0.5.15lorg2/cmdline/apt-get.cc
--- apt-0.5.15lorg2.orig/cmdline/apt-get.cc 2007-10-30 14:42:33 +0300
+++ apt-0.5.15lorg2/cmdline/apt-get.cc 2007-10-30 14:42:59 +0300
2007-10-22 16:22:08 +04:00
@@ -3366,6 +3366,7 @@
{0,"check-only","APT::Get::Check-Only",0}, // CNC:2003-03-06
{'c',"config-file",0,CommandLine::ConfigFile},
{'o',"option",0,CommandLine::ArbItem},
+ {0,"manifest","manifest",CommandLine::HasArg},
{0,0,0,0}};
CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate},
{"upgrade",&DoUpgrade},
@@ -3405,6 +3406,27 @@
return 100;
}
+ //append manifest content to FileList
+ if (!_config->Find("manifest").empty())
+ {
+ std::ifstream is(_config->Find("manifest").c_str());
+ vector<char*> new_filelist;
+ std::string line;
+
+ for (const char **I = CmdL.FileList; *I != 0; I++)
+ new_filelist.push_back(strdup(*I));
+ while (std::getline(is,line))
+ new_filelist.push_back(strdup(line.c_str()));
+
+ CmdL.FreeFileList();
+
+ size_t len = new_filelist.size();
+ CmdL.FileList = new const char *[len + 1];
+ for(int i=0;i<len;++i)
+ CmdL.FileList[i]=new_filelist[i];
+ CmdL.FileList[len] = 0;
+ }
+
// See if the help should be shown
if (_config->FindB("help") == true ||
_config->FindB("version") == true ||