libzypp
11.13.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
libzypp
Welcome to libzypp
Code Pitfalls - Frequently made mistakes
Code Snippets
Environment Variables
Testing for provided features.
Notes on revisions
Extending ZYpp: Plugins and Hooks
Services
Solver - Vendor protection
Writing and tunning testcases
Libzypp and threads
Todo List
Deprecated List
Modules
Namespaces
Classes
Files
File List
zypp
base
media
misc
parser
pool
repo
sat
solver
target
thread
ui
url
ws
zypp_detail
ZYppImpl.cc
ZYppImpl.h
ZYppReadOnlyHack.h
APIConfig.h
Arch.cc
Arch.h
AutoDispose.h
Bit.h
ByteCount.cc
ByteCount.h
Callback.h
Capabilities.cc
Capabilities.h
Capability.cc
Capability.h
CapMatch.cc
CapMatch.h
Changelog.cc
Changelog.h
CheckSum.cc
CheckSum.h
CountryCode.cc
CountryCode.h
Date.cc
Date.h
Dep.cc
Dep.h
Digest.cc
Digest.h
DiskUsage.cc
DiskUsage.h
DiskUsageCounter.cc
DiskUsageCounter.h
DownloadMode.cc
DownloadMode.h
Edition.cc
Edition.h
ExternalProgram.cc
ExternalProgram.h
Fetcher.cc
Fetcher.h
FileChecker.cc
FileChecker.h
Filter.h
Glob.cc
Glob.h
HistoryLog.cc
HistoryLog.h
HistoryLogData.cc
HistoryLogData.h
IdString.cc
IdString.h
IdStringType.h
InstanceId.cc
InstanceId.h
KeyContext.h
KeyRing.cc
KeyRing.h
KVMap.h
LanguageCode.cc
LanguageCode.h
Locale.cc
Locale.h
Locks.cc
Locks.h
ManagedFile.h
MediaProducts.cc
MediaProducts.h
MediaSetAccess.cc
MediaSetAccess.h
Misc.h
OnMediaLocation.cc
OnMediaLocation.h
Package.cc
Package.h
PackageKeyword.h
Patch.cc
Patch.h
PathInfo.cc
PathInfo.h
Pathname.cc
Pathname.h
Pattern.cc
Pattern.h
PluginFrame.cc
PluginFrame.h
PluginFrameException.cc
PluginFrameException.h
PluginScript.cc
PluginScript.h
PluginScriptException.cc
PluginScriptException.h
PoolItem.cc
PoolItem.h
PoolItemBest.cc
PoolItemBest.h
PoolQuery.cc
PoolQuery.h
PoolQueryResult.cc
PoolQueryResult.h
PoolQueryUtil.tcc
ProblemSolution.cc
ProblemSolution.h
ProblemTypes.h
Product.cc
Product.h
ProgressData.cc
ProgressData.h
ProvideFilePolicy.cc
ProvideFilePolicy.h
PublicKey.cc
PublicKey.h
Range.cc
Range.h
Rel.cc
Rel.h
RelCompare.h
RepoInfo.cc
RepoInfo.h
RepoManager.cc
RepoManager.h
Repository.cc
Repository.h
RepoStatus.cc
RepoStatus.h
ResFilters.h
ResKind.cc
ResKind.h
ResObject.cc
ResObject.h
ResObjects.h
Resolvable.cc
Resolvable.h
Resolver.cc
Resolver.h
ResolverProblem.cc
ResolverProblem.h
ResPool.cc
ResPool.h
ResPoolProxy.cc
ResPoolProxy.h
ResStatus.cc
ResStatus.h
ResTraits.h
ServiceInfo.cc
ServiceInfo.h
Signature.cc
Signature.h
SrcPackage.cc
SrcPackage.h
SysContent.cc
SysContent.h
Target.cc
Target.h
TmpPath.cc
TmpPath.h
TriBool.h
Url.cc
Url.h
Vendor.h
VendorAttr.cc
VendorAttr.h
VendorSupportOptions.cc
VendorSupportOptions.h
ZConfig.cc
ZConfig.h
ZYpp.cc
ZYpp.h
ZYppCallbacks.h
ZYppCommit.h
ZYppCommitPolicy.cc
ZYppCommitPolicy.h
ZYppCommitResult.cc
ZYppCommitResult.h
ZYppFactory.cc
ZYppFactory.h
File Members
ZYppImpl.cc
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
13
#include <iostream>
14
#include "
zypp/TmpPath.h
"
15
#include "
zypp/base/Logger.h
"
16
#include "
zypp/base/String.h
"
17
18
#include "
zypp/zypp_detail/ZYppImpl.h
"
19
#include "
zypp/solver/detail/Helper.h
"
20
#include "
zypp/target/TargetImpl.h
"
21
#include "
zypp/ZYpp.h
"
22
#include "
zypp/DiskUsageCounter.h
"
23
#include "
zypp/ZConfig.h
"
24
#include "
zypp/sat/Pool.h
"
25
#include "
zypp/PoolItem.h
"
26
27
using
std::endl;
28
30
namespace
zypp
31
{
32
33
namespace
zypp_detail
34
{
35
37
//
38
// METHOD NAME : ZYppImpl::ZYppImpl
39
// METHOD TYPE : Constructor
40
//
41
ZYppImpl::ZYppImpl
()
42
: _target(0)
43
, _resolver( new
Resolver
(
ResPool
::instance()) )
44
{
45
ZConfig::instance
().
about
(
MIL
);
46
MIL
<<
"Initializing keyring..."
<< std::endl;
47
_keyring
=
new
KeyRing
(
tmpPath
());
48
}
49
51
//
52
// METHOD NAME : ZYppImpl::~ZYppImpl
53
// METHOD TYPE : Destructor
54
//
55
ZYppImpl::~ZYppImpl
()
56
{}
57
58
//------------------------------------------------------------------------
59
// add/remove resolvables
60
61
DiskUsageCounter::MountPointSet
ZYppImpl::diskUsage
()
62
{
63
if
( !
_disk_usage
)
64
{
65
setPartitions
(
DiskUsageCounter::detectMountPoints
() );
66
}
67
return
_disk_usage
->disk_usage(
pool
());
68
}
69
70
void
ZYppImpl::setPartitions
(
const
DiskUsageCounter::MountPointSet
&mp)
71
{
72
_disk_usage
.reset(
new
DiskUsageCounter
());
73
_disk_usage
->setMountPoints(mp);
74
}
75
76
DiskUsageCounter::MountPointSet
ZYppImpl::getPartitions
()
const
77
{
78
if
(
_disk_usage
)
79
return
_disk_usage
->getMountPoints();
80
else
81
return
DiskUsageCounter::detectMountPoints
();
82
}
83
84
//------------------------------------------------------------------------
85
// target
86
87
Target_Ptr
ZYppImpl::target
()
const
88
{
89
if
(!
_target
)
90
ZYPP_THROW
(
Exception
(
"Target not initialized."
));
91
return
_target
;
92
}
93
94
void
ZYppImpl::initializeTarget
(
const
Pathname & root,
bool
doRebuild_r )
95
{
96
MIL
<<
"initTarget( "
<< root << (doRebuild_r?
", rebuilddb"
:
""
) <<
")"
<< endl;
97
if
(
_target
) {
98
if
(
_target
->root() == root) {
99
MIL
<<
"Repeated call to initializeTarget()"
<< endl;
100
return
;
101
}
102
103
_target
->unload();
104
105
}
106
_target
=
new
Target
( root, doRebuild_r );
107
_target
->buildCache();
108
}
109
110
void
ZYppImpl::finishTarget
()
111
{
112
if
(
_target
)
113
_target
->unload();
114
115
_target
= 0;
116
}
117
118
//------------------------------------------------------------------------
119
// commit
120
123
ZYppCommitResult
ZYppImpl::commit
(
const
ZYppCommitPolicy
& policy_r )
124
{
125
setenv(
"ZYPP_IS_RUNNING"
,
str::numstring
(getpid()).c_str(), 1 );
126
127
if
( getenv(
"ZYPP_TESTSUITE_FAKE_ARCH"
) )
128
{
129
ZYPP_THROW
(
Exception
(
"ZYPP_TESTSUITE_FAKE_ARCH set. Commit not allowed and disabled."
) );
130
}
131
132
MIL
<<
"Attempt to commit ("
<< policy_r <<
")"
<< endl;
133
if
(!
_target
)
134
ZYPP_THROW
(
Exception
(
"Target not initialized."
) );
135
136
ZYppCommitResult
res =
_target
->_pimpl->commit(
pool
(), policy_r );
137
138
if
(! policy_r.
dryRun
() )
139
{
140
if
( policy_r.
syncPoolAfterCommit
() )
141
{
142
// reload new status from target
143
DBG
<<
"reloading "
<<
sat::Pool::instance
().
systemRepoAlias
() <<
" repo to pool"
<< endl;
144
_target
->load();
145
}
146
else
147
{
148
DBG
<<
"unloading "
<<
sat::Pool::instance
().
systemRepoAlias
() <<
" repo from pool"
<< endl;
149
_target
->unload();
150
}
151
}
152
153
MIL
<<
"Commit ("
<< policy_r <<
") returned: "
154
<< res << endl;
155
return
res;
156
}
157
158
void
ZYppImpl::installSrcPackage
(
const
SrcPackage_constPtr & srcPackage_r )
159
{
160
if
(!
_target
)
161
ZYPP_THROW
(
Exception
(
"Target not initialized."
) );
162
_target
->_pimpl->installSrcPackage( srcPackage_r );
163
}
164
165
//------------------------------------------------------------------------
166
// target store path
167
168
Pathname
ZYppImpl::homePath
()
const
169
{
return
_home_path
.empty() ? Pathname(
"/var/lib/zypp"
) :
_home_path
; }
170
171
void
ZYppImpl::setHomePath
(
const
Pathname & path )
172
{
_home_path
= path; }
173
174
Pathname
ZYppImpl::tmpPath
()
const
175
{
176
static
TmpDir
zypp_tmp_dir( TmpPath::defaultLocation(),
"zypp."
);
177
return
zypp_tmp_dir.
path
();
178
}
179
180
/******************************************************************
181
**
182
** FUNCTION NAME : operator<<
183
** FUNCTION TYPE : std::ostream &
184
*/
185
std::ostream &
operator<<
( std::ostream & str,
const
ZYppImpl
& obj )
186
{
187
return
str <<
"ZYppImpl"
;
188
}
189
191
}
// namespace zypp_detail
194
}
// namespace zypp
zypp
zypp_detail
ZYppImpl.cc
Generated by
1.8.1