LibPkg
pkgbase.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 //
3 // Copyright 2003-2020 Graham Shaw
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef LIBPKG_PKGBASE
18 #define LIBPKG_PKGBASE
19 
20 #include <string>
21 
22 #include "libpkg/dependency.h"
23 #include "libpkg/status_table.h"
25 #include "libpkg/source_table.h"
26 #include "libpkg/env_checker.h"
27 #include "libpkg/path_table.h"
29 
30 namespace pkg {
31 
32 using std::string;
33 
35 class pkgbase
36 {
37 public:
38  class cache_error;
39 private:
41  string _pathname;
42 
44  string _dpathname;
45 
47  string _cpathname;
48 
50  status_table _curstat;
51 
53  status_table _selstat;
54 
56  status_table _prevstat;
57 
59  env_checker_ptr _env_checker_ptr;
60 
62  binary_control_table _control;
63 
65  source_table _sources;
66 
68  env_packages_table *_env_packages;
69 
71  path_table _paths;
72 
80  bool _changed;
81 public:
87  pkgbase(const string& pathname,const string& dpathname,
88  const string& cpathname);
89 
91  ~pkgbase();
92 
97  { return _curstat; }
98 
103  { return _selstat; }
104 
111  { return _prevstat; }
112 
117  { return _control; }
118 
123  { return _sources; }
124 
131 
136  { return _paths; }
137 
142  string list_pathname(const string& url);
143 
147  string available_pathname();
148 
155  string cache_pathname(const string& pkgname,
156  const string& pkgvrsn,
157  const string& pkgenvid);
158 
163  string info_pathname(const string& pkgname);
164 
168  string sysvars_pathname();
169 
173  string sprites_pathname();
174 
178  string setvars_pathname();
179 
184  string bootsprites_pathname();
185 
189  string component_update_pathname();
190 
198  void verify_cached_file(const binary_control& ctrl);
199 
208  bool fix_dependencies(const std::set<string>& seed);
209 
212  void remove_auto();
213 private:
223  bool fix_dependencies(const pkg::control& ctrl,bool allow_new);
224 
234  bool fix_dependencies(const pkg::control& ctrl,bool allow_new,
235  bool apply);
236 
249  const pkg::control* resolve(const std::vector<dependency>& deps,
250  bool allow_new=true);
251 
262  const pkg::control* resolve(const dependency& dep,
263  bool allow_new=true);
264 
270  void ensure_removed(const string& pkgname);
271 
279  void ensure_installed(const string& pkgname,const string& pkgvrsn,const string &pkgenv);
280 
285  bool update_status_table(status_table &update_table);
286 };
287 
290  public std::runtime_error
291 {
292 public:
297  cache_error(const char* message,const binary_control& ctrl);
298 };
299 
300 }; /* namespace pkg */
301 
302 #endif
An exception class for reporting cache errors.
Definition: pkgbase.h:289
void verify_cached_file(const binary_control &ctrl)
Verify file in cache.
Definition: pkgbase.cc:169
status_table & prevstat()
Get previous status table.
Definition: pkgbase.h:110
string available_pathname()
Get pathname for available list file.
Definition: pkgbase.cc:139
string info_pathname(const string &pkgname)
Get pathname for info directory of package.
Definition: pkgbase.cc:93
The namespace used to hold the package management library.
Definition: auto_dir.cc:23
A class that filters the binary control table to create a list of the packages available in the curre...
Definition: env_packages_table.h:34
binary_control_table & control()
Get binary control table.
Definition: pkgbase.h:116
A class to represent a package dependency.
Definition: dependency.h:35
string sysvars_pathname()
Get pathname for sysvars directory.
Definition: pkgbase.cc:144
~pkgbase()
Destroy pkgbase object.
Definition: pkgbase.cc:66
bool fix_dependencies(const std::set< string > &seed)
Fix dependencies.
Definition: pkgbase.cc:210
string sprites_pathname()
Get pathname for sprites directory.
Definition: pkgbase.cc:149
string setvars_pathname()
Get pathname for setvars file.
Definition: pkgbase.cc:154
status_table & selstat()
Get selected status table.
Definition: pkgbase.h:102
A class to represent the content of a RiscPkg control file.
Definition: control.h:35
void remove_auto()
Remove redundant auto-installed packages.
Definition: pkgbase.cc:348
string list_pathname(const string &url)
Get pathname for index file from given source.
Definition: pkgbase.cc:98
env_packages_table & env_packages()
Get environment packages table which contains the package names of packages suitable for the current ...
Definition: pkgbase.cc:71
A class for holding a list of source URLs.
Definition: source_table.h:37
string bootsprites_pathname()
Get pathname for sprites file.
Definition: pkgbase.cc:159
A class for mapping package name and version to binary control record.
Definition: binary_control_table.h:32
A class for representing the collection of package database tables.
Definition: pkgbase.h:35
status_table & curstat()
Get current status table.
Definition: pkgbase.h:96
Class to help manage the single env_checker instance.
Definition: env_checker.h:142
A class for mapping package name to package status.
Definition: status_table.h:31
source_table & sources()
Get source table.
Definition: pkgbase.h:122
string cache_pathname(const string &pkgname, const string &pkgvrsn, const string &pkgenvid)
Get pathname for package in cache.
Definition: pkgbase.cc:82
path_table & paths()
Get path table.
Definition: pkgbase.h:135
A class to represent the content of a RiscPkg binary control file.
Definition: binary_control.h:35
pkgbase(const string &pathname, const string &dpathname, const string &cpathname)
Create pkgbase object.
Definition: pkgbase.cc:35
string component_update_pathname()
Get pathname for component update file.
Definition: pkgbase.cc:164
A class for mapping source paths to destination paths.
Definition: path_table.h:34

Reference Manual LibPkg Version 0.9.0 (4 Sep 2020)