CopyFile - Buffered copy of a single file
GetLock - dpkg compatible lock file manipulation (fcntl)
- This source is placed in the Public Domain, do with it what you will
+ Most of this source is placed in the Public Domain, do with it what
+ you will
It was originally written by Jason Gunthorpe <jgg@debian.org>.
+ The exception is RunScripts() it is under the GPLv2
+
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
using namespace std;
+// RunScripts - Run a set of scripts from a configuration subtree /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool RunScripts(const char *Cnf)
+{
+ Configuration::Item const *Opts = _config->Tree(Cnf);
+ if (Opts == 0 || Opts->Child == 0)
+ return true;
+ Opts = Opts->Child;
+
+ // Fork for running the system calls
+ pid_t Child = ExecFork();
+
+ // This is the child
+ if (Child == 0)
+ {
+ if (chdir("/tmp/") != 0)
+ _exit(100);
+
+ unsigned int Count = 1;
+ for (; Opts != 0; Opts = Opts->Next, Count++)
+ {
+ if (Opts->Value.empty() == true)
+ continue;
+
+ if (system(Opts->Value.c_str()) != 0)
+ _exit(100+Count);
+ }
+ _exit(0);
+ }
+
+ // Wait for the child
+ int Status = 0;
+ while (waitpid(Child,&Status,0) != Child)
+ {
+ if (errno == EINTR)
+ continue;
+ return _error->Errno("waitpid","Couldn't wait for subprocess");
+ }
+
+ // Restore sig int/quit
+ signal(SIGQUIT,SIG_DFL);
+ signal(SIGINT,SIG_DFL);
+
+ // Check for an error code.
+ if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
+ {
+ unsigned int Count = WEXITSTATUS(Status);
+ if (Count > 100)
+ {
+ Count -= 100;
+ for (; Opts != 0 && Count != 1; Opts = Opts->Next, Count--);
+ _error->Error("Problem executing scripts %s '%s'",Cnf,Opts->Value.c_str());
+ }
+
+ return _error->Error("Sub-process returned an error code");
+ }
+
+ return true;
+}
+ /*}}}*/
+
// CopyFile - Buffered copy of a file /*{{{*/
// ---------------------------------------------------------------------
/* The caller is expected to set things so that failure causes erasure */
#include <apt-pkg/configuration.h>
#include <apt-pkg/depcache.h>
#include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.h>
#include <unistd.h>
#include <stdlib.h>
each one is run with system from a forked child. */
bool pkgDPkgPM::RunScripts(const char *Cnf)
{
- Configuration::Item const *Opts = _config->Tree(Cnf);
- if (Opts == 0 || Opts->Child == 0)
- return true;
- Opts = Opts->Child;
-
- // Fork for running the system calls
- pid_t Child = ExecFork();
-
- // This is the child
- if (Child == 0)
- {
- if (chdir("/tmp/") != 0)
- _exit(100);
-
- unsigned int Count = 1;
- for (; Opts != 0; Opts = Opts->Next, Count++)
- {
- if (Opts->Value.empty() == true)
- continue;
-
- if (system(Opts->Value.c_str()) != 0)
- _exit(100+Count);
- }
- _exit(0);
- }
-
- // Wait for the child
- int Status = 0;
- while (waitpid(Child,&Status,0) != Child)
- {
- if (errno == EINTR)
- continue;
- return _error->Errno("waitpid","Couldn't wait for subprocess");
- }
-
- // Restore sig int/quit
- signal(SIGQUIT,SIG_DFL);
- signal(SIGINT,SIG_DFL);
-
- // Check for an error code.
- if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
- {
- unsigned int Count = WEXITSTATUS(Status);
- if (Count > 100)
- {
- Count -= 100;
- for (; Opts != 0 && Count != 1; Opts = Opts->Next, Count--);
- _error->Error("Problem executing scripts %s '%s'",Cnf,Opts->Value.c_str());
- }
-
- return _error->Error("Sub-process returned an error code");
- }
-
- return true;
+ RunScripts(Cnf);
}
/*}}}*/
// DPkgPM::SendV2Pkgs - Send version 2 package info /*{{{*/
msgstr ""
#: cmdline/apt-get.cc:801 cmdline/apt-get.cc:1856 cmdline/apt-get.cc:2092
-#: apt-pkg/cachefile.cc:68
+#: apt-pkg/cachefile.cc:69
msgid "The list of sources could not be read."
msgstr ""
msgid "Do you want to continue [Y/n]? "
msgstr ""
-#: cmdline/apt-get.cc:961 cmdline/apt-get.cc:1989 apt-pkg/cachefile.cc:138
+#: cmdline/apt-get.cc:961 cmdline/apt-get.cc:1989 apt-pkg/cachefile.cc:142
#, c-format
msgid "Failed to fetch %s %s\n"
msgstr ""
msgid "Server closed the connection"
msgstr ""
-#: methods/ftp.cc:338 apt-pkg/contrib/fileutl.cc:471 methods/rsh.cc:190
+#: methods/ftp.cc:338 apt-pkg/contrib/fileutl.cc:536 methods/rsh.cc:190
msgid "Read error"
msgstr ""
msgid "Protocol corruption"
msgstr ""
-#: methods/ftp.cc:446 apt-pkg/contrib/fileutl.cc:510 methods/rsh.cc:232
+#: methods/ftp.cc:446 apt-pkg/contrib/fileutl.cc:575 methods/rsh.cc:232
msgid "Write error"
msgstr ""
msgid "Failed to stat the cdrom"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:82
+#: apt-pkg/contrib/fileutl.cc:147
#, c-format
msgid "Not using locking for read only lock file %s"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:87
+#: apt-pkg/contrib/fileutl.cc:152
#, c-format
msgid "Could not open lock file %s"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:105
+#: apt-pkg/contrib/fileutl.cc:170
#, c-format
msgid "Not using locking for nfs mounted lock file %s"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:109
+#: apt-pkg/contrib/fileutl.cc:174
#, c-format
msgid "Could not get lock %s"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:377
+#: apt-pkg/contrib/fileutl.cc:442
#, c-format
msgid "Waited for %s but it wasn't there"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:387
+#: apt-pkg/contrib/fileutl.cc:452
#, c-format
msgid "Sub-process %s received a segmentation fault."
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:390
+#: apt-pkg/contrib/fileutl.cc:455
#, c-format
msgid "Sub-process %s returned an error code (%u)"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:392
+#: apt-pkg/contrib/fileutl.cc:457
#, c-format
msgid "Sub-process %s exited unexpectedly"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:436
+#: apt-pkg/contrib/fileutl.cc:501
#, c-format
msgid "Could not open file %s"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:492
+#: apt-pkg/contrib/fileutl.cc:557
#, c-format
msgid "read, still have %lu to read but none left"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:522
+#: apt-pkg/contrib/fileutl.cc:587
#, c-format
msgid "write, still have %lu to write but couldn't"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:597
+#: apt-pkg/contrib/fileutl.cc:662
msgid "Problem closing the file"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:603
+#: apt-pkg/contrib/fileutl.cc:668
msgid "Problem unlinking the file"
msgstr ""
-#: apt-pkg/contrib/fileutl.cc:614
+#: apt-pkg/contrib/fileutl.cc:679
msgid "Problem syncing the file"
msgstr ""
msgid "You must put some 'source' URIs in your sources.list"
msgstr ""
-#: apt-pkg/cachefile.cc:74
+#: apt-pkg/cachefile.cc:75
msgid "The package lists or status file could not be parsed or opened."
msgstr ""
-#: apt-pkg/cachefile.cc:78
+#: apt-pkg/cachefile.cc:79
msgid "You may want to run apt-get update to correct these problems"
msgstr ""
msgid "Wrote %i records with %i missing files and %i mismatched files\n"
msgstr ""
-#: apt-pkg/deb/dpkgpm.cc:358
+#: apt-pkg/deb/dpkgpm.cc:306
#, c-format
msgid "Preparing %s"
msgstr ""
-#: apt-pkg/deb/dpkgpm.cc:359
+#: apt-pkg/deb/dpkgpm.cc:307
#, c-format
msgid "Unpacking %s"
msgstr ""
-#: apt-pkg/deb/dpkgpm.cc:364
+#: apt-pkg/deb/dpkgpm.cc:312
#, c-format
msgid "Preparing to configure %s"
msgstr ""
-#: apt-pkg/deb/dpkgpm.cc:365
+#: apt-pkg/deb/dpkgpm.cc:313
#, c-format
msgid "Configuring %s"
msgstr ""
-#: apt-pkg/deb/dpkgpm.cc:366
+#: apt-pkg/deb/dpkgpm.cc:314
#, c-format
msgid "Installed %s"
msgstr ""
-#: apt-pkg/deb/dpkgpm.cc:371
+#: apt-pkg/deb/dpkgpm.cc:319
#, c-format
msgid "Preparing for removal of %s"
msgstr ""
-#: apt-pkg/deb/dpkgpm.cc:372
+#: apt-pkg/deb/dpkgpm.cc:320
#, c-format
msgid "Removing %s"
msgstr ""
-#: apt-pkg/deb/dpkgpm.cc:373
+#: apt-pkg/deb/dpkgpm.cc:321
#, c-format
msgid "Removed %s"
msgstr ""
-#: apt-pkg/deb/dpkgpm.cc:378
+#: apt-pkg/deb/dpkgpm.cc:326
#, c-format
msgid "Preparing to completely remove %s"
msgstr ""
-#: apt-pkg/deb/dpkgpm.cc:379
+#: apt-pkg/deb/dpkgpm.cc:327
#, c-format
msgid "Completely removed %s"
msgstr ""