summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire-item.h
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-06-13 11:13:45 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-06-15 14:39:37 +0200
commitd56e2917f27a722b54685de13aeb1bb7592fc61b (patch)
tree2ab5e8f7704050189851e0ba6b9cce97a129b7ce /apt-pkg/acquire-item.h
parentd2cb5b153fb13d587b1ff632cab34ce0c403326e (diff)
provide a public interface for acquiring changelogs
Provided is a specialized acquire item which given a version can figure out the correct URI to try by itself and if not provides an error message alongside with static methods to get just the URI it would try to download if it should just be displayed or similar such. The URI is constructed as follows: Release files can provide an URI template in the "Changelogs" field, otherwise we lookup a configuration item based on the "Label" or "Origin" of the Release file to get a (hopefully known) default value for now. This template should contain the string CHANGEPATH which is replaced with the information about the version we want the changelog for (e.g. main/a/apt/apt_1.1). This middleway was choosen as this path part was consistent over the three known implementations (+1 defunct), while the rest of the URI varies widely between them. The benefit of this construct is that it is now easy to get changelogs for Debian packages on Ubuntu and vice versa – even at the moment where the Changelogs field is present nowhere. Strictly better than what apt-get had before as it would even fail to get changelogs from security… Now it will notice that security identifies as Origin: Debian and pick this setting (assuming again that no Changelogs field exists). If on the other hand security would ship its changelogs in a different location we could set it via the Label option overruling Origin. Closes: 687147, 739854, 784027, 787190
Diffstat (limited to 'apt-pkg/acquire-item.h')
-rw-r--r--apt-pkg/acquire-item.h114
1 files changed, 114 insertions, 0 deletions
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index b6d569737..606fd4173 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -1031,6 +1031,120 @@ class pkgAcqArchive : public pkgAcquire::Item
std::string &StoreFilename);
};
/*}}}*/
+/** \brief Retrieve the changelog for the given version {{{
+ *
+ * Downloads the changelog to a temporary file it will also remove again
+ * while it is deconstructed or downloads it to a named location.
+ */
+class pkgAcqChangelog : public pkgAcquire::Item
+{
+ void *d;
+ std::string TemporaryDirectory;
+ std::string const SrcName;
+ std::string const SrcVersion;
+
+ public:
+ // we will never have hashes for changelogs.
+ // If you need verified ones, download the deb and extract the changelog.
+ virtual HashStringList GetExpectedHashes() const { return HashStringList(); }
+ virtual bool HashesRequired() const { return false; }
+
+ // Specialized action members
+ virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
+ virtual void Done(std::string const &Message, HashStringList const &CalcHashes,
+ pkgAcquire::MethodConfig const * const Cnf);
+ virtual std::string DescURI() const {return Desc.URI;};
+
+ /** returns the URI to the changelog of this version
+ *
+ * @param Ver is the version to get the changelog for
+ * @return the URI which will be used to acquire the changelog
+ */
+ static std::string URI(pkgCache::VerIterator const &Ver);
+
+ /** returns the URI to the changelog of this version
+ *
+ * \param Rls is the Release file the package comes from
+ * \param Component in which the package resides, can be empty
+ * \param SrcName is the source package name
+ * \param SrcVersion is the source package version
+ * @return the URI which will be used to acquire the changelog
+ */
+ static std::string URI(pkgCache::RlsFileIterator const &Rls,
+ char const * const Component, char const * const SrcName,
+ char const * const SrcVersion);
+
+ /** returns the URI to the changelog of this version
+ *
+ * \param Template URI where CHANGEPATH has to be filled in
+ * \param Component in which the package resides, can be empty
+ * \param SrcName is the source package name
+ * \param SrcVersion is the source package version
+ * @return the URI which will be used to acquire the changelog
+ */
+ static std::string URI(std::string const &Template,
+ char const * const Component, char const * const SrcName,
+ char const * const SrcVersion);
+
+ /** returns the URI template for this release file
+ *
+ * \param Rls is a Release file
+ * @return the URI template to use for this release file
+ */
+ static std::string URITemplate(pkgCache::RlsFileIterator const &Rls);
+
+ /** \brief Create a new pkgAcqChangelog object.
+ *
+ * \param Owner The pkgAcquire object with which this object is
+ * associated.
+ * \param Ver is the version to get the changelog for
+ * \param DestDir The directory the file should be downloaded into.
+ * Will be an autocreated (and cleaned up) temporary directory if not set.
+ * \param DestFilename The filename the file should have in #DestDir
+ * Defaults to sourcepackagename.changelog if not set.
+ */
+ pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::VerIterator const &Ver,
+ std::string const &DestDir="", std::string const &DestFilename="");
+
+ /** \brief Create a new pkgAcqChangelog object.
+ *
+ * \param Owner The pkgAcquire object with which this object is
+ * associated.
+ * \param Rls is the Release file the package comes from
+ * \param Component in which the package resides, can be empty
+ * \param SrcName is the source package name
+ * \param SrcVersion is the source package version
+ * \param DestDir The directory the file should be downloaded into.
+ * Will be an autocreated (and cleaned up) temporary directory if not set.
+ * \param DestFilename The filename the file should have in #DestDir
+ * Defaults to sourcepackagename.changelog if not set.
+ */
+ pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::RlsFileIterator const &Rls,
+ char const * const Component, char const * const SrcName, char const * const SrcVersion,
+ std::string const &DestDir="", std::string const &DestFilename="");
+
+ /** \brief Create a new pkgAcqChangelog object.
+ *
+ * \param Owner The pkgAcquire object with which this object is
+ * associated.
+ * \param URI is to be used to get the changelog
+ * \param SrcName is the source package name
+ * \param SrcVersion is the source package version
+ * \param DestDir The directory the file should be downloaded into.
+ * Will be an autocreated (and cleaned up) temporary directory if not set.
+ * \param DestFilename The filename the file should have in #DestDir
+ * Defaults to sourcepackagename.changelog if not set.
+ */
+ pkgAcqChangelog(pkgAcquire * const Owner, std::string const &URI,
+ char const * const SrcName, char const * const SrcVersion,
+ std::string const &DestDir="", std::string const &DestFilename="");
+
+ virtual ~pkgAcqChangelog();
+
+private:
+ APT_HIDDEN void Init(std::string const &DestDir, std::string const &DestFilename);
+};
+ /*}}}*/
/** \brief Retrieve an arbitrary file to the current directory. {{{
*
* The file is retrieved even if it is accessed via a URL type that