libzypp 17.38.15
stringpool.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9// LEGACY-REQUIRED — see stringpool.h
10#include "stringpool.h"
11
15
16namespace zyppng::sat {
17
18 namespace {
19 /* Fixed id block for the pool snapshot (see pool_snapshot.c's map
20 * guard): libzypp and its consumers intern these strings before
21 * any repo is loaded, from static initializers whose order depends
22 * on the link line and thus on the binary. Interning them here,
23 * right after pool_create, pins their ids so a snapshot written by
24 * one libzypp binary maps in another.
25 *
26 * APPEND-ONLY: reordering or removing entries makes every existing
27 * snapshot fall back to a full load until rewritten (safe, but
28 * keep it stable). The order mirrors the pre-load intern sequence
29 * observed in zypper so snapshots written by older builds keep
30 * mapping. */
31 const char * const fixedPoolIds[] = {
32 // sat::Solvable tokens
33 "pattern()", "product()", "retracted-patch-package()", "ptf()", "ptf-package()",
34 // PoolQuery serialization words
35 "repo", "type", "comment", "query_string", "match_type", "require_all",
36 "case_sensitive", "install_status", "version", "complex", "exact",
37 "substring", "regex", "glob", "word",
38 // ResKind
39 "package", "patch", "pattern", "product", "srcpackage", "application",
40 // SolvAttr string literals
41 "changelog", "sourcesize", "isdefault", "script",
42 // the Arch builtins
43 "i386", "i486", "i586", "i686", "athlon", "x86_64", "x86_64_v2",
44 "x86_64_v3", "x86_64_v4", "pentium3", "pentium4", "ia64", "s390",
45 "s390x", "ppc", "ppc64", "ppc64p7", "ppc64le", "alpha", "alphaev5",
46 "alphaev56", "alphapca56", "alphaev6", "alphaev67", "sparc", "sparcv8",
47 "sparcv9", "sparcv9v", "sparc64", "sparc64v", "armv3l", "armv4l",
48 "armv4tl", "armv5l", "armv5tl", "armv5tel", "armv5tejl", "armv6l",
49 "armv7l", "armv8l", "armv6hl", "armv7hl", "armv8hl", "armv7hnl",
50 "armv7nhl", "armv7thl", "armv7tnhl", "aarch64", "riscv64", "sh3",
51 "sh4", "sh4a", "m68k", "mips", "mipsel", "mips64", "mips64el",
52 "loong64",
53 // LanguageCode::enCode
54 "en",
55 };
56 }
57
59 {
60 static StringPool p;
61 return p;
62 }
63
65 {
66 ::pool_free( _pool );
67 }
68
69 StringPool::StringPool() : _pool( ::pool_create() )
70 {
71 MIL << "Creating sat-pool." << std::endl;
72 if ( ! _pool )
73 {
74 ZYPP_THROW( zypp::Exception( _("Can not create sat-pool.") ) );
75 }
76 // libzypp#726: If the disttype is unset, ::pool_evrcmp_str uses
77 // the default flavor set at compiletime. But even on DEBIAN we
78 // handle rpm packages, so their rules must be applied.
79 ::pool_setdisttype( _pool, DISTTYPE_RPM );
80 for ( const char * str : fixedPoolIds )
81 ::pool_str2id( _pool, str, /*create*/1 );
82 }
83
84}
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459
#define _(MSG)
Definition Gettext.h:39
#define MIL
Definition Logger.h:130
Base class for Exception.
Definition Exception.h:153
static StringPool & instance()
Access the global StringPool instance.
Definition stringpool.cc:58
~StringPool()
Destructor.
Definition stringpool.cc:64
StringPool(const StringPool &)=delete
zypp::sat::detail::CPool * _pool
Internal pointer to the libsolv pool structure (CPool).
Definition stringpool.h:90
nullptr CURL handle void * p
Definition curl_dl.cc:99
String related utilities and Regular expression matching.