Selaa lähdekoodia

merged from lp:~donkult/apt/sid

Michael Vogt 16 vuotta sitten
vanhempi
commit
fb031c5598

+ 4 - 25
apt-pkg/acquire.cc

@@ -74,12 +74,12 @@ bool pkgAcquire::Setup(pkgAcquireStatus *Progress, string const &Lock)
    string const archivesDir = _config->FindDir("Dir::Cache::Archives");
    string const archivesDir = _config->FindDir("Dir::Cache::Archives");
    string const partialArchivesDir = archivesDir + "partial/";
    string const partialArchivesDir = archivesDir + "partial/";
 
 
-   if (CheckDirectory(_config->FindDir("Dir::State"), partialListDir) == false &&
-       CheckDirectory(listDir, partialListDir) == false)
+   if (CreateAPTDirectoryIfNeeded(_config->FindDir("Dir::State"), partialListDir) == false &&
+       CreateAPTDirectoryIfNeeded(listDir, partialListDir) == false)
       return _error->Errno("Acquire", _("List directory %spartial is missing."), listDir.c_str());
       return _error->Errno("Acquire", _("List directory %spartial is missing."), listDir.c_str());
 
 
-   if (CheckDirectory(_config->FindDir("Dir::Cache"), partialArchivesDir) == false &&
-       CheckDirectory(archivesDir, partialArchivesDir) == false)
+   if (CreateAPTDirectoryIfNeeded(_config->FindDir("Dir::Cache"), partialArchivesDir) == false &&
+       CreateAPTDirectoryIfNeeded(archivesDir, partialArchivesDir) == false)
       return _error->Errno("Acquire", _("Archives directory %spartial is missing."), archivesDir.c_str());
       return _error->Errno("Acquire", _("Archives directory %spartial is missing."), archivesDir.c_str());
 
 
    if (Lock.empty() == true || _config->FindB("Debug::NoLocking", false) == true)
    if (Lock.empty() == true || _config->FindB("Debug::NoLocking", false) == true)
@@ -93,27 +93,6 @@ bool pkgAcquire::Setup(pkgAcquireStatus *Progress, string const &Lock)
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
-// Acquire::CheckDirectory - ensure that the given directory exists	/*{{{*/
-// ---------------------------------------------------------------------
-/* a small wrapper around CreateDirectory to check if it exists and to
-   remove the trailing "/apt/" from the parent directory if needed */
-bool pkgAcquire::CheckDirectory(string const &Parent, string const &Path) const
-{
-   if (DirectoryExists(Path) == true)
-      return true;
-
-   size_t const len = Parent.size();
-   if (len > 5 && Parent.find("/apt/", len - 6, 5) == len - 5)
-   {
-      if (CreateDirectory(Parent.substr(0,len-5), Path) == true)
-	 return true;
-   }
-   else if (CreateDirectory(Parent, Path) == true)
-      return true;
-
-   return false;
-}
-									/*}}}*/
 // Acquire::~pkgAcquire	- Destructor					/*{{{*/
 // Acquire::~pkgAcquire	- Destructor					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* Free our memory, clean up the queues (destroy the workers) */
 /* Free our memory, clean up the queues (destroy the workers) */

+ 0 - 8
apt-pkg/acquire.h

@@ -362,14 +362,6 @@ class pkgAcquire
    private:
    private:
    /** \brief FD of the Lock file we acquire in Setup (if any) */
    /** \brief FD of the Lock file we acquire in Setup (if any) */
    int LockFD;
    int LockFD;
