1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
/*---------------------------------------------------------------------\
| ____ _ __ __ ___ |
| |__ / \ / / . \ . \ |
| / / \ V /| _/ _/ |
| / /__ | | | | | | |
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
#ifndef ZYPP_SHARED_COMMIT_COMMITMESSAGE_H_INCLUDED
#define ZYPP_SHARED_COMMIT_COMMITMESSAGE_H_INCLUDED
#include <zypp-core/rpc/PluginFrame.h>
#include <zypp-core/zyppng/pipelines/expected.h>
#include <cstdint>
#include <string>
#include <variant>
#include <vector>
/*!
* This file specifies all messages that are sent between TargetImpl and the zypp-rpm
* backend binary. The communication protocol uses our implementation of the
* STOMP protocol mesage format. \sa zypp::PluginFrame
*/
namespace zypp::proto::target
{
// transaction steps are sent as part of the Commit Message
// serialized to 0x0\stepId\0pathName\0multiversion\0
struct InstallStep {
uint32_t stepId;
std::string pathname;
bool multiversion;
};
// serialized to 0x1stepId\0name\0version\0release\0arch\0
struct RemoveStep {
uint32_t stepId;
std::string name;
std::string version;
std::string release;
std::string arch ;
};
using TransactionStep = std::variant<InstallStep,RemoveStep>;
// first message that is sent to zypp-rpm
// to setup the commit basics.
struct Commit
{
Commit() = default;
Commit(const Commit &) = default;
Commit(Commit &&) = default;
Commit &operator=(const Commit &) = default;
Commit &operator=(Commit &&) = default;
static constexpr std::string_view typeName = "Commit";
enum StepTypes : uint8_t {
InstallStepType,
RemoveStepType
};
uint32_t flags;
std::string arch;
std::string root;
std::string dbPath;
std::string lockFilePath;
bool ignoreArch;
std::vector<TransactionStep> transactionSteps;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<Commit> fromStompMessage( const zypp::PluginFrame &msg );
};
// message written to zypper when the transaction has failed
struct TransactionError {
static constexpr std::string_view typeName = "TransactionError";
std::vector<std::string> problems;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<TransactionError> fromStompMessage( const zypp::PluginFrame &msg );
};
// message written to the rpm log including the level
struct RpmLog {
static constexpr std::string_view typeName = "RpmLog";
uint32_t level;
std::string line;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<RpmLog> fromStompMessage( const zypp::PluginFrame &msg );
};
// Per package information which directly correspond to a TransactionStep !!!!
struct PackageBegin {
static constexpr std::string_view typeName = "PackageBegin";
uint32_t stepId;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<PackageBegin> fromStompMessage( const zypp::PluginFrame &msg );
};
struct PackageFinished {
static constexpr std::string_view typeName = "PackageFinished";
uint32_t stepId;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<PackageFinished> fromStompMessage( const zypp::PluginFrame &msg );
};
struct PackageError {
static constexpr std::string_view typeName = "PackageError";
uint32_t stepId;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<PackageError> fromStompMessage( const zypp::PluginFrame &msg );
};
struct PackageProgress {
static constexpr std::string_view typeName = "PackageProgress";
uint32_t stepId;
uint32_t amount;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<PackageProgress> fromStompMessage( const zypp::PluginFrame &msg );
};
// Progress for cleaning up old versions of packages
// which have NO corresponding TransactionStep
struct CleanupBegin {
static constexpr std::string_view typeName = "CleanupBegin";
std::string nvra;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<CleanupBegin> fromStompMessage( const zypp::PluginFrame &msg );
};
struct CleanupFinished {
static constexpr std::string_view typeName = "CleanupFinished";
std::string nvra;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<CleanupFinished> fromStompMessage( const zypp::PluginFrame &msg );
};
struct CleanupProgress {
static constexpr std::string_view typeName = "CleanupProgress";
std::string nvra;
uint32_t amount;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<CleanupProgress> fromStompMessage( const zypp::PluginFrame &msg );
};
// per script info, for each of those the stepId can be -1 or point
// to a valid step in the transaction set.
struct ScriptBegin {
static constexpr std::string_view typeName = "ScriptBegin";
int32_t stepId;
std::string scriptType;
std::string scriptPackage;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<ScriptBegin> fromStompMessage( const zypp::PluginFrame &msg );
};
struct ScriptFinished {
static constexpr std::string_view typeName = "ScriptFinished";
int32_t stepId;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<ScriptFinished> fromStompMessage( const zypp::PluginFrame &msg );
};
struct ScriptError {
static constexpr std::string_view typeName = "ScriptError";
int32_t stepId;
bool fatal;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<ScriptError> fromStompMessage( const zypp::PluginFrame &msg );
};
// Generic Transactionstep report, we use it for preparing and verifying progress
struct TransBegin {
static constexpr std::string_view typeName = "TransBegin";
std::string name;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<TransBegin> fromStompMessage( const zypp::PluginFrame &msg );
};
struct TransFinished {
static constexpr std::string_view typeName = "TransFinished";
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<TransFinished> fromStompMessage( const zypp::PluginFrame &msg );
};
struct TransProgress {
static constexpr std::string_view typeName = "TransProgress";
uint32_t amount;
zyppng::expected<zypp::PluginFrame> toStompMessage() const;
static zyppng::expected<TransProgress> fromStompMessage( const zypp::PluginFrame &msg );
};
}
#endif // ZYPP_SHARED_COMMIT_COMMITMESSAGE_H_INCLUDED
|