From fc2d32c089f035955c81100f2ded7c3f66793dc3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 23 May 2008 09:19:41 +0200 Subject: * improve apt progress reporting, display trigger actions --- apt-pkg/deb/dpkgpm.cc | 42 +++++++++++++++++++++++++++++++++++++++++- apt-pkg/deb/dpkgpm.h | 2 ++ 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index bc15b8819..8222be75e 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -333,6 +333,12 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line) 'status: /var/cache/apt/archives/krecipes_0.8.1-0ubuntu1_i386.deb : error : trying to overwrite `/usr/share/doc/kde/HTML/en/krecipes/krectip.png', which is also in package krecipes-data and conffile-prompt like this 'status: conffile-prompt: conffile : 'current-conffile' 'new-conffile' useredited distedited + + Newer versions of dpkg sent also: + 'processing: install: pkg' + 'processing: configure: pkg' + 'processing: remove: pkg' + 'processing: trigproc: trigger' */ char* list[5]; @@ -351,6 +357,34 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line) char *pkg = list[1]; char *action = _strstrip(list[2]); + // 'processing' from dpkg looks like + // 'processing: action: pkg' + if(strncmp(list[0], "processing", strlen("processing")) == 0) + { + char s[200]; + map::iterator iter; + char *pkg_or_trigger = _strstrip(list[2]); + action =_strstrip( list[1]); + iter = PackageProcessingOps.find(action); + if(iter == PackageProcessingOps.end()) + { + if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true) + std::clog << "ignoring unknwon action: " << action << std::endl; + return; + } + snprintf(s, sizeof(s), _(iter->second.c_str()), pkg_or_trigger); + + status << "pmstatus:" << pkg_or_trigger + << ":" << (PackagesDone/float(PackagesTotal)*100.0) + << ":" << s + << endl; + if(OutStatusFd > 0) + write(OutStatusFd, status.str().c_str(), status.str().size()); + if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true) + std::clog << "send: '" << status.str() << "'" << endl; + return; + } + if(strncmp(action,"error",strlen("error")) == 0) { status << "pmerror:" << list[1] @@ -526,7 +560,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) if (RunScriptsWithPkgs("DPkg::Pre-Install-Pkgs") == false) return false; - + // map the dpkg states to the operations that are performed // (this is sorted in the same way as Item::Ops) static const struct DpkgState DpkgStatesOpMap[][7] = { @@ -566,6 +600,12 @@ bool pkgDPkgPM::Go(int OutStatusFd) }, }; + // populate the "processing" map + PackageProcessingOps.insert( make_pair("install",N_("Installing %s")) ); + PackageProcessingOps.insert( make_pair("configure",N_("Configuring %s")) ); + PackageProcessingOps.insert( make_pair("remove",N_("Removing %s")) ); + PackageProcessingOps.insert( make_pair("trigproc",N_("Triggering %s")) ); + // init the PackageOps map, go over the list of packages that // that will be [installed|configured|removed|purged] and add // them to the PackageOps map (the dpkg states it goes through) diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index ebc7e32bf..449469126 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -47,6 +47,8 @@ class pkgDPkgPM : public pkgPackageManager // the int is the state that is already done (e.g. a package that is // going to be install is already in state "half-installed") map PackageOpsDone; + // map the dpkg "processing" info to human readable names + map PackageProcessingOps; // progress reporting unsigned int PackagesDone; unsigned int PackagesTotal; -- cgit v1.2.3-70-g09d2 From 5d382c9cbd8864c391a99ebf184836a5c60f56ed Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 17 Jul 2008 09:52:57 +0100 Subject: apt-pkg/deb/dpkgpm.cc: improve the trigger text --- 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 8222be75e..3528c1619 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -604,7 +604,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) PackageProcessingOps.insert( make_pair("install",N_("Installing %s")) ); PackageProcessingOps.insert( make_pair("configure",N_("Configuring %s")) ); PackageProcessingOps.insert( make_pair("remove",N_("Removing %s")) ); - PackageProcessingOps.insert( make_pair("trigproc",N_("Triggering %s")) ); + PackageProcessingOps.insert( make_pair("trigproc",N_("Running post-installation trigger %s")) ); // init the PackageOps map, go over the list of packages that // that will be [installed|configured|removed|purged] and add -- cgit v1.2.3-70-g09d2 From 870ce08fa327a889cfbd9ca67d7a33808b5482f4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 25 Jul 2008 20:29:31 +0200 Subject: * add DPkg::NoTriggers option so that applications that call apt/aptitude (like the installer) defer trigger processing (thanks to Joey Hess) --- apt-pkg/deb/dpkgpm.cc | 3 +++ debian/changelog | 3 +++ 2 files changed, 6 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 3528c1619..c2c33f342 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -554,6 +554,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) { unsigned int MaxArgs = _config->FindI("Dpkg::MaxArgs",8*1024); unsigned int MaxArgBytes = _config->FindI("Dpkg::MaxArgBytes",32*1024); + bool NoTriggers = _config->FindB("DPkg::NoTriggers",false); if (RunScripts("DPkg::Pre-Invoke") == false) return false; @@ -689,6 +690,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) case Item::Configure: Args[n++] = "--configure"; + if (NoTriggers) + Args[n++] = "--no-triggers"; Size += strlen(Args[n-1]); break; diff --git a/debian/changelog b/debian/changelog index b921fb004..f040d6cdf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,9 @@ apt (0.7.15) UNRELEASED; urgency=low (thanks to Arnaud Ebalard, closes: #485965) * add doc/examples/apt-https-method-example.cof (thanks to Arnaud Ebalard, closes: #485964) + * add DPkg::NoTriggers option so that applications that call + apt/aptitude (like the installer) defer trigger processing + (thanks to Joey Hess) -- -- cgit v1.2.3-70-g09d2 From 9b5d79ec68d5380f26b92cd0d9cb7af6a19ac849 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 5 Aug 2008 10:52:09 +0200 Subject: fix various -Wall warnings --- apt-inst/contrib/extracttar.cc | 4 ++-- apt-pkg/acquire.cc | 3 ++- apt-pkg/contrib/cdromutl.cc | 3 ++- apt-pkg/contrib/mmap.cc | 5 +++-- apt-pkg/deb/dpkgpm.cc | 4 ++-- apt-pkg/depcache.cc | 2 +- apt-pkg/indexcopy.cc | 2 +- cmdline/apt-cache.cc | 2 +- debian/changelog | 1 + methods/http.cc | 3 ++- methods/https.cc | 2 +- 11 files changed, 18 insertions(+), 13 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc index 68c871a5d..8338fd89d 100644 --- a/apt-inst/contrib/extracttar.cc +++ b/apt-inst/contrib/extracttar.cc @@ -208,14 +208,14 @@ bool ExtractTar::Go(pkgDirStream &Stream) Itm.Name = (char *)LastLongName.c_str(); else { - Tar->Name[sizeof(Tar->Name)] = 0; + Tar->Name[sizeof(Tar->Name)-1] = 0; Itm.Name = Tar->Name; } if (Itm.Name[0] == '.' && Itm.Name[1] == '/' && Itm.Name[2] != 0) Itm.Name += 2; // Grab the link target - Tar->Name[sizeof(Tar->LinkName)] = 0; + Tar->Name[sizeof(Tar->LinkName)-1] = 0; Itm.LinkTarget = Tar->LinkName; if (LastLongLink.empty() == false) diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 6840ae120..91f603889 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -444,8 +444,9 @@ bool pkgAcquire::Clean(string Dir) unlink(Dir->d_name); }; - chdir(StartDir.c_str()); closedir(D); + if (chdir(StartDir.c_str()) != 0) + return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); return true; } /*}}}*/ diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 6f00e1451..b6524a178 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -176,7 +176,8 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) Hash.Add(Dir->d_name); }; - chdir(StartDir.c_str()); + if (chdir(StartDir.c_str()) != 0) + return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); closedir(D); // Some stats from the fsys diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index abcae46fe..eed438250 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -192,7 +192,8 @@ DynamicMMap::~DynamicMMap() unsigned long EndOfFile = iSize; iSize = WorkSpace; Close(false); - ftruncate(Fd->Fd(),EndOfFile); + if(ftruncate(Fd->Fd(),EndOfFile) < 0) + _error->Errno("ftruncate", _("Failed to truncate file")); } /*}}}*/ // DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space /*{{{*/ @@ -209,7 +210,7 @@ unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln) // Just in case error check if (Result + Size > WorkSpace) { - _error->Error("Dynamic MMap ran out of room"); + _error->Error(_("Dynamic MMap ran out of room")); return 0; } diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index c2c33f342..2abb3a0ef 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -496,7 +496,7 @@ bool pkgDPkgPM::OpenLog() struct tm *tmp = localtime(&t); strftime(outstr, sizeof(outstr), "%F %T", tmp); fprintf(term_out, "\nLog started: "); - fprintf(term_out, outstr); + fprintf(term_out, "%s", outstr); fprintf(term_out, "\n"); } return true; @@ -511,7 +511,7 @@ bool pkgDPkgPM::CloseLog() struct tm *tmp = localtime(&t); strftime(outstr, sizeof(outstr), "%F %T", tmp); fprintf(term_out, "Log ended: "); - fprintf(term_out, outstr); + fprintf(term_out, "%s", outstr); fprintf(term_out, "\n"); fclose(term_out); } diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index d8b4dc6d2..4ac77b3aa 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -269,7 +269,7 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) ostr.str(string("")); ostr << "Package: " << pkg.Name() << "\nAuto-Installed: 1\n\n"; - fprintf(OutFile,ostr.str().c_str()); + fprintf(OutFile,"%s",ostr.str().c_str()); fprintf(OutFile,"\n"); } } diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index b30777d8d..9e5c03e0b 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -639,7 +639,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector &SigList, // Open the Release file and add it to the MetaIndex if(!MetaIndex->Load(*I+"Release")) { - _error->Error(MetaIndex->ErrorText.c_str()); + _error->Error("%s",MetaIndex->ErrorText.c_str()); return false; } diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index a73e35a53..b16a0e5d0 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1276,7 +1276,7 @@ bool DisplayRecord(pkgCache::VerIterator V) /*}}}*/ // Search - Perform a search /*{{{*/ // --------------------------------------------------------------------- -/* This searches the package names and pacakge descriptions for a pattern */ +/* This searches the package names and package descriptions for a pattern */ struct ExDescFile { pkgCache::DescFile *Df; diff --git a/debian/changelog b/debian/changelog index 24f876e44..cd433ac25 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,7 @@ apt (0.7.15) UNRELEASED; urgency=low (thanks to Joey Hess) * document --install-recommends and --no-install-recommends (thanks to Dereck Wonnacott, LP: #126180) + * fix various -Wall warnings [ Dereck Wonnacott ] * apt-ftparchive might write corrupt Release files (LP: #46439) diff --git a/methods/http.cc b/methods/http.cc index 26d435dea..b3c791fa0 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -941,7 +941,8 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv) if (Srv->StartPos >= 0) { Res.ResumePoint = Srv->StartPos; - ftruncate(File->Fd(),Srv->StartPos); + if (ftruncate(File->Fd(),Srv->StartPos) < 0) + _error->Errno("ftruncate", _("Failed to truncate file")); } // Set the start point diff --git a/methods/https.cc b/methods/https.cc index e53ba1a11..98dfeefa1 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -249,7 +249,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm) if(success != 0) { unlink(File->Name().c_str()); - _error->Error(curl_errorstr); + _error->Error("%s", curl_errorstr); Fail(); return true; } -- cgit v1.2.3-70-g09d2 From b462d75aab39f85d4ce9bd03c4dfda54f77b566f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 1 Oct 2008 17:55:05 +0200 Subject: * apt-pkg/packagemanager.cc, apt-pkg/deb/dpkgpm.cc: - move the state file writting into the Go() implementation of dpkgpm (closes: #498799) --- apt-pkg/deb/dpkgpm.cc | 2 ++ apt-pkg/packagemanager.cc | 4 ---- debian/changelog | 3 +++ 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 2abb3a0ef..c9af2f401 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -927,6 +927,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) if (RunScripts("DPkg::Post-Invoke") == false) return false; + + Cache.writeStateFile(NULL); return true; } /*}}}*/ diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index c391a6036..304d1c653 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -666,10 +666,6 @@ pkgPackageManager::DoInstallPostFork(int statusFd) if(goResult == false) return Failed; - // if all was fine update the state file - if(Res == Completed) { - Cache.writeStateFile(NULL); - } return Res; }; diff --git a/debian/changelog b/debian/changelog index 9ccb807c3..46d01bdf3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -45,6 +45,9 @@ apt (0.7.15) UNRELEASED; urgency=low * apt-pkg/pkgcachegen.cc: - do not add multiple identical descriptions for the same language (closes: #400768) + * apt-pkg/packagemanager.cc, apt-pkg/deb/dpkgpm.cc: + - move the state file writting into the Go() implementation + of dpkgpm (closes: #498799) [ Dereck Wonnacott ] * apt-ftparchive might write corrupt Release files (LP: #46439) -- cgit v1.2.3-70-g09d2 From 17745b02462bfbc0f1e8e5b2a062d887280345ea Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 28 Oct 2008 20:57:31 +0100 Subject: * apt-pkg/deb/dpkgpm.cc: - fix potential hang when in a backgroud process group --- apt-pkg/deb/dpkgpm.cc | 16 ++++++++++++---- debian/changelog | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 85cf4e119..36c20ad85 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -587,6 +587,11 @@ static int racy_pselect(int nfds, fd_set *readfds, fd_set *writefds, */ bool pkgDPkgPM::Go(int OutStatusFd) { + fd_set rfds; + struct timespec tv; + sigset_t sigmask; + sigset_t original_sigmask; + unsigned int MaxArgs = _config->FindI("Dpkg::MaxArgs",8*1024); unsigned int MaxArgBytes = _config->FindI("Dpkg::MaxArgBytes",32*1024); bool NoTriggers = _config->FindB("DPkg::NoTriggers",false); @@ -795,7 +800,14 @@ bool pkgDPkgPM::Go(int OutStatusFd) rtt = tt; cfmakeraw(&rtt); rtt.c_lflag &= ~ECHO; + // block SIGTTOU during tcsetattr to prevent a hang if + // the process is a member of the background process group + // http://www.opengroup.org/onlinepubs/000095399/functions/tcsetattr.html + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGTTOU); + sigprocmask(SIG_BLOCK,&sigmask, &original_sigmask); tcsetattr(0, TCSAFLUSH, &rtt); + sigprocmask(SIG_SETMASK, &original_sigmask, 0); } // Fork dpkg @@ -862,10 +874,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) close(slave); // setups fds - fd_set rfds; - struct timespec tv; - sigset_t sigmask; - sigset_t original_sigmask; sigemptyset(&sigmask); sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask); diff --git a/debian/changelog b/debian/changelog index 283c49fd5..fdf2db409 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,6 +28,8 @@ apt (0.7.17) UNRELEASED; urgency=low of variables (LP: #56792) * apt-pkg/cacheiterators.h: - add missing checks for Owner == 0 in end() + * apt-pkg/deb/dpkgpm.cc: + - fix potential hang when in a backgroud process group [ Dereck Wonnacott ] * apt-ftparchive might write corrupt Release files (LP: #46439) -- cgit v1.2.3-70-g09d2 From 73e598c3acc354b963d2ec93b77006841175df5d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 12 Nov 2008 16:23:19 +0100 Subject: fix SIGHUP handling (closes: #463030) --- apt-pkg/deb/dpkgpm.cc | 5 +++++ debian/changelog | 1 + 2 files changed, 6 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 36c20ad85..dde1c6d63 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -778,6 +778,9 @@ bool pkgDPkgPM::Go(int OutStatusFd) sighandler_t old_SIGQUIT = signal(SIGQUIT,SIG_IGN); sighandler_t old_SIGINT = signal(SIGINT,SIG_IGN); + // ignore SIGHUP as well (debian #463030) + sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); + struct termios tt; struct termios tt_out; struct winsize win; @@ -889,6 +892,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Restore sig int/quit signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); + signal(SIGINT,old_SIGHUP); return _error->Errno("waitpid","Couldn't wait for subprocess"); } @@ -928,6 +932,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Restore sig int/quit signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); + signal(SIGINT,old_SIGHUP); if(master >= 0) { diff --git a/debian/changelog b/debian/changelog index fdf2db409..0f20db8a3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -30,6 +30,7 @@ apt (0.7.17) UNRELEASED; urgency=low - add missing checks for Owner == 0 in end() * apt-pkg/deb/dpkgpm.cc: - fix potential hang when in a backgroud process group + - fix SIGHUP handling (closes: #463030) [ Dereck Wonnacott ] * apt-ftparchive might write corrupt Release files (LP: #46439) -- cgit v1.2.3-70-g09d2 From d9ec0faca41c96df02bac493549af64c5e6a8bc2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 12 Nov 2008 20:40:09 +0100 Subject: merge from debian-sid --- 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 dde1c6d63..5349a7ef2 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -932,7 +932,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Restore sig int/quit signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); - signal(SIGINT,old_SIGHUP); + signal(SIGHUP,old_SIGHUP); if(master >= 0) { -- cgit v1.2.3-70-g09d2 From e306ec4728557675680115af4470d16159f22ab1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 12 Nov 2008 21:17:34 +0100 Subject: fix another typo --- 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 5349a7ef2..686cbc6ee 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -892,7 +892,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Restore sig int/quit signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); - signal(SIGINT,old_SIGHUP); + signal(SIGHUP,old_SIGHUP); return _error->Errno("waitpid","Couldn't wait for subprocess"); } -- cgit v1.2.3-70-g09d2 From f23153d046f014f96d442fca5b9ef6ede7fcf546 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 9 Dec 2008 14:38:10 -0800 Subject: * methods/gpgv.cc: - fix compiler warning * cmdline/apt-get.cc: - fix "apt-get source pkg=ver" if binary name != source name and show a message (LP: #202219) * apt-pkg/deb/debsystem.cc: - make strings i18n able --- apt-pkg/deb/debsystem.cc | 15 ++++++++------- cmdline/apt-get.cc | 2 +- debian/changelog | 11 ++++++++--- methods/gpgv.cc | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index 11a84f1c6..b882367b8 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -17,7 +17,8 @@ #include #include #include - +#include + #include #include #include @@ -66,11 +67,11 @@ bool debSystem::Lock() if (LockFD == -1) { if (errno == EACCES || errno == EAGAIN) - return _error->Error("Unable to lock the administration directory (%s), " - "is another process using it?",AdminDir.c_str()); + return _error->Error(_("Unable to lock the administration directory (%s), " + "is another process using it?"),AdminDir.c_str()); else - return _error->Error("Unable to lock the administration directory (%s), " - "are you root?",AdminDir.c_str()); + return _error->Error(_("Unable to lock the administration directory (%s), " + "are you root?"),AdminDir.c_str()); } // See if we need to abort with a dirty journal @@ -78,8 +79,8 @@ bool debSystem::Lock() { close(LockFD); LockFD = -1; - return _error->Error("dpkg was interrupted, you must manually " - "run 'dpkg --configure -a' to correct the problem. "); + return _error->Error(_("dpkg was interrupted, you must manually " + "run 'dpkg --configure -a' to correct the problem. ")); } LockCount++; diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 40ae02400..2ef32a615 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1297,7 +1297,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, // show name mismatches if (IsMatch == true && Parse->Package() != Src) - ioprintf(c1out, _("No source package '%s' picking '%s' instead"), Parse->Package(), Src); + ioprintf(c1out, _("No source package '%s' picking '%s' instead"), Parse->Package().c_str(), Src.c_str()); if (VerTag.empty() == false) { diff --git a/debian/changelog b/debian/changelog index 77a5bac1f..e2a0365ac 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,8 +26,6 @@ apt (0.7.17) UNRELEASED; urgency=low * cmdline/apt-cache.cc: - remove the gettext from a string that consists entirely of variables (LP: #56792) - - fix "apt-get source pkg=ver" if binary name != source name - (LP: #202219) * doc/makefile: - add examples/apt-https-method-example.conf * apt-pkg/cacheiterators.h: @@ -39,7 +37,14 @@ apt (0.7.17) UNRELEASED; urgency=low - fix some i18n issues * apt-pkg/contrib/strutl.h: - add new strprintf() function to make i18n strings easier - + * methods/gpgv.cc: + - fix compiler warning + * cmdline/apt-get.cc: + - fix "apt-get source pkg=ver" if binary name != source name + and show a message (LP: #202219) + * apt-pkg/deb/debsystem.cc: + - make strings i18n able + [ Dereck Wonnacott ] * apt-ftparchive might write corrupt Release files (LP: #46439) * Apply --important option to apt-cache depends (LP: #16947) diff --git a/methods/gpgv.cc b/methods/gpgv.cc index 9f4683e6e..f3277b300 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -264,7 +264,7 @@ bool GPGVMethod::Fetch(FetchItem *Itm) // least one bad signature. good signatures and NoPubKey signatures // happen easily when a file is signed with multiple signatures if(GoodSigners.empty() or !BadSigners.empty()) - return _error->Error(errmsg.c_str()); + return _error->Error("%s", errmsg.c_str()); } // Just pass the raw output up, because passing it as a real data -- cgit v1.2.3-70-g09d2 From f814fbf4f2c78e3b9ceeeaba3cb93ed0ebbc7943 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 28 Jan 2009 17:36:03 +0100 Subject: apt-pkg/deb/debsystem.cc: add missing i18n string --- apt-pkg/deb/debsystem.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index b882367b8..82464d998 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -97,7 +97,7 @@ bool debSystem::UnLock(bool NoErrors) return false; if (LockCount < 1) - return _error->Error("Not locked"); + return _error->Error(_("Not locked")); if (--LockCount == 0) { close(LockFD); -- cgit v1.2.3-70-g09d2 From 51f07d3215a814cba98ed90f2ee4900ba2ba5780 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 6 Mar 2009 09:56:30 +0100 Subject: * apt-pkg/deb/dpkgpm.cc: - revert the change by Kees again for the amd64 ALL-CAPS problem --- apt-pkg/deb/dpkgpm.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 686cbc6ee..1d45e70e9 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -782,16 +782,14 @@ bool pkgDPkgPM::Go(int OutStatusFd) sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); struct termios tt; - struct termios tt_out; struct winsize win; int master; int slave; // FIXME: setup sensible signal handling (*ick*) tcgetattr(0, &tt); - tcgetattr(1, &tt_out); ioctl(0, TIOCGWINSZ, (char *)&win); - if (openpty(&master, &slave, NULL, &tt_out, &win) < 0) + if (openpty(&master, &slave, NULL, &tt, &win) < 0) { const char *s = _("Can not write log, openpty() " "failed (/dev/pts not mounted?)\n"); -- cgit v1.2.3-70-g09d2 From 4e86942abf369e5bce6c3612d0e8f2aa5a9f2821 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 23 Apr 2009 12:53:48 +0200 Subject: fix problematic use of tolower() when calculating the version hash by using locale independant tolower_ascii() function. Thanks to M. Vefa Bicakci (LP: #80248) --- apt-pkg/contrib/strutl.cc | 11 +++++++++++ apt-pkg/contrib/strutl.h | 1 + apt-pkg/deb/deblistparser.cc | 2 +- apt-pkg/pkgcache.cc | 4 ++-- debian/changelog | 4 ++++ 5 files changed, 19 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 327381d03..0b1bc3c98 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1074,6 +1074,17 @@ char *safe_snprintf(char *Buffer,char *End,const char *Format,...) } /*}}}*/ +// tolower_ascii - tolower() function that ignores the locale /*{{{*/ +// --------------------------------------------------------------------- +/* */ +int tolower_ascii(int c) +{ + if (c >= 'A' and c <= 'Z') + return c + 32; + return c; +} + /*}}}*/ + // CheckDomainList - See if Host is in a , seperate list /*{{{*/ // --------------------------------------------------------------------- /* The domain list is a comma seperate list of domains that are suffix diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index d9972abf4..51416a24a 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -62,6 +62,7 @@ void ioprintf(ostream &out,const char *format,...) APT_FORMAT2; void strprintf(string &out,const char *format,...) APT_FORMAT2; char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_FORMAT3; bool CheckDomainList(const string &Host, const string &List); +int tolower_ascii(int c); #define APT_MKSTRCMP(name,func) \ inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 896d4d6d8..55ba1f8c4 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -213,7 +213,7 @@ unsigned short debListParser::VersionHash() for (; Start != End; Start++) { if (isspace(*Start) == 0) - *I++ = tolower(*Start); + *I++ = tolower_ascii(*Start); if (*Start == '<' && Start[1] != '<' && Start[1] != '=') *I++ = '='; if (*Start == '>' && Start[1] != '>' && Start[1] != '=') diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 4fbf42c4b..6687864ee 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -163,7 +163,7 @@ unsigned long pkgCache::sHash(const string &Str) const { unsigned long Hash = 0; for (string::const_iterator I = Str.begin(); I != Str.end(); I++) - Hash = 5*Hash + tolower(*I); + Hash = 5*Hash + tolower_ascii(*I); return Hash % _count(HeaderP->HashTable); } @@ -171,7 +171,7 @@ unsigned long pkgCache::sHash(const char *Str) const { unsigned long Hash = 0; for (const char *I = Str; *I != 0; I++) - Hash = 5*Hash + tolower(*I); + Hash = 5*Hash + tolower_ascii(*I); return Hash % _count(HeaderP->HashTable); } diff --git a/debian/changelog b/debian/changelog index 75a3e2c0a..45804bc63 100644 --- a/debian/changelog +++ b/debian/changelog @@ -48,6 +48,10 @@ apt (0.7.21) UNRELEASED; urgency=low - add Acquire::https::AllowRedirect support * methods/gpgv.cc: - properly check for expired and revoked keys (closes: #433091) + * fix problematic use of tolower() when calculating the version + hash by using locale independant tolower_ascii() function. + Thanks to M. Vefa Bicakci (LP: #80248) + [ Dereck Wonnacott ] * apt-ftparchive might write corrupt Release files (LP: #46439) -- cgit v1.2.3-70-g09d2 From cebe0287c36408e44196266de45737386eaa28fc Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 17 Jun 2009 10:15:51 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - add Dpkg::UseIoNice boolean option to run dpkg with ionice -c3 (off by default) --- apt-pkg/deb/dpkgpm.cc | 30 +++++++++++++++++++++++++++++- debian/changelog | 3 +++ 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 1d45e70e9..462f4a739 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -74,6 +74,31 @@ namespace }; } +/* helper function to ionice the given PID + + there is no C header for ionice yet - just the syscall interface + so we use the binary from util-linux +*/ +static bool +ionice(int PID) +{ + if (!FileExists("/usr/bin/ionice")) + return false; + pid_t Process = ExecFork(); + if (Process == 0) + { + char buf[32]; + snprintf(buf, sizeof(buf), "-p%d", PID); + const char *Args[4]; + Args[0] = "/usr/bin/ionice"; + Args[1] = "-c3"; + Args[2] = buf; + Args[3] = 0; + execv(Args[0], (char **)Args); + } + return ExecWait(Process, "ionice"); +} + // DPkgPM::pkgDPkgPM - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -850,7 +875,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) _exit(100); } - /* No Job Control Stop Env is a magic dpkg var that prevents it from using sigstop */ putenv((char *)"DPKG_NO_TSTP=yes"); @@ -859,6 +883,10 @@ bool pkgDPkgPM::Go(int OutStatusFd) _exit(100); } + // apply ionice + if (_config->FindB("DPkg::UseIoNice", false) == true) + ionice(Child); + // clear the Keep-Fd again _config->Clear("APT::Keep-Fds",fd[1]); diff --git a/debian/changelog b/debian/changelog index 30e7b7591..a22f78401 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,9 @@ apt (0.7.21) UNRELEASED; urgency=low * apt-pkg/acquire.cc: - make the max pipeline depth of the acquire queue configurable via Acquire::Max-Pipeline-Depth + * apt-pkg/deb/dpkgpm.cc: + - add Dpkg::UseIoNice boolean option to run dpkg with ionice -c3 + (off by default) -- Michael Vogt Thu, 28 May 2009 17:51:42 +0200 -- cgit v1.2.3-70-g09d2 From ccd8e28fe16bf8e80db65e330ed89454c0104f80 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 17 Jun 2009 10:44:21 +0200 Subject: send "dpkg-exec" message on the status fd when dpkg is run --- apt-pkg/deb/dpkgpm.cc | 9 +++++++++ debian/changelog | 1 + 2 files changed, 10 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 462f4a739..a8d08f500 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -839,6 +839,15 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Fork dpkg pid_t Child; _config->Set("APT::Keep-Fds::",fd[1]); + // send status information that we are about to fork dpkg + if(OutStatusFd > 0) { + ostringstream status; + status << "pmstatus:dpkg-exec:" + << (PackagesDone/float(PackagesTotal)*100.0) + << ":" << _("Running dpkg") + << endl; + write(OutStatusFd, status.str().c_str(), status.str().size()); + } Child = ExecFork(); // This is the child diff --git a/debian/changelog b/debian/changelog index a22f78401..60db448c0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,7 @@ apt (0.7.21) UNRELEASED; urgency=low * apt-pkg/deb/dpkgpm.cc: - add Dpkg::UseIoNice boolean option to run dpkg with ionice -c3 (off by default) + - send "dpkg-exec" message on the status fd when dpkg is run -- Michael Vogt Thu, 28 May 2009 17:51:42 +0200 -- cgit v1.2.3-70-g09d2 From 599d6ad5ecb0f5876c391fef6db4171759911cf2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 10 Jul 2009 17:21:11 +0200 Subject: apt-pkg/deb/dpkgpm.cc: remove dead code, add comment on problematic argument list split --- apt-pkg/deb/dpkgpm.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index a8d08f500..416860f35 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -640,20 +640,12 @@ bool pkgDPkgPM::Go(int OutStatusFd) { {"unpacked",N_("Preparing to configure %s") }, {"half-configured", N_("Configuring %s") }, -#if 0 - {"triggers-awaited", N_("Processing triggers for %s") }, - {"triggers-pending", N_("Processing triggers for %s") }, -#endif { "installed", N_("Installed %s")}, {NULL, NULL} }, // Remove operation { {"half-configured", N_("Preparing for removal of %s")}, -#if 0 - {"triggers-awaited", N_("Preparing for removal of %s")}, - {"triggers-pending", N_("Preparing for removal of %s")}, -#endif {"half-installed", N_("Removing %s")}, {"config-files", N_("Removed %s")}, {NULL, NULL} @@ -690,10 +682,19 @@ bool pkgDPkgPM::Go(int OutStatusFd) for (vector::iterator I = List.begin(); I != List.end();) { vector::iterator J = I; - for (; J != List.end() && J->Op == I->Op; J++); + for (; J != List.end() && J->Op == I->Op; J++) + /* nothing */; // Generate the argument list const char *Args[MaxArgs + 50]; + + // Now check if we are within the MaxArgs limit + // + // this code below is problematic, because it may happen that + // the argument list is split in a way that A depends on B + // and they are in the same "--configure A B" run + // - with the split they may now be configured in different + // runs if (J - I > (signed)MaxArgs) J = I + MaxArgs; -- cgit v1.2.3-70-g09d2 From 4b7cfe96d621ab8fc0cec1334f0cd5f9ea87bf6d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 21 Jul 2009 13:52:48 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - provide DPkg::Chroot-Directory config option (useful for testing) --- apt-pkg/deb/dpkgpm.cc | 9 +++++++++ debian/changelog | 2 ++ 2 files changed, 11 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 416860f35..f787f365e 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -866,6 +866,15 @@ bool pkgDPkgPM::Go(int OutStatusFd) } close(fd[0]); // close the read end of the pipe + if (_config->FindDir("DPkg::Chroot-Directory","/") != "/") + { + std::cerr << "Chrooting into " + << _config->FindDir("DPkg::Chroot-Directory") + << std::endl; + if (chroot(_config->FindDir("DPkg::Chroot-Directory","/").c_str()) != 0) + _exit(100); + } + if (chdir(_config->FindDir("DPkg::Run-Directory","/").c_str()) != 0) _exit(100); diff --git a/debian/changelog b/debian/changelog index 65fd9e590..cf9231105 100644 --- a/debian/changelog +++ b/debian/changelog @@ -27,6 +27,8 @@ apt (0.7.21) UNRELEASED; urgency=low * methods/http.cc: - ignore SIGPIPE, we deal with EPIPE from write in HttpMethod::ServerDie() (LP: #385144) + * apt-pkg/deb/dpkgpm.cc: + - provide DPkg::Chroot-Directory config option (useful for testing) -- Michael Vogt Thu, 28 May 2009 17:51:42 +0200 -- cgit v1.2.3-70-g09d2