]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-get.cc
apt-get: Create the temporary downloaded changelog inside tmpdir
[apt.git] / cmdline / apt-get.cc
index caf69da2aeb7b7a735289f601b563e463e735213..cfa79339b7b9aa9574535f45587c892329513c2c 100644 (file)
@@ -665,7 +665,7 @@ static bool DoDownload(CommandLine &CmdL)
    {
       pkgAcquire::UriIterator I = Fetcher.UriBegin();
       for (; I != Fetcher.UriEnd(); ++I)
-        cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
+        cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile)  << ' ' <<
               I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
       return true;
    }
@@ -756,6 +756,7 @@ static bool DoSource(CommandLine &CmdL)
 
    // Load the requestd sources into the fetcher
    unsigned J = 0;
+   std::string UntrustedList;
    for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
    {
       string Src;
@@ -764,6 +765,9 @@ static bool DoSource(CommandLine &CmdL)
       if (Last == 0) {
         return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
       }
+
+      if (Last->Index().IsTrusted() == false)
+         UntrustedList += Src + " ";
       
       string srec = Last->AsStr();
       string::size_type pos = srec.find("\nVcs-");
@@ -847,6 +851,10 @@ static bool DoSource(CommandLine &CmdL)
                        Last->Index().SourceInfo(*Last,*I),Src);
       }
    }
+
+   // check authentication status of the source as well
+   if (UntrustedList != "" && !AuthPrompt(UntrustedList, false))
+      return false;
    
    // Display statistics
    unsigned long long FetchBytes = Fetcher.FetchNeeded();
@@ -945,18 +953,19 @@ static bool DoSource(CommandLine &CmdL)
         else
         {
            // Call dpkg-source
-           char S[500];
-           snprintf(S,sizeof(S),"%s -x %s",
+           std::string const sourceopts = _config->Find("DPkg::Source-Options", "-x");
+           std::string S;
+           strprintf(S, "%s %s %s",
                     _config->Find("Dir::Bin::dpkg-source","dpkg-source").c_str(),
-                    Dsc[I].Dsc.c_str());
-           if (system(S) != 0)
+                    sourceopts.c_str(), Dsc[I].Dsc.c_str());
+           if (system(S.c_str()) != 0)
            {
-              fprintf(stderr,_("Unpack command '%s' failed.\n"),S);
-              fprintf(stderr,_("Check if the 'dpkg-dev' package is installed.\n"));
+              fprintf(stderr, _("Unpack command '%s' failed.\n"), S.c_str());
+              fprintf(stderr, _("Check if the 'dpkg-dev' package is installed.\n"));
               _exit(1);
-           }       
+           }
         }
-        
+
         // Try to compile it with dpkg-buildpackage
         if (_config->FindB("APT::Get::Compile",false) == true)
         {
@@ -972,20 +981,20 @@ static bool DoSource(CommandLine &CmdL)
            buildopts.append(_config->Find("DPkg::Build-Options","-b -uc"));
 
            // Call dpkg-buildpackage
-           char S[500];
-           snprintf(S,sizeof(S),"cd %s && %s %s",
+           std::string S;
+           strprintf(S, "cd %s && %s %s",
                     Dir.c_str(),
                     _config->Find("Dir::Bin::dpkg-buildpackage","dpkg-buildpackage").c_str(),
                     buildopts.c_str());
-           
-           if (system(S) != 0)
+
+           if (system(S.c_str()) != 0)
            {
-              fprintf(stderr,_("Build command '%s' failed.\n"),S);
+              fprintf(stderr, _("Build command '%s' failed.\n"), S.c_str());
               _exit(1);
-           }       
-        }      
+           }
+        }
       }
-      
+
       _exit(0);
    }
 
@@ -1554,7 +1563,7 @@ static bool DoChangelog(CommandLine &CmdL)
    {
       string changelogfile;
       if (downOnly == false)
-        changelogfile.append(tmpname).append("changelog");
+        changelogfile.append(tmpname).append("/changelog");
       else
         changelogfile.append(Ver.ParentPkg().Name()).append(".changelog");
       if (DownloadChangelog(Cache, Fetcher, Ver, changelogfile) && downOnly == false)
@@ -1664,20 +1673,6 @@ static bool ShowHelp(CommandLine &)
       "pages for more information and options.\n"
       "                       This APT has Super Cow Powers.\n");
    return true;
-}
-                                                                       /*}}}*/
-// SigWinch - Window size change signal handler                                /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static void SigWinch(int)
-{
-   // Riped from GNU ls
-#ifdef TIOCGWINSZ
-   struct winsize ws;
-  
-   if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5)
-      ScreenWidth = ws.ws_col - 1;
-#endif
 }
                                                                        /*}}}*/
 int main(int argc,const char *argv[])                                  /*{{{*/
@@ -1734,14 +1729,12 @@ int main(int argc,const char *argv[])                                   /*{{{*/
    // see if we are in simulate mode
    CheckSimulateMode(CmdL);
 
+   // Init the signals
+   InitSignals();
+
    // Setup the output streams
    InitOutput();
 
-   // Setup the signals
-   signal(SIGPIPE,SIG_IGN);
-   signal(SIGWINCH,SigWinch);
-   SigWinch(0);
-
    // Match the operation
    CmdL.DispatchArg(Cmds);