1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
11 #include "zypp/base/String.h"
12 #include "zypp/base/Logger.h"
13 #include "zypp/base/Gettext.h"
15 #include "Downloader.h"
16 #include "zypp/KeyContext.h"
17 #include "zypp/ZYppCallbacks.h"
26 Downloader::Downloader()
29 Downloader::Downloader(const RepoInfo & repoinfo) : _repoinfo(repoinfo)
32 Downloader::~Downloader()
36 RepoStatus Downloader::status( MediaSetAccess &media )
38 WAR << "Non implemented" << endl;
42 void Downloader::download( MediaSetAccess &media,
43 const Pathname &dest_dir,
44 const ProgressData::ReceiverFnc & progress )
46 WAR << "Non implemented" << endl;
49 void Downloader::defaultDownloadMasterIndex( MediaSetAccess & media_r, const Pathname & destdir_r, const Pathname & masterIndex_r )
51 Pathname sigpath = masterIndex_r.extend( ".asc" );
52 Pathname keypath = masterIndex_r.extend( ".key" );
54 // always download them, even if repoGpgCheck is disabled
55 enqueue( OnMediaLocation( sigpath, 1 ).setOptional( true ).setDownloadSize( ByteCount( 20, ByteCount::MB ) ) );
56 enqueue( OnMediaLocation( keypath, 1 ).setOptional( true ).setDownloadSize( ByteCount( 20, ByteCount::MB ) ) );
57 start( destdir_r, media_r );
60 FileChecker checker; // set to sigchecker if appropriate, else Null.
61 SignatureFileChecker sigchecker;
62 bool isSigned = PathInfo(destdir_r / sigpath).isExist();
64 if ( repoInfo().repoGpgCheck() )
66 if ( isSigned || repoInfo().repoGpgCheckIsMandatory() )
68 // only add the signature if it exists
70 sigchecker = SignatureFileChecker( destdir_r / sigpath );
73 context.setRepoInfo( repoInfo() );
74 // only add the key if it exists
75 if ( PathInfo(destdir_r / keypath).isExist() )
76 sigchecker.addPublicKey( destdir_r / keypath, context );
78 // set the checker context even if the key is not known (unsigned repo, key
79 // file missing; bnc #495977)
80 sigchecker.setKeyContext( context );
82 checker = FileChecker( ref(sigchecker) ); // ref() to the local sigchecker is important as we want back fileValidated!
86 WAR << "Accept unsigned repository because repoGpgCheck is not mandatory for " << repoInfo().alias() << endl;
91 WAR << "Signature checking disabled in config of repository " << repoInfo().alias() << endl;
94 enqueue( OnMediaLocation( masterIndex_r, 1 ).setDownloadSize( ByteCount( 20, ByteCount::MB ) ), checker ? checker : FileChecker(NullFileChecker()) );
95 start( destdir_r, media_r );
99 _repoinfo.setMetadataPath( destdir_r );
101 _repoinfo.setValidRepoSignature( sigchecker.fileValidated() );
103 _repoinfo.setValidRepoSignature( indeterminate );