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 * The arch names must cover every entry of libsolv's policy table
27 * (src/poolarch.c): mapSnapshot() calls pool_setarch() before
28 * mapping, and on a host whose arch is missing here that interns a
29 * new id, shifting the sequence and disabling the snapshot for good.
30 *
31 * APPEND-ONLY: reordering or removing entries makes every existing
32 * snapshot fall back to a full load until rewritten (safe, but
33 * keep it stable). The order mirrors the pre-load intern sequence
34 * observed in zypper so snapshots written by older builds keep
35 * mapping. */
36 const char * const fixedPoolIds[] = {
37 // sat::Solvable tokens
38 "pattern()", "product()", "retracted-patch-package()", "ptf()", "ptf-package()",
39 // PoolQuery serialization words
40 "repo", "type", "comment", "query_string", "match_type", "require_all",
41 "case_sensitive", "install_status", "version", "complex", "exact",
42 "substring", "regex", "glob", "word",
43 // ResKind
44 "package", "patch", "pattern", "product", "srcpackage", "application",
45 // SolvAttr string literals
46 "changelog", "sourcesize", "isdefault", "script",
47 // the Arch builtins
48 "i386", "i486", "i586", "i686", "athlon", "x86_64", "x86_64_v2",
49 "x86_64_v3", "x86_64_v4", "pentium3", "pentium4", "ia64", "s390",
50 "s390x", "ppc", "ppc64", "ppc64p7", "ppc64le", "alpha", "alphaev5",
51 "alphaev56", "alphapca56", "alphaev6", "alphaev67", "sparc", "sparcv8",
52 "sparcv9", "sparcv9v", "sparc64", "sparc64v", "armv3l", "armv4l",
53 "armv4tl", "armv5l", "armv5tl", "armv5tel", "armv5tejl", "armv6l",
54 "armv7l", "armv8l", "armv6hl", "armv7hl", "armv8hl", "armv7hnl",
55 "armv7nhl", "armv7thl", "armv7tnhl", "aarch64", "riscv64", "sh3",
56 "sh4", "sh4a", "m68k", "mips", "mipsel", "mips64", "mips64el",
57 "loong64", "armv8hnl", "armv8hcnl", "e2k", "e2kv4", "e2kv5", "e2kv6",
58 // only in a FEDORA/MAGEIA build of libsolv, but interning them
59 // unconditionally keeps this list independent of that
60 "ia32e", "amd64", "geode", "ppc64iseries", "ppc64pseries",
61 // LanguageCode::enCode
62 "en",
63 };
64 }
65
67 {
68 static StringPool p;
69 return p;
70 }
71
73 {
74 ::pool_free( _pool );
75 }
76
77 StringPool::StringPool() : _pool( ::pool_create() )
78 {
79 MIL << "Creating sat-pool." << std::endl;
80 if ( ! _pool )
81 {
82 ZYPP_THROW( zypp::Exception( _("Can not create sat-pool.") ) );
83 }
84 // libzypp#726: If the disttype is unset, ::pool_evrcmp_str uses
85 // the default flavor set at compiletime. But even on DEBIAN we
86 // handle rpm packages, so their rules must be applied.
87 ::pool_setdisttype( _pool, DISTTYPE_RPM );
88 for ( const char * str : fixedPoolIds )
89 ::pool_str2id( _pool, str, /*create*/1 );
90 }
91
92}
#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:66
~StringPool()
Destructor.
Definition stringpool.cc:72
StringPool(const StringPool &)=delete
zypp::sat::detail::CPool * _pool
Internal pointer to the libsolv pool structure (CPool).
Definition stringpool.h:90
CURL handle void * p
Definition curl_dl.cc:142
String related utilities and Regular expression matching.