libzypp: zypp/ZYppCommitPolicy.cc Source File

libzypp 17.25.10

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
30 class ZYppCommitPolicy::Impl
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;
44 DownloadMode _downloadMode;
45 target::rpm::RpmInstFlags _rpmInstFlags;
46 bool _syncPoolAfterCommit;
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
60 ZYppCommitPolicy::ZYppCommitPolicy()
61 : _pimpl( new Impl )
62 {}
63
64
65 ZYppCommitPolicy & ZYppCommitPolicy::restrictToMedia( unsigned mediaNr_r )
66 { _pimpl->_restrictToMedia = ( mediaNr_r == 1 ) ? 1 : 0; return *this; }
67
68 unsigned ZYppCommitPolicy::restrictToMedia() const
69 { return _pimpl->_restrictToMedia; }
70
71
72 ZYppCommitPolicy & ZYppCommitPolicy::dryRun( bool yesNo_r )
73 { _pimpl->_dryRun = yesNo_r; return *this; }
74
75 bool ZYppCommitPolicy::dryRun() const
76 { return _pimpl->_dryRun; }
77
78
79 ZYppCommitPolicy & ZYppCommitPolicy::downloadMode( DownloadMode val_r )
80 { _pimpl->_downloadMode = val_r; return *this; }
81
82 DownloadMode ZYppCommitPolicy::downloadMode() const
83 { return _pimpl->_downloadMode; }
84
85
86 ZYppCommitPolicy & ZYppCommitPolicy::rpmInstFlags( target::rpm::RpmInstFlags newFlags_r )
87 { _pimpl->_rpmInstFlags = newFlags_r; return *this; }
88
89 ZYppCommitPolicy & ZYppCommitPolicy::rpmNoSignature( bool yesNo_r )
90 { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_NOSIGNATURE, yesNo_r ); return *this; }
91
92 ZYppCommitPolicy & ZYppCommitPolicy::rpmExcludeDocs( bool yesNo_r )
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
98 bool ZYppCommitPolicy::rpmNoSignature() const
99 { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_NOSIGNATURE ); }
100
101 bool ZYppCommitPolicy::rpmExcludeDocs() const
102 { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_EXCLUDEDOCS ); }
103
104
105 ZYppCommitPolicy & ZYppCommitPolicy::syncPoolAfterCommit( bool yesNo_r )
106 { _pimpl->_syncPoolAfterCommit = yesNo_r; return *this; }
107
108 bool ZYppCommitPolicy::syncPoolAfterCommit() const
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
String.h
ZConfig.h
ZYppCommitPolicy.h
zypp::ZConfig
Interim helper class to collect global options and settings.
Definition: ZConfig.h:62
zypp::ZYppCommitPolicy::Impl
Definition: ZYppCommitPolicy.cc:31
zypp::ZYppCommitPolicy::Impl::_syncPoolAfterCommit
bool _syncPoolAfterCommit
Definition: ZYppCommitPolicy.cc:46
zypp::ZYppCommitPolicy::Impl::Impl
Impl()
Definition: ZYppCommitPolicy.cc:33
zypp::ZYppCommitPolicy::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition: ZYppCommitPolicy.cc:51
zypp::ZYppCommitPolicy::Impl::_dryRun
bool _dryRun
Definition: ZYppCommitPolicy.cc:43
zypp::ZYppCommitPolicy::Impl::_downloadMode
DownloadMode _downloadMode
Definition: ZYppCommitPolicy.cc:44
zypp::ZYppCommitPolicy::Impl::_rpmInstFlags
target::rpm::RpmInstFlags _rpmInstFlags
Definition: ZYppCommitPolicy.cc:45
zypp::ZYppCommitPolicy::Impl::_restrictToMedia
unsigned _restrictToMedia
Definition: ZYppCommitPolicy.cc:42
zypp::ZYppCommitPolicy
Options and policies for ZYpp::commit.
Definition: ZYppCommitPolicy.h:34
zypp::ZYppCommitPolicy::rpmInstFlags
ZYppCommitPolicy & rpmInstFlags(target::rpm::RpmInstFlags newFlags_r)
The default target::rpm::RpmInstFlags.
Definition: ZYppCommitPolicy.cc:86
zypp::ZYppCommitPolicy::syncPoolAfterCommit
ZYppCommitPolicy & syncPoolAfterCommit(bool yesNo_r)
Kepp pool in sync with the Target databases after commit (default: true)
Definition: ZYppCommitPolicy.cc:105
zypp::ZYppCommitPolicy::dryRun
ZYppCommitPolicy & dryRun(bool yesNo_r)
Set dry run (default: false).
Definition: ZYppCommitPolicy.cc:72
zypp::ZYppCommitPolicy::dryRun
bool dryRun() const
Definition: ZYppCommitPolicy.cc:75
zypp::ZYppCommitPolicy::restrictToMedia
ZYppCommitPolicy & restrictToMedia(unsigned mediaNr_r)
Restrict commit to media 1.
Definition: ZYppCommitPolicy.cc:65
zypp::ZYppCommitPolicy::ZYppCommitPolicy
ZYppCommitPolicy()
Definition: ZYppCommitPolicy.cc:60
zypp::ZYppCommitPolicy::downloadMode
DownloadMode downloadMode() const
Definition: ZYppCommitPolicy.cc:82
zypp::ZYppCommitPolicy::rpmNoSignature
bool rpmNoSignature() const
Definition: ZYppCommitPolicy.cc:98
zypp::ZYppCommitPolicy::rpmInstFlags
target::rpm::RpmInstFlags rpmInstFlags() const
Definition: ZYppCommitPolicy.cc:95
zypp::ZYppCommitPolicy::downloadMode
ZYppCommitPolicy & downloadMode(DownloadMode val_r)
Commit download policy to use.
Definition: ZYppCommitPolicy.cc:79
zypp::ZYppCommitPolicy::restrictToMedia
unsigned restrictToMedia() const
Definition: ZYppCommitPolicy.cc:68
zypp::ZYppCommitPolicy::rpmExcludeDocs
bool rpmExcludeDocs() const
Definition: ZYppCommitPolicy.cc:101
zypp::ZYppCommitPolicy::syncPoolAfterCommit
bool syncPoolAfterCommit() const
Definition: ZYppCommitPolicy.cc:108
zypp::ZYppCommitPolicy::_pimpl
RWCOW_pointer< Impl > _pimpl
Pointer to data.
Definition: ZYppCommitPolicy.h:95
str
String related utilities and Regular expression matching.
zypp::str::hexstring
std::string hexstring(char n, int w=4)
Definition: String.h:321
zypp::target::rpm::RPMINST_NOSIGNATURE
@ RPMINST_NOSIGNATURE
Definition: RpmFlags.h:47
zypp::target::rpm::RPMINST_EXCLUDEDOCS
@ RPMINST_EXCLUDEDOCS
Definition: RpmFlags.h:40
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
zypp::DownloadMode
DownloadMode
Supported commit download policies.
Definition: DownloadMode.h:23