-
-   /** \brief Ensure the existence of the given Path
-    *
-    *  \param Parent directory of the Path directory - a trailing
-    *  /apt/ will be removed before CreateDirectory call.
-    *  \param Path which should exist after (successful) call
-    */
-   bool CheckDirectory(string const &Parent, string const &Path) const;
 };
 };
 
 
 /** \brief Represents a single download source from which an item
 /** \brief Represents a single download source from which an item

+ 21 - 0
apt-pkg/contrib/fileutl.cc

@@ -251,6 +251,27 @@ bool CreateDirectory(string const &Parent, string const &Path)
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
+// CreateAPTDirectoryIfNeeded - ensure that the given directory exists		/*{{{*/
+// ---------------------------------------------------------------------
+/* a small wrapper around CreateDirectory to check if it exists and to
+   remove the trailing "/apt/" from the parent directory if needed */
+bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path)
+{
+   if (DirectoryExists(Path) == true)
+      return true;
+
+   size_t const len = Parent.size();
+   if (len > 5 && Parent.find("/apt/", len - 6, 5) == len - 5)
+   {
+      if (CreateDirectory(Parent.substr(0,len-5), Path) == true)
+	 return true;
+   }
+   else if (CreateDirectory(Parent, Path) == true)
+      return true;
+
+   return false;
+}
+									/*}}}*/
 // GetListOfFilesInDir - returns a vector of files in the given dir	/*{{{*/
 // GetListOfFilesInDir - returns a vector of files in the given dir	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* If an extension is given only files with this extension are included
 /* If an extension is given only files with this extension are included

+ 9 - 0
apt-pkg/contrib/fileutl.h

@@ -94,6 +94,15 @@ int GetLock(string File,bool Errors = true);
 bool FileExists(string File);
 bool FileExists(string File);
 bool DirectoryExists(string const &Path) __attrib_const;
 bool DirectoryExists(string const &Path) __attrib_const;
 bool CreateDirectory(string const &Parent, string const &Path);
 bool CreateDirectory(string const &Parent, string const &Path);
+
+/** \brief Ensure the existence of the given Path
+ *
+ *  \param Parent directory of the Path directory - a trailing
+ *  /apt/ will be removed before CreateDirectory call.
+ *  \param Path which should exist after (successful) call
+ */
+bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path);
+
 std::vector<string> GetListOfFilesInDir(string const &Dir, string const &Ext,
 std::vector<string> GetListOfFilesInDir(string const &Dir, string const &Ext,
 					bool const &SortList, bool const &AllowNoExt=false);
 					bool const &SortList, bool const &AllowNoExt=false);
 std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> const &Ext,
 std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> const &Ext,

+ 2 - 1
apt-pkg/deb/dpkgpm.cc

