/usr/include/x86_64-linux-gnu/zypp/Fetcher.h is in libzypp-dev 14.29.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | /*---------------------------------------------------------------------\
| ____ _ __ __ ___ |
| |__ / \ / / . \ . \ |
| / / \ V /| _/ _/ |
| / /__ | | | | | | |
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
/** \file zypp/Fetcher.h
*
*/
#ifndef ZYPP_FETCHER_H
#define ZYPP_FETCHER_H
#include <iosfwd>
#include <list>
#include "zypp/base/Flags.h"
#include "zypp/base/PtrTypes.h"
#include "zypp/Pathname.h"
#include "zypp/Url.h"
#include "zypp/OnMediaLocation.h"
#include "zypp/Digest.h"
#include "zypp/MediaSetAccess.h"
#include "zypp/FileChecker.h"
#include "zypp/ProgressData.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
/**
* This class allows to retrieve a group of files in a confortable
* way, providing some smartness that does not belong to the
* media layer like:
*
* \li Configurable local caches to retrieve already
* donwloaded files.
* \li File checkers that can check for right checksums
* digital signatures, etc.
*
* \code
* MediaSetAccess access(url, path);
* Fetcher fetcher;
* fetcher.enqueue( OnMediaLocation().setLocation("/somefile") );
* fetcher.addCachePath("/tmp/cache")
* fetcher.start( "/download-dir, access );
* fetcher.reset();
* \endcode
*
* To use the checkers. just create a functor implementing
* bool operator()(const Pathname &file) \see FileChecker.
* Pass the necessary validation data in the constructor
* of the functor, and pass the object to the \ref enqueue
* method.
*
* \code
* ChecksumFileChecker checker(CheckSum("sha1", "....");
* fetcher.enqueue( location, checker);
* \endcode
*
* If you need to use more than one checker
* \see CompositeFileChecker
*
* Additionally, you can automatically enqueue a job
* with a checksum checker by using \ref enqueueDigested
* which will use the \ref OnMediaLocation checksum
* automatically.
*
* \code
* location.setChecksum(CheckSum("sha1", "...."));
* fetcher.enqueueDigested(location);
* \endcode
*
* \note If the checksum of the location is empty, but
* \ref enqueueDigested is used, then the user will get a
* warning that the file has no checksum.
*
* Additionally, Fetcher supports checking the downloaded
* content by using signed indexes on the remote side.
*
* \code
* MediaSetAccess access(url, path);
* Fetcher fetcher;
* fetcher.addIndex(OnMediaLocation("/content"));
* fetcher.enqueue( OnMediaLocation().setLocation("/somefile") );
* fetcher.start( "/download-dir, access );
* fetcher.reset();
* \endcode
*
* Indexes are supported in CHECKSUMS format (simple text file)
* with checksum and file name, or content file, whith
* HASH SHA1 line entries.
*
* \note The indexes file names are relative to the directory
* where the index is.
*
* \note libzypp-11.x: Introduction of sha256 lead to the insight
* that using SHA1SUMS as filename was a bad choice. New media store
* the checksums in a CHECKSUMS file. If a CHECKSUMS file is not
* present, we fall back looking for a SHA1SUMS file. The checksum
* type (md5,sha1,sha256) is auto detected by looking at the cheksums
* length. No need to somehow encode it in the filename.
*/
class Fetcher
{
friend std::ostream & operator<<( std::ostream & str,
const Fetcher & obj );
public:
/** Implementation */
class Impl;
public:
/**
* Various option flags to change behavior
*/
enum Option
{
/**
* If a content file is found, it is
* downloaded and read.
*/
AutoAddContentFileIndexes = 0x0001,
/**
* If a CHECKSUMS file is found, it is
* downloaded and read.
*/
AutoAddChecksumsIndexes = 0x0002,
/**
* If a content or CHECKSUMS file is found,
* it is downloaded and read.
*/
AutoAddIndexes = AutoAddContentFileIndexes | AutoAddChecksumsIndexes,
};
ZYPP_DECLARE_FLAGS(Options, Option);
/** Default ctor */
Fetcher();
/** Dtor */
virtual ~Fetcher();
public:
/**
* Set the Fetcher options
* \see Fetcher::Options
*/
void setOptions( Options options );
/**
* Get current options
* \see Fetcher::Options
*/
Options options() const;
/**
* Adds an index containing metadata (for example
* checksums ) that will be retrieved and read
* before the job processing starts.
*
* Nothing will be transferred or checked
* until \ref start() is called.
*
* The index is relative to the media path, and
* the listed files too.
*
* Indexes in the SHA1SUM format, and YaST
* content file
*
* The file has to be signed or the user will be
* warned that the file is unsigned. You can
* place the signature next to the file adding the
* .asc extension.
*
* If you expect the key to not to be in the target
* system, then you can place it next to the index
* using adding the .key extension.
*
*/
void addIndex( const OnMediaLocation &resource );
/**
* Enqueue a object for transferal, they will not
* be transferred until \ref start() is called
*
*/
void enqueue( const OnMediaLocation &resource,
const FileChecker &checker = FileChecker() );
/**
* Enqueue a object for transferal, they will not
* be transferred until \ref start() is called
*
* \note As \ref OnMediaLocation contains the digest information,
* a \ref ChecksumFileChecker is automatically added to the
* transfer job, so make sure you don't add another one or
* the user could be asked twice.
*
* \todo FIXME implement checker == operator to avoid this.
*
* the optional deltafile argument describes a file that can
* be used for delta download algorithms. Usable files are
* uncompressed files or files compressed with gzip --rsyncable.
* Other files like rpms do not work, as the compression
* breaks the delta algorithm.
*/
void enqueueDigested( const OnMediaLocation &resource,
const FileChecker &checker = FileChecker(), const Pathname &deltafile = Pathname());
/**
* Enqueue a directory
*
* As the files to be enqueued are not known
* in advance, all files whose checksum can
* be found in some index are enqueued with
* checksum checking. Otherwise they are not.
*
* Some index may provide
* the checksums, either by \ref addIndex or
* using \ref AutoAddIndexes flag.
*
* Files are checked by providing a
* CHECKSUMS or content file listing
* <checksum> filename
* and a respective CHECKSUMS.asc/content.asc which has
* the signature for the checksums.
*
* If you expect the user to not have the key of
* the signature either in the trusted or untrusted
* keyring, you can offer it as CHECKSUMS.key (or content.key)
*
* \param recursive True if the complete tree should
* be enqueued.
*
* \note As \ref checksums are read from the index,
* a \ref ChecksumFileChecker is automatically added to
* transfer jobs having a checksum available,
* so make sure you don't add another one or
* the user could be asked twice.
*
* \note The format of the file CHECKSUMS is the output of:
* ls | grep -v CHECKSUMS | xargs sha256sum > CHECKSUMS
* in each subdirectory.
*
* \note Every file CHECKSUMS.* except of CHECKSUMS.(asc|key|(void)) will
* not be transferred and will be ignored.
*
*/
void enqueueDir( const OnMediaLocation &resource,
bool recursive = false,
const FileChecker &checker = FileChecker() );
/**
* Enqueue a directory and always check for
* checksums.
*
* As the files to be enqueued are not known
* in advance, all files are enqueued with
* checksum checking. If the checksum of some file is
* not in some index, then there will be a verification
* warning ( \ref DigestReport ).
*
* Therefore some index will need to provide
* the checksums, either by \ref addIndex or
* using \ref AutoAddIndexes flag.
*
* Files are checked by providing a
* CHECKSUMS or content file listing
* <checksum> filename
* and a respective CHECKSUMS.asc/content.asc which has
* the signature for the checksums.
*
* If you expect the user to not have the key of
* the signature either in the trusted or untrusted
* keyring, you can offer it as CHECKSUMS.key (or content.key)
*
* \param recursive True if the complete tree should
* be enqueued.
*
* \note As \ref checksums are read from the index,
* a \ref ChecksumFileChecker is automatically added to every
* transfer job, so make sure you don't add another one or
* the user could be asked twice.
*
* \note The format of the file CHECKSUMS is the output of:
* ls | grep -v CHECKSUMS | xargs sha256sum > CHECKSUMS
* in each subdirectory.
*
* \note Every file CHECKSUMS.* except of CHECKSUMS.(asc|key|(void)) will
* not be transferred and will be ignored.
*
*/
void enqueueDigestedDir( const OnMediaLocation &resource,
bool recursive = false,
const FileChecker &checker = FileChecker() );
/**
* adds a directory to the list of directories
* where to look for cached files
*/
void addCachePath( const Pathname &cache_dir );
/**
* Reset the transfer (jobs) list
* \note It does not reset the cache directory list
*/
void reset();
/**
* start the transfer to a destination directory
* \a dest_dir
* You have to provde a media set access
* \a media to get the files from
* The file tree will be replicated inside this
* directory
*
*/
void start( const Pathname &dest_dir,
MediaSetAccess &media,
const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
private:
/** Pointer to implementation */
RWCOW_pointer<Impl> _pimpl;
};
///////////////////////////////////////////////////////////////////
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Fetcher::Options);
/** \relates Fetcher Stream output */
std::ostream & operator<<( std::ostream & str, const Fetcher & obj );
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_FETCHER_H
|