libzypp  17.7.0
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 
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
DownloadMode downloadMode() const
ZYppCommitPolicy & rpmInstFlags(target::rpm::RpmInstFlags newFlags_r)
The default target::rpm::RpmInstFlags.
ZYppCommitPolicy & dryRun(bool yesNo_r)
Set dry run (default: false).
String related utilities and Regular expression matching.
target::rpm::RpmInstFlags rpmInstFlags() const
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
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:59
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.
Impl * clone() const
clone for RWCOW_pointer
RWCOW_pointer< Impl > _pimpl
Pointer to data.
bool syncPoolAfterCommit() const
target::rpm::RpmInstFlags _rpmInstFlags
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
std::string hexstring(char n, int w=4)
Definition: String.h:323
unsigned restrictToMedia() const
DownloadMode
Supported commit download policies.
Definition: DownloadMode.h:22