@@ -641,7 +641,8 @@ void pkgDPkgPM::WriteHistoryTag(string const &tag, string value)
 bool pkgDPkgPM::OpenLog()
 bool pkgDPkgPM::OpenLog()
 {
 {
    string const logdir = _config->FindDir("Dir::Log");
    string const logdir = _config->FindDir("Dir::Log");
-   if(not FileExists(logdir))
+   if(CreateAPTDirectoryIfNeeded(logdir, logdir) == false)
+      // FIXME: use a better string after freeze
       return _error->Error(_("Directory '%s' missing"), logdir.c_str());
       return _error->Error(_("Directory '%s' missing"), logdir.c_str());
 
 
    // get current time
    // get current time

+ 1 - 1
apt-pkg/indexcopy.cc

@@ -661,7 +661,7 @@ bool SigVerify::RunGPGV(std::string const &File, std::string const &FileGPG,
 {
 {
    string const gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv");
    string const gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv");
    // FIXME: remove support for deprecated APT::GPGV setting
    // FIXME: remove support for deprecated APT::GPGV setting
-   string const trustedFile = _config->FindFile("Dir::Etc::Trusted");
+   string const trustedFile = _config->Find("APT::GPGV::TrustedKeyring", _config->FindFile("Dir::Etc::Trusted"));
    string const trustedPath = _config->FindDir("Dir::Etc::TrustedParts");
    string const trustedPath = _config->FindDir("Dir::Etc::TrustedParts");
 
 
    bool const Debug = _config->FindB("Debug::Acquire::gpgv", false);
    bool const Debug = _config->FindB("Debug::Acquire::gpgv", false);

+ 1 - 2
apt-pkg/init.cc

@@ -70,8 +70,7 @@ bool pkgInitConfig(Configuration &Cnf)
    Cnf.Set("Dir::Etc::parts","apt.conf.d");
    Cnf.Set("Dir::Etc::parts","apt.conf.d");
    Cnf.Set("Dir::Etc::preferences","preferences");
    Cnf.Set("Dir::Etc::preferences","preferences");
    Cnf.Set("Dir::Etc::preferencesparts","preferences.d");
    Cnf.Set("Dir::Etc::preferencesparts","preferences.d");
-   string const deprecated = _config->Find("APT::GPGV::TrustedKeyring");
-   Cnf.Set("Dir::Etc::trusted", deprecated.empty() ? "trusted.gpg" : deprecated);
+   Cnf.Set("Dir::Etc::trusted", "trusted.gpg");
    Cnf.Set("Dir::Etc::trustedparts","trusted.gpg.d");
    Cnf.Set("Dir::Etc::trustedparts","trusted.gpg.d");
    Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
    Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
    Cnf.Set("Dir::Media::MountPath","/media/apt");
    Cnf.Set("Dir::Media::MountPath","/media/apt");

+ 1 - 1
apt-pkg/init.h

@@ -23,7 +23,7 @@
 // See also buildlib/libversion.mak
 // See also buildlib/libversion.mak
 #define APT_PKG_MAJOR 4
 #define APT_PKG_MAJOR 4
 #define APT_PKG_MINOR 10
 #define APT_PKG_MINOR 10
-#define APT_PKG_RELEASE 0
+#define APT_PKG_RELEASE 1
     
     
 extern const char *pkgVersion;
 extern const char *pkgVersion;
 extern const char *pkgLibVersion;
 extern const char *pkgLibVersion;

+ 1 - 1
apt-pkg/versionmatch.cc

@@ -118,7 +118,7 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type)
    
    
    if (Type == Origin)
    if (Type == Origin)
    {
    {
-      if (Data[0] == '"' && Data.end()[-1] == '"')
+      if (Data[0] == '"' && Data.length() >= 2 && Data.end()[-1] == '"')
 	 OrSite = Data.substr(1, Data.length() - 2);
 	 OrSite = Data.substr(1, Data.length() - 2);
       else
       else
 	 OrSite = Data;
 	 OrSite = Data;

+ 2 - 0
cmdline/apt-key

@@ -147,11 +147,13 @@ else
 	#echo "generate list"
 	#echo "generate list"
 	TRUSTEDFILE="/etc/apt/trusted.gpg"
 	TRUSTEDFILE="/etc/apt/trusted.gpg"
 	eval $(apt-config shell TRUSTEDFILE Apt::GPGV::TrustedKeyring)
 	eval $(apt-config shell TRUSTEDFILE Apt::GPGV::TrustedKeyring)
+	eval $(apt-config shell TRUSTEDFILE Dir::Etc::Trusted/f)
 	if [ -r "$TRUSTEDFILE" ]; then
 	if [ -r "$TRUSTEDFILE" ]; then
 		GPG="$GPG --keyring $TRUSTEDFILE"
 		GPG="$GPG --keyring $TRUSTEDFILE"
 	fi
 	fi
 	GPG="$GPG --primary-keyring $TRUSTEDFILE"
 	GPG="$GPG --primary-keyring $TRUSTEDFILE"
 	TRUSTEDPARTS="/etc/apt/trusted.gpg.d"
 	TRUSTEDPARTS="/etc/apt/trusted.gpg.d"
+	eval $(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d)
 	if [ -d "$TRUSTEDPARTS" ]; then
 	if [ -d "$TRUSTEDPARTS" ]; then
 		#echo "parts active"
 		#echo "parts active"
 		for trusted in $(run-parts --list $TRUSTEDPARTS --regex '^.*\.gpg$'); do
 		for trusted in $(run-parts --list $TRUSTEDPARTS --regex '^.*\.gpg$'); do

+ 1 - 1
configure.in

@@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 
 dnl -- SET THIS TO THE RELEASE VERSION --
 dnl -- SET THIS TO THE RELEASE VERSION --
-AC_DEFINE_UNQUOTED(VERSION,"0.7.26~exp6")
+AC_DEFINE_UNQUOTED(VERSION,"0.8.2")
 PACKAGE="apt"
 PACKAGE="apt"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_SUBST(PACKAGE)
 AC_SUBST(PACKAGE)

+ 17 - 1
debian/changelog

@@ -3,7 +3,23 @@ apt (0.8.2) UNRELEASED; urgency=low
   [ Manpages translations ]
   [ Manpages translations ]
   * Spanish (Omar Campagne). Closes: #595557
   * Spanish (Omar Campagne). Closes: #595557
 
 
- -- Christian Perrier <bubulle@debian.org>  Sun, 05 Sep 2010 07:53:15 +0200
+  [ David Kalnischkies ]
+  * apt-pkg/versionmatch.cc:
+    - do not accept 'Pin: origin "' (missing closing ") as a valid
+      way to pin a local archive: either "" or none…
+  * apt-pkg/deb/dpkgpm.cc:
+    - create Dir::Log if needed to support /var/log as tmpfs or similar,
+      inspired by Thomas Bechtold, thanks! (Closes: #523919, LP: #220239)
+  * apt-pkg/indexcopy.cc:
+    - support really still the APT::GPGV::TrustedKeyring setting,
+      as it breaks d-i badly otherwise (Closes: #595428)
+  * cmdline/apt-key:
+    - support also Dir::Etc::Trusted so that apt-key works in the same
+      way as the library part which works with the trusted files
+  * methods/{gzip,bzip2}.cc:
+    - empty files can never be valid archives (Closes: #595691)
+
+ -- Michael Vogt <mvo@debian.org>  Mon, 06 Sep 2010 18:10:06 +0200
 
 
 apt (0.8.1) unstable; urgency=low
 apt (0.8.1) unstable; urgency=low
 
 

+ 3 - 6
methods/bzip2.cc

@@ -56,12 +56,9 @@ bool Bzip2Method::Fetch(FetchItem *Itm)
    // Open the source and destination files
    // Open the source and destination files
    FileFd From(Path,FileFd::ReadOnly);
    FileFd From(Path,FileFd::ReadOnly);
 
 
-   // if the file is empty, just rename it and return
-   if(From.Size() == 0) 
-   {
-      rename(Path.c_str(), Itm->DestFile.c_str());
-      return true;
-   }
+   // FIXME add an error message saying that empty files can't be valid archives
+   if(From.Size() == 0)
+      return false;
 
 
    int GzOut[2];   
    int GzOut[2];   
    if (pipe(GzOut) < 0)
    if (pipe(GzOut) < 0)

+ 3 - 6
methods/gzip.cc

@@ -48,12 +48,9 @@ bool GzipMethod::Fetch(FetchItem *Itm)
    // Open the source and destination files
    // Open the source and destination files
    FileFd From(Path,FileFd::ReadOnlyGzip);
    FileFd From(Path,FileFd::ReadOnlyGzip);
 
 
-   // if the file is empty, just rename it and return
-   if(From.Size() == 0) 
-   {
-      rename(Path.c_str(), Itm->DestFile.c_str());
-      return true;
-   }
+   // FIXME add an error message saying that empty files can't be valid archives
+   if(From.Size() == 0)
+      return false;
 
 
    FileFd To(Itm->DestFile,FileFd::WriteAtomic);   
    FileFd To(Itm->DestFile,FileFd::WriteAtomic);   
    To.EraseOnFailure();
    To.EraseOnFailure();

+ 16 - 8
test/integration/framework

@@ -72,11 +72,15 @@ aptconfig() { runapt apt-config $*; }
 aptcache() { runapt apt-cache $*; }
 aptcache() { runapt apt-cache $*; }
 aptget() { runapt apt-get $*; }
 aptget() { runapt apt-get $*; }
 aptftparchive() { runapt apt-ftparchive $*; }
 aptftparchive() { runapt apt-ftparchive $*; }
+aptkey() { runapt apt-key $*; }
+dpkg() {
+	$(which dpkg) --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log $*
+}
 
 
 setupenvironment() {
 setupenvironment() {
 	TMPWORKINGDIRECTORY=$(mktemp -d)
 	TMPWORKINGDIRECTORY=$(mktemp -d)
 	local TESTDIR=$(readlink -f $(dirname $0))
 	local TESTDIR=$(readlink -f $(dirname $0))
-	msgninfo "Preparing environment for ${CCMD}$0${CINFO} in ${TMPWORKINGDIRECTORY}… "
+	msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
 	BUILDDIRECTORY="${TESTDIR}/../../build/bin"
 	BUILDDIRECTORY="${TESTDIR}/../../build/bin"
 	test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
 	test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
 	local OLDWORKINGDIRECTORY=$(pwd)
 	local OLDWORKINGDIRECTORY=$(pwd)
@@ -85,10 +89,10 @@ setupenvironment() {
 	cd $TMPWORKINGDIRECTORY
 	cd $TMPWORKINGDIRECTORY
 	mkdir rootdir aptarchive keys
 	mkdir rootdir aptarchive keys
 	cd rootdir
 	cd rootdir
-	mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache
-	mkdir -p var/log/apt var/lib/apt
+	mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d
+	mkdir -p var/cache var/lib var/log
 	mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers
 	mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers
-	local STATUSFILE=$(echo "$(basename $0)" | sed 's/^test-/status-/')
+	local STATUSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
 	if [ -f "${TESTDIR}/${STATUSFILE}" ]; then
 	if [ -f "${TESTDIR}/${STATUSFILE}" ]; then
 		cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status
 		cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status
 	else
 	else
@@ -98,7 +102,7 @@ setupenvironment() {
 	mkdir -p usr/lib/apt
 	mkdir -p usr/lib/apt
 	ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods
 	ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods
 	cd ..
 	cd ..
-	local PACKAGESFILE=$(echo "$(basename $0)" | sed 's/^test-/Packages-/')
+	local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
 	if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then
 	if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then
 		cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages
 		cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages
 	else
 	else
@@ -228,6 +232,10 @@ buildaptarchive() {
 
 
 createaptftparchiveconfig() {
 createaptftparchiveconfig() {
 	local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb$#\1#' | tr '\n' ' ')"
 	local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb$#\1#' | tr '\n' ' ')"
+	if [ -z "$ARCHS" ]; then
+		# the pool is empty, so we will operate on faked packages - let us use the configured archs
+		ARCHS="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
+	fi
 	echo -n 'Dir {
 	echo -n 'Dir {
 	ArchiveDir "' >> ftparchive.conf
 	ArchiveDir "' >> ftparchive.conf
 	echo -n $(readlink -f .) >> ftparchive.conf
 	echo -n $(readlink -f .) >> ftparchive.conf
@@ -297,7 +305,7 @@ buildaptftparchivedirectorystructure() {
 }
 }
 
 
 buildaptarchivefromincoming() {
 buildaptarchivefromincoming() {
-	msginfo "Build APT archive for ${CCMD}$0${CINFO} based on incoming packages…"
+	msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
 	cd aptarchive
 	cd aptarchive
 	[ -e pool ] || ln -s ../incoming pool
 	[ -e pool ] || ln -s ../incoming pool
 	[ -e ftparchive.conf ] || createaptftparchiveconfig
 	[ -e ftparchive.conf ] || createaptftparchiveconfig
@@ -314,7 +322,7 @@ buildaptarchivefromincoming() {
 }
 }
 
 
 buildaptarchivefromfiles() {
 buildaptarchivefromfiles() {
-	msginfo "Build APT archive for ${CCMD}$0${CINFO} based on prebuild files…"
+	msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
 	cd aptarchive
 	cd aptarchive
 	if [ -f Packages ]; then
 	if [ -f Packages ]; then
 		msgninfo "\tPackages file… "
 		msgninfo "\tPackages file… "
@@ -476,7 +484,7 @@ N: No packages found"
 	local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH_CPU)
 	local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH_CPU)
 	eval `apt-config shell ARCH APT::Architecture`
 	eval `apt-config shell ARCH APT::Architecture`
 	echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
 	echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
-	aptcache show $PACKAGE 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
+	aptcache show -q=0 $PACKAGE 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
 	rm $COMPAREFILE
 	rm $COMPAREFILE
 }
 }