aboutsummaryrefslogtreecommitdiff
path: root/0.8.0/paludis/ebin.hh
blob: 51a470e4dfc24d47d7ec527823e41fdb47d4ad4b (plain)
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
/* vim: set sw=4 sts=4 et foldmethod=syntax : */

/*
 * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
 *
 * This file is part of the Paludis package manager. Paludis is free software;
 * you can redistribute it and/or modify it under the terms of the GNU General
 * Public License version 2, as published by the Free Software Foundation.
 *
 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef PALUDIS_GUARD_PALUDIS_EBIN_HH
#define PALUDIS_GUARD_PALUDIS_EBIN_HH 1

#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/sr.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/collection.hh>
#include <paludis/package_database.hh>
#include <string>

/** \file
 * Declarations for the EbinCommand classes.
 *
 * \ingroup grpebininterface
 */

namespace paludis
{
    class Environment;
    class MakeEnvCommand;

#include <paludis/ebin-sr.hh>

    /**
     * An EbinCommand is the base class from which specific ebin
     * command interfaces are descended.
     *
     * \ingroup grpebininterface
     */
    class EbinCommand :
        private InstantiationPolicy<EbinCommand, instantiation_method::NonCopyableTag>
    {
        protected:
            /**
             * Our parameters.
             */
            const EbinCommandParams params;

            /**
             * Constructor.
             */
            EbinCommand(const EbinCommandParams &);

            /**
             * Override in descendents: which commands (for example, 'prerm
             * unmerge postrm') do we give to ebin.bash?
             */
            virtual std::string commands() const = 0;

            /**
             * Actions to be taken after a successful command.
             *
             * The return value of this function is used for the return value
             * of operator().
             */
            virtual bool success();

            /**
             * Should the sandbox, if available, be used?
             */
            virtual bool use_sandbox() const;

            /**
             * Actions to be taken after a failed command.
             *
             * The return value of this function is used for the return value
             * of operator(). In some descendents, this function throws and
             * does not return.
             */
            virtual bool failure() = 0;

            /**
             * Run the specified command. Can be overridden if, for example,
             * the command output needs to be captured.
             *
             * \return Whether the command succeeded.
             */
            virtual bool do_run_command(const std::string &);

            /**
             * Add Portage emulation vars.
             */
            virtual MakeEnvCommand add_portage_vars(const MakeEnvCommand &) const;

            /**
             * Extend the command to be run.
             */
            virtual MakeEnvCommand extend_command(const MakeEnvCommand &) = 0;

        public:
            /**
             * Destructor.
             */
            virtual ~EbinCommand();

            /**
             * Run the command.
             */
            virtual bool operator() ();
    };

    /**
     * An EbinFetchCommand is used to download and verify the digests for a
     * particular ebin in a PortageRepository. On failure it throws.
     *
     * \ingroup grpebininterface
     */
    class EbinFetchCommand :
        public EbinCommand
    {
        protected:
            /// Parameters for fetch.
            const EbinFetchCommandParams fetch_params;

            virtual std::string commands() const;

            virtual bool failure() PALUDIS_ATTRIBUTE((noreturn));

            virtual MakeEnvCommand extend_command(const MakeEnvCommand &);

        public:
            /**
             * Constructor.
             */
            EbinFetchCommand(const EbinCommandParams &, const EbinFetchCommandParams &);
    };

    /**
     * An EbinInstallCommand is used to install an ebin from a
     * PortageRepository. On failure it throws.
     *
     * \ingroup grpebininterface
     */
    class EbinInstallCommand :
        public EbinCommand
    {
        protected:
            /// Parameters for install.
            const EbinInstallCommandParams install_params;

            virtual std::string commands() const;

            virtual bool failure() PALUDIS_ATTRIBUTE((noreturn));

            virtual MakeEnvCommand extend_command(const MakeEnvCommand &);

        public:
            /**
             * Constructor.
             */
            EbinInstallCommand(const EbinCommandParams &, const EbinInstallCommandParams &);
    };
}

#endif