From 2e1715eabc8fabdcf3c3a4fe139412e2a2ffb8e4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 5 Sep 2007 14:57:35 +0200 Subject: * write start/end log tags --- apt-pkg/deb/dpkgpm.cc | 80 ++++++++++++++++++++++++++++++++++----------------- apt-pkg/deb/dpkgpm.h | 4 +++ 2 files changed, 57 insertions(+), 27 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index bb7e4b40a..2b32fbe66 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -495,6 +495,46 @@ void pkgDPkgPM::DoDpkgStatusFd(int statusfd, int OutStatusFd) } /*}}}*/ +bool pkgDPkgPM::OpenLog() +{ + string logdir = _config->FindDir("Dir::Log"); + if(not FileExists(logdir)) + return _error->Error(_("Directory '%s' missing"), logdir.c_str()); + string logfile_name = flCombine(logdir, + _config->Find("Dir::Log::Terminal")); + if (!logfile_name.empty()) + { + term_out = fopen(logfile_name.c_str(),"a"); + chmod(logfile_name.c_str(), 0600); + // output current time + char outstr[200]; + time_t t = time(NULL); + struct tm *tmp = localtime(&t); + strftime(outstr, sizeof(outstr), "%F %T", tmp); + fprintf(term_out, "\nLog started: "); + fprintf(term_out, outstr); + fprintf(term_out, "\n"); + } + return true; +} + +bool pkgDPkgPM::CloseLog() +{ + if(term_out) + { + char outstr[200]; + time_t t = time(NULL); + struct tm *tmp = localtime(&t); + strftime(outstr, sizeof(outstr), "%F %T", tmp); + fprintf(term_out, "\nLog ended: "); + fprintf(term_out, outstr); + fprintf(term_out, "\n"); + fclose(term_out); + } + term_out = NULL; + return true; +} + // DPkgPM::Go - Run the sequence /*{{{*/ // --------------------------------------------------------------------- @@ -563,24 +603,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) } // create log - string logdir = _config->FindDir("Dir::Log"); - if(not FileExists(logdir)) - return _error->Error(_("Directory '%s' missing"), logdir.c_str()); - string logfile_name = flCombine(logdir, - _config->Find("Dir::Log::Terminal")); - if (!logfile_name.empty()) - { - term_out = fopen(logfile_name.c_str(),"a"); - chmod(logfile_name.c_str(), 0600); - // output current time - char outstr[200]; - time_t t = time(NULL); - struct tm *tmp = localtime(&t); - strftime(outstr, sizeof(outstr), "%F %T", tmp); - fprintf(term_out, "\nLog started: "); - fprintf(term_out, outstr); - fprintf(term_out, "\n"); - } + OpenLog(); // this loop is runs once per operation for (vector::iterator I = List.begin(); I != List.end();) @@ -810,11 +833,16 @@ bool pkgDPkgPM::Go(int OutStatusFd) tv.tv_sec = 1; tv.tv_usec = 0; select_ret = select(max(master, _dpkgin)+1, &rfds, NULL, NULL, &tv); - if (select_ret < 0) { - std::cerr << "Error in select()" << std::endl; - continue; - } else if (select_ret == 0) - continue; + if (select_ret == 0) + continue; + else if (select_ret < 0 && errno == EINTR) + continue; + else if (select_ret < 0) + { + perror("select() returned error"); + continue; + } + if(master >= 0 && FD_ISSET(master, &rfds)) DoTerminalPty(master); @@ -852,14 +880,12 @@ bool pkgDPkgPM::Go(int OutStatusFd) if(stopOnError) { - if(term_out) - fclose(term_out); + CloseLog(); return false; } } } - if(term_out) - fclose(term_out); + CloseLog(); if (RunScripts("DPkg::Post-Invoke") == false) return false; diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index 448091626..b7f45b978 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -66,6 +66,10 @@ class pkgDPkgPM : public pkgPackageManager bool RunScriptsWithPkgs(const char *Cnf); bool SendV2Pkgs(FILE *F); + // dpkg log + bool OpenLog(); + bool CloseLog(); + // input processing void DoStdin(int master); void DoTerminalPty(int master); -- cgit v1.2.3 From 8398ac36e49bd1b863549753166d77de1efb3a23 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 5 Sep 2007 15:09:56 +0200 Subject: apt-pkg/deb/dpkgpm.cc: - remove leading "\n" --- apt-pkg/deb/dpkgpm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 2b32fbe66..f83214344 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -526,7 +526,7 @@ bool pkgDPkgPM::CloseLog() time_t t = time(NULL); struct tm *tmp = localtime(&t); strftime(outstr, sizeof(outstr), "%F %T", tmp); - fprintf(term_out, "\nLog ended: "); + fprintf(term_out, "Log ended: "); fprintf(term_out, outstr); fprintf(term_out, "\n"); fclose(term_out); -- cgit v1.2.3 From f27b4a70b2cfe4d49806080937d15fb415d4d18b Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Thu, 25 Oct 2007 09:58:11 -0200 Subject: * Applied patch from Daniel Burrows to add support for the Homepage field, closes: #447970. --- apt-pkg/deb/debrecords.cc | 8 ++++++++ apt-pkg/deb/debrecords.h | 1 + 2 files changed, 9 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index 3d3d7de0a..8ed0bb7eb 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -51,6 +51,14 @@ string debRecordParser::Name() return Section.FindS("Package"); } /*}}}*/ +// RecordParser::Homepage - Return the package homepage /*{{{*/ +// --------------------------------------------------------------------- +/* */ +string debRecordParser::Homepage() +{ + return Section.FindS("Homepage"); +} + /*}}}*/ // RecordParser::MD5Hash - Return the archive hash /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h index ab244b6dd..6f358abfa 100644 --- a/apt-pkg/deb/debrecords.h +++ b/apt-pkg/deb/debrecords.h @@ -44,6 +44,7 @@ class debRecordParser : public pkgRecords::Parser virtual string ShortDesc(); virtual string LongDesc(); virtual string Name(); + virtual string Homepage(); virtual void GetRec(const char *&Start,const char *&Stop); -- cgit v1.2.3 From 919e5852f297045cdb409143df663ad630b123e8 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Mon, 29 Oct 2007 16:52:30 -0200 Subject: * Applied patch from Brian M. Carlson to add backward support for arches that lacks pselect support, closes: #448406. --- apt-pkg/deb/dpkgpm.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index ce4d4b44b..e3fe8d845 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -543,6 +543,27 @@ bool pkgDPkgPM::CloseLog() return true; } +/*{{{*/ +// This implements a racy version of pselect for those architectures +// that don't have a working implementation. +// FIXME: Probably can be removed on Lenny+1 +static int racy_pselect(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const struct timespec *timeout, + const sigset_t *sigmask) +{ + sigset_t origmask; + struct timeval tv; + int retval; + + tv.tv_sec = timeout->tv.tv_sec; + tv.tv_usec = timeout->tv.tv_nsec/1000; + + sigprocmask(SIG_SETMASK, &sigmask, &origmask); + retval = select(nfds, readfds, writefds, exceptfds, &tv); + sigprocmask(SIG_SETMASK, &origmask, 0); + return retval; +} +/*}}}*/ // DPkgPM::Go - Run the sequence /*{{{*/ // --------------------------------------------------------------------- @@ -855,6 +876,9 @@ bool pkgDPkgPM::Go(int OutStatusFd) tv.tv_nsec = 0; select_ret = pselect(max(master, _dpkgin)+1, &rfds, NULL, NULL, &tv, &original_sigmask); + if (select_ret < 0 && (errno == EINVAL || errno == ENOSYS)) + select_ret = racy_pselect(max(master, _dpkgin)+1, &rfds, NULL, + NULL, &tv, &original_sigmask); if (select_ret == 0) continue; else if (select_ret < 0 && errno == EINTR) -- cgit v1.2.3 From f6b37f38731a06309dc761ffe0fdef094fdf50ca Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Wed, 31 Oct 2007 13:36:54 -0200 Subject: Minor fixes on racy_pselect --- apt-pkg/deb/dpkgpm.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index e3fe8d845..5a7711a90 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -555,10 +555,10 @@ static int racy_pselect(int nfds, fd_set *readfds, fd_set *writefds, struct timeval tv; int retval; - tv.tv_sec = timeout->tv.tv_sec; - tv.tv_usec = timeout->tv.tv_nsec/1000; + tv.tv_sec = timeout->tv_sec; + tv.tv_usec = timeout->tv_nsec/1000; - sigprocmask(SIG_SETMASK, &sigmask, &origmask); + sigprocmask(SIG_SETMASK, sigmask, &origmask); retval = select(nfds, readfds, writefds, exceptfds, &tv); sigprocmask(SIG_SETMASK, &origmask, 0); return retval; -- cgit v1.2.3 From 9983591d172ba5ded02b4e697e655429546e4966 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Mon, 26 Nov 2007 15:44:46 -0200 Subject: * Applied patch from Aurelien Jarno to avoid CPU getting crazy when /dev/null is redirected to stdin (which breaks buildds), closes: #452858. --- apt-pkg/deb/dpkgpm.cc | 10 ++++++++-- apt-pkg/deb/dpkgpm.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 5a7711a90..d796146fa 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -344,7 +344,10 @@ void pkgDPkgPM::DoStdin(int master) { char input_buf[256] = {0,}; int len = read(0, input_buf, sizeof(input_buf)); - write(master, input_buf, len); + if (len) + write(master, input_buf, len); + else + stdin_is_dev_null = true; } /*}}}*/ // DPkgPM::DoTerminalPty - Read the terminal pty and write log /*{{{*/ @@ -639,6 +642,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) } } + stdin_is_dev_null = false; + // create log OpenLog(); @@ -868,7 +873,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) // wait for input or output here FD_ZERO(&rfds); - FD_SET(0, &rfds); + if (!stdin_is_dev_null) + FD_SET(0, &rfds); FD_SET(_dpkgin, &rfds); if(master >= 0) FD_SET(master, &rfds); diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index b7f45b978..81a888f05 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -23,6 +23,8 @@ class pkgDPkgPM : public pkgPackageManager { private: + bool stdin_is_dev_null; + // the buffer we use for the dpkg status-fd reading char dpkgbuf[1024]; int dpkgbuf_pos; -- cgit v1.2.3