From 158fda31be7d4ae1c80a56223faa8d01efc25acc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 2 Sep 2010 12:22:33 +0200 Subject: add wrapper around dpkg to be able to use it easily in the tests --- test/integration/framework | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/integration/framework b/test/integration/framework index 8efe47330..ba5f9dfa3 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -72,6 +72,9 @@ aptconfig() { runapt apt-config $*; } aptcache() { runapt apt-cache $*; } aptget() { runapt apt-get $*; } aptftparchive() { runapt apt-ftparchive $*; } +dpkg() { + $(which dpkg) --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log $* +} setupenvironment() { TMPWORKINGDIRECTORY=$(mktemp -d) @@ -228,6 +231,10 @@ buildaptarchive() { 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' ' ')" + 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 { ArchiveDir "' >> ftparchive.conf echo -n $(readlink -f .) >> ftparchive.conf -- cgit v1.2.3 From b29c37128c2c77490f5851158a7631ed107c79fc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 2 Sep 2010 12:47:48 +0200 Subject: * 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) Easily done by moving a private method from pkgAcquire into the public area of fileutl.cc to be able to use it also in here --- apt-pkg/acquire.cc | 21 --------------------- apt-pkg/acquire.h | 8 -------- apt-pkg/contrib/fileutl.cc | 21 +++++++++++++++++++++ apt-pkg/contrib/fileutl.h | 9 +++++++++ apt-pkg/deb/dpkgpm.cc | 3 ++- debian/changelog | 5 ++++- test/integration/framework | 4 ++-- 7 files changed, 38 insertions(+), 33 deletions(-) diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 63825da93..6ec557397 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -93,27 +93,6 @@ bool pkgAcquire::Setup(pkgAcquireStatus *Progress, string const &Lock) 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 /*{{{*/ // --------------------------------------------------------------------- /* Free our memory, clean up the queues (destroy the workers) */ diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 82be8b843..e3a4435b8 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -362,14 +362,6 @@ class pkgAcquire private: /** \brief FD of the Lock file we acquire in Setup (if any) */ 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 diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 2b73d1424..94d994e8b 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -251,6 +251,27 @@ bool CreateDirectory(string const &Parent, string const &Path) return true; } /*}}}*/ +// 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 CheckDirectory(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 /*{{{*/ // --------------------------------------------------------------------- /* If an extension is given only files with this extension are included diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index cb4655798..f79c9032f 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -94,6 +94,15 @@ int GetLock(string File,bool Errors = true); bool FileExists(string File); bool DirectoryExists(string const &Path) __attrib_const; 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 CheckDirectory(string const &Parent, string const &Path); + std::vector GetListOfFilesInDir(string const &Dir, string const &Ext, bool const &SortList, bool const &AllowNoExt=false); std::vector GetListOfFilesInDir(string const &Dir, std::vector const &Ext, diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 5530ef129..d3c432ce1 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -641,7 +641,8 @@ void pkgDPkgPM::WriteHistoryTag(string const &tag, string value) bool pkgDPkgPM::OpenLog() { string const logdir = _config->FindDir("Dir::Log"); - if(not FileExists(logdir)) + if(CheckDirectory(logdir, logdir) == false) + // FIXME: use a better string after freeze return _error->Error(_("Directory '%s' missing"), logdir.c_str()); // get current time diff --git a/debian/changelog b/debian/changelog index e37a5504f..2a3a9d89c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -40,8 +40,11 @@ apt (0.8.1) UNRELEASED; urgency=low - let the pin origin actually work as advertised in the manpage which means "" are optional and pinning a local archive does work - even if it is a non-flat archive (Closes: #594435) + * 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) - -- Michael Vogt Mon, 30 Aug 2010 11:53:30 +0200 + -- David Kalnischkies Thu, 02 Sep 2010 12:41:32 +0200 apt (0.8.0) unstable; urgency=low diff --git a/test/integration/framework b/test/integration/framework index ba5f9dfa3..2b26fc8f7 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -88,8 +88,8 @@ setupenvironment() { cd $TMPWORKINGDIRECTORY mkdir rootdir aptarchive keys 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 local STATUSFILE=$(echo "$(basename $0)" | sed 's/^test-/status-/') if [ -f "${TESTDIR}/${STATUSFILE}" ]; then -- cgit v1.2.3 From e8379ba3b9e4d5ab3e2225252ca6fde1217fac28 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 2 Sep 2010 12:52:04 +0200 Subject: set the quiet value for apt-cache so the tests will actually see the notices as they will not be shown otherwise --- test/integration/framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/framework b/test/integration/framework index 2b26fc8f7..b5fc46865 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -483,7 +483,7 @@ N: No packages found" local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH_CPU) eval `apt-config shell ARCH APT::Architecture` 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 } -- cgit v1.2.3 From 3cbbda3c5af73f73b2d32b34078c4e6b9fef8a6e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 2 Sep 2010 13:03:38 +0200 Subject: show only the basename of the running test --- test/integration/framework | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/integration/framework b/test/integration/framework index b5fc46865..e55563544 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -79,7 +79,7 @@ dpkg() { setupenvironment() { TMPWORKINGDIRECTORY=$(mktemp -d) 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" test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first" local OLDWORKINGDIRECTORY=$(pwd) @@ -304,7 +304,7 @@ buildaptftparchivedirectorystructure() { } 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 [ -e pool ] || ln -s ../incoming pool [ -e ftparchive.conf ] || createaptftparchiveconfig @@ -321,7 +321,7 @@ buildaptarchivefromincoming() { } 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 if [ -f Packages ]; then msgninfo "\tPackages file… " -- cgit v1.2.3 From 99aa69c74f27a70d585510b817561fbf20ac7fb5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 2 Sep 2010 15:19:51 +0200 Subject: check for length of Data to avoid the validness of Pin: origin " (no error displayed). We already know in this method that Data is at least one char long, so we avoid the length counting as long as the string doesn't start with " --- apt-pkg/versionmatch.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index 17a54bc4c..c40b1fdbc 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -118,7 +118,7 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) 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); else OrSite = Data; -- cgit v1.2.3 From 2c6baa5a1f935eb3b8d4eb9fdef62e696416e27a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 2 Sep 2010 15:24:44 +0200 Subject: do the right thing(TM) even if the (unfinished) testcase is named skip-* instead of test-* to avoid calling him with run-tests --- test/integration/framework | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/framework b/test/integration/framework index e55563544..d832bedbe 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -91,7 +91,7 @@ setupenvironment() { 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 - 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 cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status else @@ -101,7 +101,7 @@ setupenvironment() { mkdir -p usr/lib/apt ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods 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 cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages else -- cgit v1.2.3 From 223b069806ea822e3fca2f5448108a7716ed7d98 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 3 Sep 2010 19:35:51 +0200 Subject: update the version number to the upcoming 0.8.2 and bump the release version of the library also --- apt-pkg/init.h | 2 +- configure.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apt-pkg/init.h b/apt-pkg/init.h index 6e7340dfe..15a1165b9 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -23,7 +23,7 @@ // See also buildlib/libversion.mak #define APT_PKG_MAJOR 4 #define APT_PKG_MINOR 10 -#define APT_PKG_RELEASE 0 +#define APT_PKG_RELEASE 1 extern const char *pkgVersion; extern const char *pkgLibVersion; diff --git a/configure.in b/configure.in index 8b212c1bc..b2880c99c 100644 --- a/configure.in +++ b/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) dnl -- SET THIS TO THE RELEASE VERSION -- -AC_DEFINE_UNQUOTED(VERSION,"0.7.26~exp6") +AC_DEFINE_UNQUOTED(VERSION,"0.8.2") PACKAGE="apt" AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE") AC_SUBST(PACKAGE) -- cgit v1.2.3 From 1dc03a8614454023ab8ed265465c061980cb9ea9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 4 Sep 2010 10:46:36 +0200 Subject: * apt-pkg/indexcopy.cc: - support really still the APT::GPGV::TrustedKeyring setting, as it breaks d-i badly otherwise (Closes: #595428) --- apt-pkg/indexcopy.cc | 2 +- apt-pkg/init.cc | 3 +-- debian/changelog | 5 ++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index a2a1d5934..ed037027c 100644 --- a/apt-pkg/indexcopy.cc +++ b/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"); // 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"); bool const Debug = _config->FindB("Debug::Acquire::gpgv", false); diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index 846b27313..f0bad78df 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -70,8 +70,7 @@ bool pkgInitConfig(Configuration &Cnf) Cnf.Set("Dir::Etc::parts","apt.conf.d"); Cnf.Set("Dir::Etc::preferences","preferences"); 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::Bin::methods","/usr/lib/apt/methods"); Cnf.Set("Dir::Media::MountPath","/media/apt"); diff --git a/debian/changelog b/debian/changelog index bed6a55c7..205777a01 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,8 +7,11 @@ apt (0.8.2) UNRELEASED; urgency=low * 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) - -- David Kalnischkies Fri, 03 Sep 2010 19:29:01 +0200 + -- David Kalnischkies Sat, 04 Sep 2010 10:45:45 +0200 apt (0.8.1) unstable; urgency=low -- cgit v1.2.3 From 1f8b2599f6beb14e8855f5d43fc1a759a08690e9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 4 Sep 2010 15:28:47 +0200 Subject: * 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 --- cmdline/apt-key | 2 ++ debian/changelog | 5 ++++- test/integration/framework | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmdline/apt-key b/cmdline/apt-key index 27731ef7d..b39ab12e4 100755 --- a/cmdline/apt-key +++ b/cmdline/apt-key @@ -147,11 +147,13 @@ else #echo "generate list" TRUSTEDFILE="/etc/apt/trusted.gpg" eval $(apt-config shell TRUSTEDFILE Apt::GPGV::TrustedKeyring) + eval $(apt-config shell TRUSTEDFILE Dir::Etc::Trusted/f) if [ -r "$TRUSTEDFILE" ]; then GPG="$GPG --keyring $TRUSTEDFILE" fi GPG="$GPG --primary-keyring $TRUSTEDFILE" TRUSTEDPARTS="/etc/apt/trusted.gpg.d" + eval $(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d) if [ -d "$TRUSTEDPARTS" ]; then #echo "parts active" for trusted in $(run-parts --list $TRUSTEDPARTS --regex '^.*\.gpg$'); do diff --git a/debian/changelog b/debian/changelog index 205777a01..4dca62603 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,8 +10,11 @@ apt (0.8.2) UNRELEASED; urgency=low * 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 - -- David Kalnischkies Sat, 04 Sep 2010 10:45:45 +0200 + -- David Kalnischkies Sat, 04 Sep 2010 15:25:10 +0200 apt (0.8.1) unstable; urgency=low diff --git a/test/integration/framework b/test/integration/framework index d832bedbe..8a5973d4b 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -72,6 +72,7 @@ aptconfig() { runapt apt-config $*; } aptcache() { runapt apt-cache $*; } aptget() { runapt apt-get $*; } 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 $* } -- cgit v1.2.3 From cf1cdb3328dacde829db8bbb3db4f5373ac07d61 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 6 Sep 2010 12:17:15 +0200 Subject: * methods/{gzip,bzip2}.cc: - empty files can never be valid archives (Closes: #595691) --- debian/changelog | 4 +++- methods/bzip2.cc | 9 +++------ methods/gzip.cc | 9 +++------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/debian/changelog b/debian/changelog index 4dca62603..07196db25 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,8 +13,10 @@ apt (0.8.2) UNRELEASED; urgency=low * 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) - -- David Kalnischkies Sat, 04 Sep 2010 15:25:10 +0200 + -- David Kalnischkies Mon, 06 Sep 2010 12:16:58 +0200 apt (0.8.1) unstable; urgency=low diff --git a/methods/bzip2.cc b/methods/bzip2.cc index 241f21c66..c668141a2 100644 --- a/methods/bzip2.cc +++ b/methods/bzip2.cc @@ -56,12 +56,9 @@ bool Bzip2Method::Fetch(FetchItem *Itm) // Open the source and destination files 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]; if (pipe(GzOut) < 0) diff --git a/methods/gzip.cc b/methods/gzip.cc index 5b9b66b50..22cae9424 100644 --- a/methods/gzip.cc +++ b/methods/gzip.cc @@ -48,12 +48,9 @@ bool GzipMethod::Fetch(FetchItem *Itm) // Open the source and destination files 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); To.EraseOnFailure(); -- cgit v1.2.3 From 7753e4684e2b80abbed296b90f47be12b4fce8fc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 6 Sep 2010 14:10:26 +0200 Subject: rename the newly public CheckDirectory method to CreateAPTDirectoryIfNeeded to give a better indication what this method will do if called. --- apt-pkg/acquire.cc | 8 ++++---- apt-pkg/contrib/fileutl.cc | 4 ++-- apt-pkg/contrib/fileutl.h | 2 +- apt-pkg/deb/dpkgpm.cc | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 6ec557397..9478cdfb4 100644 --- a/apt-pkg/acquire.cc +++ b/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 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()); - 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()); if (Lock.empty() == true || _config->FindB("Debug::NoLocking", false) == true) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 94d994e8b..eabaadf90 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -251,11 +251,11 @@ bool CreateDirectory(string const &Parent, string const &Path) return true; } /*}}}*/ -// CheckDirectory - ensure that the given directory exists /*{{{*/ +// 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 CheckDirectory(string const &Parent, string const &Path) +bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path) { if (DirectoryExists(Path) == true) return true; diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index f79c9032f..419506273 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -101,7 +101,7 @@ bool CreateDirectory(string const &Parent, string const &Path); * /apt/ will be removed before CreateDirectory call. * \param Path which should exist after (successful) call */ -bool CheckDirectory(string const &Parent, string const &Path); +bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path); std::vector GetListOfFilesInDir(string const &Dir, string const &Ext, bool const &SortList, bool const &AllowNoExt=false); diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index d3c432ce1..395c3fb1a 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -641,7 +641,7 @@ void pkgDPkgPM::WriteHistoryTag(string const &tag, string value) bool pkgDPkgPM::OpenLog() { string const logdir = _config->FindDir("Dir::Log"); - if(CheckDirectory(logdir, logdir) == false) + if(CreateAPTDirectoryIfNeeded(logdir, logdir) == false) // FIXME: use a better string after freeze return _error->Error(_("Directory '%s' missing"), logdir.c_str()); -- cgit v1.2.3