LibPkg
commit.h
Go to the documentation of this file.
1 // This file is part of the 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_COMMIT
18 #define LIBPKG_COMMIT
19 
20 #include "libpkg/thread.h"
21 #include "libpkg/log.h"
22 #include "libpkg/trigger.h"
23 #include "libpkg/download.h"
24 
25 namespace pkg {
26 
27 class control_binary;
28 class pkgbase;
29 class unpack;
30 class trigger_run;
31 class triggers;
32 class trigger;
33 
35 class commit:
36  public thread
37 {
38 public:
40  typedef unsigned long long size_type;
41 
43  static const size_type npos=static_cast<size_type>(-1);
44 
45  // An enumeration for describing the state of the commit operation. */
47  {
83  };
84 private:
86  pkgbase& _pb;
87 
89  state_type _state;
90 
92  std::set<string> _packages_to_process;
93 
95  std::set<string> _packages_to_download;
96 
100  std::set<string> _packages_to_unpack;
101 
105  std::set<string> _packages_to_configure;
106 
110  std::set<string> _packages_to_purge;
111 
113  std::set<string> _components_to_remove;
114 
116  std::set<string> _files_to_boot;
118  std::set<string> _files_to_run;
120  std::set<string> _files_to_add_to_apps;
121 
123  string _pkgname;
124 
126  download* _dload;
127 
129  unpack* _upack;
130 
132  size_type _files_done;
133 
135  size_type _files_total;
136 
138  size_type _bytes_done;
139 
141  size_type _bytes_total;
142 
145  string _message;
146 
147  struct progress;
148 
150  std::map<string,progress> _progress_table;
151 
154  std::set<string> _files_that_conflict;
155 
157  trigger_run *_trigger_run;
158 
160  triggers *_triggers;
161 
163  trigger *_trigger;
164 
166  log *_log;
167 
169  log *_warnings;
170 
172  pkg::download::options *_download_options;
173 
174 public:
179  commit(pkgbase& pb,const std::set<string>& packages);
180 
182  virtual ~commit();
183 
188  { return _state; }
189 
193  size_type files_done() const
194  { return _files_done; }
195 
199  size_type files_total() const
200  { return _files_total; }
201 
205  size_type bytes_done() const
206  { return _bytes_done; }
207 
211  size_type bytes_total() const
212  { return _bytes_total; }
213 
219  string message() const
220  { return _message; }
221 
222  bool has_substate_text() const;
224  std::string substate_text() const;
225 
232  const std::set<string>& files_that_conflict() const
233  { return _files_that_conflict; }
234 
236  void use_trigger_run(trigger_run *tr);
237 
241  void log_to(log *use_log);
242 
246  log *warnings() const {return _warnings;}
253  log *detach_warnings() {log *w = _warnings; _warnings = 0; return w;}
254 
259  void download_options(const download::options &options);
260 
261 protected:
262  virtual void poll();
263 private:
268  void update_download_progress();
269 
276  void warning(LogCode code, const std::string &item, const std::string &what);
277 };
278 
281 {
292  progress();
293 };
294 
295 }; /* namespace pkg */
296 
297 #endif
std::string substate_text() const
Definition: commit.cc:785
The state in which post remove triggers are run.
Definition: commit.h:73
A class to manage the package triggers executed during the commiting of the packages.
Definition: triggers.h:38
The state in which the sprite pool is updated.
Definition: commit.h:63
Definition: download.h:58
size_type bytes_total() const
Get total number of bytes to process.
Definition: commit.h:211
The state in which packages are being purged.
Definition: commit.h:59
The namespace used to hold the package management library.
Definition: auto_dir.cc:23
size_type bytes_done() const
Get number of bytes processed.
Definition: commit.h:205
The state in which packages are being downloaded.
Definition: commit.h:53
log * warnings() const
Return warnings log.
Definition: commit.h:246
void use_trigger_run(trigger_run *tr)
Set the class to run triggers.
Definition: commit.cc:791
size_type files_total() const
Get total number of files to process.
Definition: commit.h:199
The state in which post install triggers are run.
Definition: commit.h:75
The state in which all operations have been successfully completed.
Definition: commit.h:80
void log_to(log *use_log)
Set the log to add to.
Definition: commit.cc:796
virtual void poll()
Poll this thread.
Definition: commit.cc:80
The state in which packages are being unpacked or removed.
Definition: commit.h:55
The state in which the RISC OS boot option files are updated.
Definition: commit.h:65
The state in which an error has occurred.
Definition: commit.h:82
The state in which files are added to the current apps virtual directory.
Definition: commit.h:71
A class for unpacking and removing sets of packages.
Definition: unpack.h:49
The state in which packages are being configured.
Definition: commit.h:57
The state in which the list of system variables is updated.
Definition: commit.h:61
unsigned long long size_type
A type for representing byte counts.
Definition: commit.h:40
class to represent a trigger action from a script
Definition: trigger.h:33
commit(pkgbase &pb, const std::set< string > &packages)
Construct commit operation.
Definition: commit.cc:40
The state in which packages are being considered for download.
Definition: commit.h:51
The state in which files added to the boot run files are run.
Definition: commit.h:69
A mixin class to represent a cooperative thread.
Definition: thread.h:23
log * detach_warnings()
Detach warnings log.
Definition: commit.h:253
size_type files_done() const
Get number of files processed.
Definition: commit.h:193
Class to log actions that occur in LibPkg.
Definition: log.h:226
string message() const
Get error message.
Definition: commit.h:219
state_type
Definition: commit.h:46
Interface to execute a trigger.
Definition: trigger.h:77
bool has_substate_text() const
Definition: commit.cc:772
A class for representing the collection of package database tables.
Definition: pkgbase.h:35
state_type state() const
Get current state of the commit operation.
Definition: commit.h:187
const std::set< string > & files_that_conflict() const
Get the set of destination pathnames that conflict with files already on the system.
Definition: commit.h:232
The state in which work files and variables for triggers are cleaned up.
Definition: commit.h:77
size_type bytes_done
The number of bytes downloaded.
Definition: commit.h:283
size_type bytes_total
The total number of bytes to download, or npos if not known.
Definition: commit.h:285
static const size_type npos
A null value for use in place of a byte count.
Definition: commit.h:43
A class for downloading a file from a URL.
Definition: download.h:37
A structure for monitoring the download progress of one source.
Definition: commit.h:280
size_type bytes_ctrl
The total number of bytes specified in the control record, or npos if no total was given...
Definition: commit.h:288
virtual ~commit()
Destroy commit operation.
Definition: commit.cc:67
bool clear_substate_text_changed()
Definition: commit.cc:777
void download_options(const download::options &options)
Set additional options for any downloads required.
Definition: commit.cc:74
A class for installing, removing and purging packages.
Definition: commit.h:35
LogCode
An enumeration of all the items that can be logged.
Definition: log.h:30
The state in which paths for components are set.
Definition: commit.h:49
The state in which files added to the boot look at and boot run files are booted. ...
Definition: commit.h:67

Reference Manual LibPkg Version 0.9.0 (4 Sep 2020)