paludis Version 3.0.2
The one true package mangler
repository.hh
Go to the documentation of this file.
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh
5 *
6 * This file is part of the Paludis package manager. Paludis is free software;
7 * you can redistribute it and/or modify it under the terms of the GNU General
8 * Public License version 2, as published by the Free Software Foundation.
9 *
10 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORY_HH
21#define PALUDIS_GUARD_PALUDIS_REPOSITORY_HH 1
22
23#include <paludis/action-fwd.hh>
26#include <paludis/spec_tree-fwd.hh>
27#include <paludis/name.hh>
29#include <paludis/partitioning-fwd.hh>
32#include <paludis/util/fs_path.hh>
33#include <paludis/util/wrapped_forward_iterator-fwd.hh>
35#include <paludis/util/named_value.hh>
36#include <paludis/util/timestamp.hh>
39#include <paludis/output_manager-fwd.hh>
42#include <paludis/metadata_key_holder.hh>
43#include <paludis/merger-fwd.hh>
44#include <paludis/hook-fwd.hh>
45#include <string>
46#include <functional>
47
48/** \file
49 * Declarations for Repository classes.
50 *
51 * \ingroup g_repository
52 *
53 * \section Examples
54 *
55 * - \ref example_repository.cc "example_repository.cc"
56 */
57
58namespace paludis
59{
60 namespace n
61 {
62 typedef Name<struct name_arch> arch;
63 typedef Name<struct name_build_start_time> build_start_time;
64 typedef Name<struct name_check> check;
65 typedef Name<struct name_destination_interface> destination_interface;
66 typedef Name<struct name_environment_file> environment_file;
67 typedef Name<struct name_environment_variable_interface> environment_variable_interface;
68 typedef Name<struct name_image_dir> image_dir;
69 typedef Name<struct name_is_volatile> is_volatile;
70 typedef Name<struct name_manifest_interface> manifest_interface;
71 typedef Name<struct name_merged_entries> merged_entries;
72 typedef Name<struct name_options> options;
73 typedef Name<struct name_output_manager> output_manager;
74 typedef Name<struct name_package_id> package_id;
75 typedef Name<struct name_parts> parts;
76 typedef Name<struct name_path> path;
77 typedef Name<struct name_perform_uninstall> perform_uninstall;
78 typedef Name<struct name_permit_destination> permit_destination;
79 typedef Name<struct name_profile> profile;
80 typedef Name<struct name_replacing> replacing;
81 typedef Name<struct name_status> status;
82 typedef Name<struct name_used_this_for_config_protect> used_this_for_config_protect;
83 typedef Name<struct name_want_phase> want_phase;
84 }
85
86 /**
87 * Optional interfaces that may be provided by a Repository.
88 *
89 * \see Repository
90 * \ingroup g_repository
91 * \since 0.30
92 */
99
100 /**
101 * Parameters for RepositoryDestinationInterface::merge.
102 *
103 * \see RepositoryDestinationInterface
104 * \ingroup g_repository
105 * \since 0.30
106 */
108 {
109 /**
110 * The start of the build time (for binaries, should really be when the
111 * binary was originally built).
112 *
113 * \since 0.44
114 */
116
117 /**
118 * Whether to check or perform the merge.
119 *
120 * A check must be performed before a merge.
121 *
122 * \since 0.59
123 */
125
128
129 /**
130 * Whether or not a file is volatile.
131 * \since 2.0.0
132 */
133 NamedValue<n::is_volatile, std::function<bool (const FSPath &)> > is_volatile;
134
135 /**
136 * We record things we merged here.
137 * \since 0.41
138 */
140
144
145 /**
146 * Package partioning.
147 * \since 1.1.0
148 */
150
151 /**
152 * Some merges need to do an uninstall mid-way through the merge process.
153 *
154 * \see InstallActionOptions::perform_uninstall
155 * \since 0.36
156 */
157 NamedValue<n::perform_uninstall, std::function<void (
158 const std::shared_ptr<const PackageID> &,
160
161 ///\since 0.66
163
164 /**
165 * Someone needs to replace these (either the merge or the install).
166 *
167 * \since 0.57
168 */
170
171 NamedValue<n::used_this_for_config_protect, std::function<void (const std::string &)> > used_this_for_config_protect;
172
173 /**
174 * Sometimes merging runs phase functions, possibly via perform_uninstall.
175 *
176 * \since 0.77
177 */
178 NamedValue<n::want_phase, std::function<WantPhase (const std::string &)> > want_phase;
179 };
180
181 /**
182 * Thrown if a Set does not exist
183 *
184 * \ingroup g_exceptions
185 * \ingroup g_repository
186 * \nosubgrouping
187 */
188 class PALUDIS_VISIBLE NoSuchSetError :
189 public Exception
190 {
191 private:
192 std::string _name;
193
194 public:
195 ///\name Basic operations
196 ///\{
197
198 NoSuchSetError(const std::string & name) noexcept;
199
200 ~NoSuchSetError() override;
201
202 ///\}
203
204 /**
205 * Name of the set.
206 */
207 const std::string name() const;
208 };
209
210 /**
211 * Thrown if a Set is recursively defined
212 *
213 * \ingroup g_exceptions
214 * \ingroup g_repository
215 * \nosubgrouping
216 */
217 class PALUDIS_VISIBLE RecursivelyDefinedSetError :
218 public Exception
219 {
220 private:
221 std::string _name;
222
223 public:
224 ///\name Basic operations
225 ///\{
226
227 RecursivelyDefinedSetError(const std::string & name) noexcept;
228
229 ~RecursivelyDefinedSetError() override;
230
231 ///\}
232
233 /**
234 * Name of the set.
235 */
236 const std::string name() const;
237 };
238
239 /**
240 * A Repository provides a representation of a physical repository to an
241 * Environment.
242 *
243 * \ingroup g_repository
244 * \nosubgrouping
245 */
246 class PALUDIS_VISIBLE Repository :
248 public MetadataKeyHolder
249 {
250 private:
251 Pimp<Repository> _imp;
252
253 protected:
254 ///\name Basic operations
255 ///\{
256
257 Repository(const Environment * const, const RepositoryName &, const RepositoryCapabilities &);
258
259 ///\}
260
261 public:
262 ///\name Basic operations
263 ///\{
264
265 ~Repository() override;
266
267 Repository(const Repository &) = delete;
268 Repository & operator= (const Repository &) = delete;
269
270 ///\}
271
272 ///\name Repository information
273 ///\{
274
275 /**
276 * Return our name.
277 */
278 const RepositoryName name() const noexcept PALUDIS_ATTRIBUTE((warn_unused_result));
279
280 ///\}
281
282 ///\name Specific metadata keys
283 ///\{
284
285 virtual const std::shared_ptr<const MetadataValueKey<std::string>> cross_compile_host_key() const = 0;
286
287 /**
288 * The format_key, if non-zero, holds our repository's format. Repository
289 * implementations should not return zero here, but clients should still
290 * check.
291 */
292 virtual const std::shared_ptr<const MetadataValueKey<std::string> > format_key() const = 0;
293
294 /**
295 * The location_key, if non-zero, holds the file or directory containing
296 * our repository's data, the format of which depends on the value of
297 * format_key.
298 */
299 virtual const std::shared_ptr<const MetadataValueKey<FSPath> > location_key() const = 0;
300
301 /**
302 * The installed_root_key, if non-zero, specifies that we contain installed
303 * packages at the specified root.
304 *
305 * This key is currently used in various places to determine whether a repository is
306 * an 'installed' repository or not.
307 */
308 virtual const std::shared_ptr<const MetadataValueKey<FSPath> > installed_root_key() const = 0;
309
310 /**
311 * The sync_host_key, if present, should have value containing
312 * the host against which a sync will be performed for each suffix.
313 *
314 * This is used to avoid starting multiple parallel syncs against
315 * the same host.
316 *
317 * \since 0.44
318 * \since 0.55 is a Map<std::string, std::string>.
319 */
320 virtual const std::shared_ptr<const MetadataCollectionKey<Map<std::string, std::string> > > sync_host_key() const = 0;
321
322 virtual const std::shared_ptr<const MetadataValueKey<std::string>> tool_prefix_key() const = 0;
323
324 ///\}
325
326 ///\name Repository content queries
327 ///\{
328
329 /**
330 * Do we have a category with the given name?
331 *
332 * \since 0.59 takes repository_content_may_excludes
333 */
334 virtual bool has_category_named(const CategoryNamePart & c,
335 const RepositoryContentMayExcludes & repository_content_may_excludes) const = 0;
336
337 /**
338 * Do we have a package in the given category with the given name?
339 */
341 const RepositoryContentMayExcludes & repository_content_may_excludes) const = 0;
342
343 /**
344 * Fetch our category names.
345 */
346 virtual std::shared_ptr<const CategoryNamePartSet> category_names(
347 const RepositoryContentMayExcludes & repository_content_may_excludes) const = 0;
348
349 /**
350 * Fetch unimportant categories.
351 */
352 virtual std::shared_ptr<const CategoryNamePartSet> unimportant_category_names(
353 const RepositoryContentMayExcludes & repository_content_may_excludes) const;
354
355 /**
356 * Are we unimportant?
357 *
358 * In disambiguation, anything gets preferred over packages from unimportant repositories.
359 *
360 * \since 0.46
361 */
362 virtual const bool is_unimportant() const = 0;
363
364 /**
365 * Fetch categories that contain a named package.
366 */
367 virtual std::shared_ptr<const CategoryNamePartSet> category_names_containing_package(
368 const PackageNamePart & p,
369 const RepositoryContentMayExcludes & repository_content_may_excludes) const;
370
371 /**
372 * Fetch our package names.
373 */
374 virtual std::shared_ptr<const QualifiedPackageNameSet> package_names(
375 const CategoryNamePart & c,
376 const RepositoryContentMayExcludes & repository_content_may_excludes) const = 0;
377
378 /**
379 * Fetch our IDs.
380 */
381 virtual std::shared_ptr<const PackageIDSequence> package_ids(const QualifiedPackageName & p,
382 const RepositoryContentMayExcludes & repository_content_may_excludes) const = 0;
383
384 /**
385 * Might some of our IDs support a particular action?
386 *
387 * Used to optimise various Generator and Filter queries. If a
388 * repository doesn't support, say, InstallAction, a query can skip
389 * searching it entirely when looking for installable packages.
390 */
392
393 /**
394 * Might some of our IDs be not masked?
395 *
396 * Used to optimise various Generator and Filter queries.
397 *
398 * \since 0.49
399 */
400 virtual bool some_ids_might_not_be_masked() const = 0;
401
402 /**
403 * Possibly expand a licence.
404 *
405 * May return a null pointer, if we don't define any licence
406 * groups, or if the thing being passed in doesn't look like a
407 * licence group.
408 *
409 * This should not be recursive.
410 *
411 * Callers should Environment::expand_licence, not this method.
412 *
413 * \since 0.66
414 */
415 virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
416 const std::string &) const = 0;
417
418 ///\}
419
420 ///\name Repository behaviour methods
421 ///\{
422
423 /**
424 * Invalidate any in memory cache.
425 */
426 virtual void invalidate() = 0;
427
428 /**
429 * Regenerate any on disk cache.
430 */
431 virtual void regenerate_cache() const;
432
433 /**
434 * Purge any invalid on-disk cache entries.
435 */
436 virtual void purge_invalid_cache() const;
437
438 /**
439 * Perform a hook.
440 *
441 * \since 0.40 (previously in an interface)
442 * \since 0.53 takes optional_output_manager
443 */
445 const Hook & hook,
446 const std::shared_ptr<OutputManager> & optional_output_manager)
447 PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
448
449 /**
450 * Sync, if necessary.
451 *
452 * \return True if we synced successfully, false if we skipped sync.
453 * \since 0.42 (previously in an interface)
454 * \since 0.55 takes a source (may be empty)
455 * \since 0.61 takes a revision (may be empty)
456 */
457 virtual bool sync(
458 const std::string & source,
459 const std::string & revision,
460 const std::shared_ptr<OutputManager> &) const = 0;
461
462 /**
463 * Allow the Repository to drop any memory-cached metadata and
464 * PackageIDs it holds.
465 *
466 * \since 0.42
467 */
468 virtual void can_drop_in_memory_cache() const;
469
470 ///\}
471
472 ///\name Set methods
473 ///\{
474
475 /**
476 * Call Environment::add_set for every set we define.
477 *
478 * Environment will call this method at most once, so no cache or check for
479 * repeats is required. Nothing else should call this method.
480 *
481 * \since 0.40
482 */
483 virtual void populate_sets() const = 0;
484
485 ///\}
486 };
487
488 /**
489 * Interface for environment variable querying for repositories.
490 *
491 * \see Repository
492 * \ingroup g_repository
493 * \nosubgrouping
494 */
496 {
497 public:
498 ///\name Environment query functionality
499 ///\{
500
501 /**
502 * Query an environment variable
503 */
504 virtual std::string get_environment_variable(
505 const std::shared_ptr<const PackageID> & for_package,
506 const std::string & var) const
507 PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
508
509 ///\}
510
512 };
513
514 /**
515 * Interface for repositories that can be used as an install destination.
516 *
517 * \see Repository
518 * \ingroup g_repository
519 * \nosubgrouping
520 */
522 {
523 public:
524 ///\name Destination functions
525 ///\{
526
527 /**
528 * Are we a suitable destination for the specified package?
529 *
530 * \since 0.58 takes id by shared_ptr
531 */
532 virtual bool is_suitable_destination_for(const std::shared_ptr<const PackageID> &) const
533 PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
534
535 /**
536 * If true, pre and post install phases will be used when writing to this
537 * destination.
538 *
539 * This should return true for 'real' filesystem destinations (whether or
540 * not root is /, if root merges are supported), and false for intermediate
541 * destinations such as binary repositories.
542 */
543 virtual bool want_pre_post_phases() const
544 PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
545
546 /**
547 * Merge a package.
548 */
549 virtual void merge(const MergeParams &) = 0;
550
551 virtual std::string split_debug_location() const = 0;
552
553 ///\}
554
556 };
557
558 /**
559 * Interface for making and verifying Manifest2-style manifests
560 *
561 * \see Repository
562 * \ingroup g_repository
563 * \nosubgrouping
564 */
566 {
567 public:
568 /**
569 * Makes the Manifest for a given package. Requires that all
570 * the needed DIST files, etc, have already been fetched.
571 */
572 virtual void make_manifest(const QualifiedPackageName &) = 0;
573
574 ///\name Basic operations
575 ///\{
576
578
579 ///\}
580 };
581}
582
583#endif
Definition environment.hh:203
Definition fs_path.hh:34
Definition hook.hh:75
Definition map.hh:53
Definition metadata_key.hh:279
Definition metadata_key.hh:229
Definition named_value.hh:51
const std::string name() const
Definition output_manager.hh:30
Definition pimp.hh:52
Definition name.hh:112
const std::string name() const
Definition repository.hh:522
virtual void merge(const MergeParams &)=0
virtual bool is_suitable_destination_for(const std::shared_ptr< const PackageID > &) const PALUDIS_ATTRIBUTE((warn_unused_result))=0
virtual bool want_pre_post_phases() const PALUDIS_ATTRIBUTE((warn_unused_result))=0
virtual std::string get_environment_variable(const std::shared_ptr< const PackageID > &for_package, const std::string &var) const PALUDIS_ATTRIBUTE((warn_unused_result))=0
Definition repository.hh:566
virtual void make_manifest(const QualifiedPackageName &)=0
virtual void purge_invalid_cache() const
virtual bool some_ids_might_not_be_masked() const =0
virtual const std::shared_ptr< const MetadataCollectionKey< Map< std::string, std::string > > > sync_host_key() const =0
virtual HookResult perform_hook(const Hook &hook, const std::shared_ptr< OutputManager > &optional_output_manager) PALUDIS_ATTRIBUTE((warn_unused_result))=0
virtual std::shared_ptr< const PackageIDSequence > package_ids(const QualifiedPackageName &p, const RepositoryContentMayExcludes &repository_content_may_excludes) const =0
virtual std::shared_ptr< const CategoryNamePartSet > category_names(const RepositoryContentMayExcludes &repository_content_may_excludes) const =0
virtual void populate_sets() const =0
virtual const std::shared_ptr< const Set< std::string > > maybe_expand_licence_nonrecursively(const std::string &) const =0
virtual const std::shared_ptr< const MetadataValueKey< FSPath > > location_key() const =0
virtual const std::shared_ptr< const MetadataValueKey< std::string > > format_key() const =0
virtual const bool is_unimportant() const =0
virtual void can_drop_in_memory_cache() const
virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const =0
const RepositoryName name() const noexcept PALUDIS_ATTRIBUTE((warn_unused_result))
virtual void invalidate()=0
virtual std::shared_ptr< const CategoryNamePartSet > unimportant_category_names(const RepositoryContentMayExcludes &repository_content_may_excludes) const
virtual std::shared_ptr< const CategoryNamePartSet > category_names_containing_package(const PackageNamePart &p, const RepositoryContentMayExcludes &repository_content_may_excludes) const
virtual bool has_package_named(const QualifiedPackageName &q, const RepositoryContentMayExcludes &repository_content_may_excludes) const =0
virtual void regenerate_cache() const
virtual std::shared_ptr< const QualifiedPackageNameSet > package_names(const CategoryNamePart &c, const RepositoryContentMayExcludes &repository_content_may_excludes) const =0
virtual bool has_category_named(const CategoryNamePart &c, const RepositoryContentMayExcludes &repository_content_may_excludes) const =0
virtual bool sync(const std::string &source, const std::string &revision, const std::shared_ptr< OutputManager > &) const =0
virtual const std::shared_ptr< const MetadataValueKey< FSPath > > installed_root_key() const =0
Definition set.hh:51
Definition action.hh:633
WrappedValue< CategoryNamePartTag > CategoryNamePart
Definition name-fwd.hh:61
WrappedValue< PackageNamePartTag > PackageNamePart
Definition name-fwd.hh:47
WrappedValue< RepositoryNameTag > RepositoryName
Definition name-fwd.hh:105
Sequence< std::shared_ptr< const PackageID > > PackageIDSequence
Definition package_id-fwd.hh:48
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24
Definition hook.hh:62
Definition repository.hh:108
NamedValue< n::build_start_time, Timestamp > build_start_time
Definition repository.hh:115
NamedValue< n::permit_destination, PermitDestinationFn > permit_destination
Definition repository.hh:162
NamedValue< n::perform_uninstall, std::function< void(const std::shared_ptr< const PackageID > &, const UninstallActionOptions &)> > perform_uninstall
Definition repository.hh:159
NamedValue< n::merged_entries, std::shared_ptr< FSPathSet > > merged_entries
Definition repository.hh:139
NamedValue< n::check, bool > check
Definition repository.hh:124
NamedValue< n::replacing, std::shared_ptr< const PackageIDSequence > > replacing
Definition repository.hh:169
NamedValue< n::is_volatile, std::function< bool(const FSPath &)> > is_volatile
Definition repository.hh:133
NamedValue< n::parts, std::shared_ptr< Partitioning > > parts
Definition repository.hh:149
NamedValue< n::want_phase, std::function< WantPhase(const std::string &)> > want_phase
Definition repository.hh:178
Definition repository.hh:94
Definition action.hh:198