1
/* rpackagecache.cc - package cache wrapper
3
* Copyright (c) 2000, 2001 Conectiva S/A
5
* Author: Alfredo K. Kojima <kojima@conectiva.com.br>
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License as
9
* published by the Free Software Foundation; either version 2 of the
10
* License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26
#include "rpackagecache.h"
30
#include <apt-pkg/error.h>
31
#include <apt-pkg/sourcelist.h>
32
#include <apt-pkg/pkgcachegen.h>
33
#include <apt-pkg/configuration.h>
35
# include <apt-pkg/systemfactory.h>
37
# include <apt-pkg/pkgsystem.h>
38
# include <apt-pkg/policy.h>
43
bool RPackageCache::open(OpProgress &progress)
46
_lock = new pkgRpmLock(true);
51
if (_error->PendingError())
54
// Read the source list
56
if (!list.ReadMainList())
57
return _error->Error(_("The list of sources could not be read."));
60
_system->makeStatusCache(list, progress);
63
pkgMakeStatusCache(list, progress);
66
if (_error->PendingError())
67
return _error->Error(_("The package lists or status file could not be parsed or opened."));
69
// Open the cache file
70
FileFd File(_config->FindFile("Dir::Cache::pkgcache"),FileFd::ReadOnly);
71
if (_error->PendingError())
74
_map = new MMap(File,MMap::Public | MMap::ReadOnly);
75
if (_error->PendingError())
78
// Create the dependency cache
80
_dcache = new pkgDepCache(*_map, progress);
82
_cache = new pkgCache(_map);
83
if (_error->PendingError())
87
_policy = new pkgPolicy(_cache);
88
if (_error->PendingError() == true)
90
if (ReadPinFile(*_policy) == false)
93
_dcache = new pkgDepCache(_cache, _policy);
95
_dcache->Init(&progress);
99
if (_error->PendingError())
102
// Check that the system is OK
103
if (_dcache->DelCount() != 0 || _dcache->InstCount() != 0)
104
return _error->Error("Internal Error, non-zero counts");
113
bool RPackageCache::reset(OpProgress &progress)
126
return open(progress);
131
bool RPackageCache::lock()
138
_lock->GetLock(true);
147
void RPackageCache::releaseLock()