libzypp  13.10.6
ZYppCommitPolicy.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #include <iostream>
14 
15 #include "zypp/base/String.h"
16 
17 #include "zypp/ZConfig.h"
18 #include "zypp/ZYppCommitPolicy.h"
19 
21 namespace zypp
22 {
23 
25  //
26  // CLASS NAME : ZYppCommitPolicy::Impl
27  //
29 
31  {
32  public:
33  Impl()
34  : _restrictToMedia ( 0 )
35  , _dryRun ( false )
36  , _downloadMode ( ZConfig::instance().commit_downloadMode() )
37  , _rpmInstFlags ( ZConfig::instance().rpmInstallFlags() )
38  , _syncPoolAfterCommit ( true )
39  {}
40 
41  public:
42  unsigned _restrictToMedia;
43  bool _dryRun;
45  target::rpm::RpmInstFlags _rpmInstFlags;
47 
48  private:
49  friend Impl * rwcowClone<Impl>( const Impl * rhs );
51  Impl * clone() const { return new Impl( *this ); }
52  };
53 
55  //
56  // CLASS NAME : ZYppCommitPolicy
57  //
59 
61  : _pimpl( new Impl )
62  {}
63 
64 
66  { _pimpl->_restrictToMedia = ( mediaNr_r == 1 ) ? 1 : 0; return *this; }
67 
69  { return _pimpl->_restrictToMedia; }
70 
71 
73  { _pimpl->_dryRun = yesNo_r; return *this; }
74 
76  { return _pimpl->_dryRun; }
77 
78 
80  { _pimpl->_downloadMode = val_r; return *this; }
81 
83  { return _pimpl->_downloadMode; }
84 
85 
86  ZYppCommitPolicy & ZYppCommitPolicy::rpmInstFlags( target::rpm::RpmInstFlags newFlags_r )
87  { _pimpl->_rpmInstFlags = newFlags_r; return *this; }
88 
90  { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_NOSIGNATURE, yesNo_r ); return *this; }
91 
93  { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS, yesNo_r ); return *this; }
94 
95  target::rpm::RpmInstFlags ZYppCommitPolicy::rpmInstFlags() const
96  { return _pimpl->_rpmInstFlags; }
97 
99  { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_NOSIGNATURE ); }
100 
102  { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_EXCLUDEDOCS ); }
103 
104 
106  { _pimpl->_syncPoolAfterCommit = yesNo_r; return *this; }
107 
109  { return _pimpl->_syncPoolAfterCommit; }
110 
111 
112  std::ostream & operator<<( std::ostream & str, const ZYppCommitPolicy & obj )
113  {
114  str << "CommitPolicy(";
115  if ( obj.restrictToMedia() )
116  str << " restrictToMedia:" << obj.restrictToMedia();
117  if ( obj.dryRun() )
118  str << " dryRun";
119  str << " " << obj.downloadMode();
120  if ( obj.syncPoolAfterCommit() )
121  str << " syncPoolAfterCommit";
122  if ( obj.rpmInstFlags() )
123  str << " rpmInstFlags{" << str::hexstring(obj.rpmInstFlags()) << "}";
124  return str << " )";
125  }
126 
128 } // namespace zypp
ZYppCommitPolicy & rpmInstFlags(target::rpm::RpmInstFlags newFlags_r)
The default target::rpm::RpmInstFlags.
ZYppCommitPolicy & dryRun(bool yesNo_r)
Set dry run (default: false).
bool rpmNoSignature() const
bool syncPoolAfterCommit() const
unsigned restrictToMedia() const
DownloadMode downloadMode() const
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
Options and policies for ZYpp::commit.
ZYppCommitPolicy & downloadMode(DownloadMode val_r)
Commit download policy to use.
Interim helper class to collect global options and settings.
Definition: ZConfig.h:58
ZYppCommitPolicy & syncPoolAfterCommit(bool yesNo_r)
Kepp pool in sync with the Target databases after commit (default: true)
ZYppCommitPolicy & restrictToMedia(unsigned mediaNr_r)
Restrict commit to media 1.
target::rpm::RpmInstFlags rpmInstFlags() const
RWCOW_pointer< Impl > _pimpl
Pointer to data.
Impl * clone() const
clone for RWCOW_pointer
target::rpm::RpmInstFlags _rpmInstFlags
std::string hexstring(char n, int w=4)
Definition: String.h:254
DownloadMode
Supported commit download policies.
Definition: DownloadMode.h:22