summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2007-11-28 14:00:40 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2007-11-28 14:00:40 +0100
commitce1b2acbafafe111a09846b15183ef42eecf2be5 (patch)
tree88378b5b8b341e16f2a3647ca1cdf9a145689fd5 /apt-pkg
parent7052511ef60897a02c00da43a309465380f93603 (diff)
parent757f20941a19d5e1e9ebd74ecd5a4d5b0012644f (diff)
merge from the debian apt branch
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cdrom.cc11
-rw-r--r--apt-pkg/deb/debrecords.cc8
-rw-r--r--apt-pkg/deb/debrecords.h1
-rw-r--r--apt-pkg/deb/dpkgpm.cc99
-rw-r--r--apt-pkg/deb/dpkgpm.h6
-rw-r--r--apt-pkg/init.cc10
-rw-r--r--apt-pkg/init.h2
-rw-r--r--apt-pkg/makefile2
-rw-r--r--apt-pkg/pkgrecords.h1
9 files changed, 107 insertions, 33 deletions
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index b8f94e5b0..0cbdc178f 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -560,10 +560,17 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log)
}
if(log) {
msg.str("");
- ioprintf(msg, _("Stored label: %s \n"),
- Database.Find("CD::"+ident).c_str());
+ ioprintf(msg, _("Stored label: %s\n"),
+ Database.Find("CD::"+ident).c_str());
log->Update(msg.str());
}
+
+ // Unmount and finish
+ if (_config->FindB("APT::CDROM::NoMount",false) == false) {
+ log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
+ UnmountCdrom(CDROM);
+ }
+
return true;
}
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);
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 8e1d7c85a..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 /*{{{*/
@@ -503,6 +506,67 @@ 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, "Log ended: ");
+ fprintf(term_out, outstr);
+ fprintf(term_out, "\n");
+ fclose(term_out);
+ }
+ term_out = NULL;
+ 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_sec;
+ tv.tv_usec = timeout->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 /*{{{*/
// ---------------------------------------------------------------------
@@ -578,25 +642,10 @@ bool pkgDPkgPM::Go(int OutStatusFd)
}
}
+ stdin_is_dev_null = false;
+
// 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<Item>::iterator I = List.begin(); I != List.end();)
@@ -824,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);
@@ -832,6 +882,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)
@@ -881,14 +934,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..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;
@@ -66,6 +68,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);
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index 676b66d38..338bef66c 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -35,7 +35,7 @@ bool pkgInitConfig(Configuration &Cnf)
// General APT things
Cnf.Set("APT::Architecture", COMMON_ARCH);
Cnf.Set("APT::Build-Essential::", "build-essential");
- Cnf.Set("APT::Install-Recommends", false);
+ Cnf.Set("APT::Install-Recommends", true);
Cnf.Set("APT::Install-Suggests", false);
Cnf.Set("Dir","/");
@@ -72,7 +72,10 @@ bool pkgInitConfig(Configuration &Cnf)
// State
Cnf.Set("Dir::Log","var/log/apt");
Cnf.Set("Dir::Log::Terminal","term.log");
-
+
+ // Translation
+ Cnf.Set("APT::Acquire::Translation", "environment");
+
bool Res = true;
// Read an alternate config file
@@ -104,9 +107,6 @@ bool pkgInitConfig(Configuration &Cnf)
}
#endif
- // Translation
- Cnf.Set("APT::Acquire::Translation", "environment");
-
return true;
}
/*}}}*/
diff --git a/apt-pkg/init.h b/apt-pkg/init.h
index 23e951eff..6d8693be9 100644
--- a/apt-pkg/init.h
+++ b/apt-pkg/init.h
@@ -18,7 +18,7 @@
// See the makefile
#define APT_PKG_MAJOR 4
-#define APT_PKG_MINOR 5
+#define APT_PKG_MINOR 6
#define APT_PKG_RELEASE 0
extern const char *pkgVersion;
diff --git a/apt-pkg/makefile b/apt-pkg/makefile
index b327dbf64..1b78c94f6 100644
--- a/apt-pkg/makefile
+++ b/apt-pkg/makefile
@@ -13,7 +13,7 @@ include ../buildlib/defaults.mak
# methods/makefile - FIXME
LIBRARY=apt-pkg
LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
-MAJOR=4.5
+MAJOR=4.6
MINOR=0
SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil
APT_DOMAIN:=libapt-pkg$(MAJOR)
diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h
index f3bf7b6a1..17f3b1569 100644
--- a/apt-pkg/pkgrecords.h
+++ b/apt-pkg/pkgrecords.h
@@ -66,6 +66,7 @@ class pkgRecords::Parser
virtual string ShortDesc() {return string();};
virtual string LongDesc() {return string();};
virtual string Name() {return string();};
+ virtual string Homepage() {return string();}
// The record in binary form
virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;};