aboutsummaryrefslogtreecommitdiff
path: root/src/clients/contrarius/install.cc
blob: 5994a70d73246b49baf32ca404d727f482be07cb (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
/* vim: set sw=4 sts=4 et foldmethod=syntax : */

/*
 * Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
 * Copyright (c) 2007 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
 *
 * 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
 */

#include "install.hh"
#include <src/output/console_install_task.hh>

#include <iostream>

#include <paludis/install_task.hh>
#include <paludis/util/log.hh>
#include <paludis/util/sequence.hh>
#include <paludis/environment.hh>
#include <paludis/package_id.hh>

/** \file
 * Handle the --install action for the contrarius program.
 */

using namespace paludis;

using std::cerr;
using std::cout;
using std::endl;

namespace
{
    class OurInstallTask :
        public ConsoleInstallTask
    {
        public:
            OurInstallTask(tr1::shared_ptr<Environment> env, const DepListOptions & options) :
                ConsoleInstallTask(env.get(), options, env->default_destinations())
            {
            }

            virtual bool want_full_install_reasons() const
            {
                return "full" == CommandLine::get_instance()->a_show_reasons.argument();
            }

            virtual bool want_tags_summary() const
            {
                return CommandLine::get_instance()->a_pretend.specified();
            }

            virtual bool want_install_reasons() const
            {
                return "full" == CommandLine::get_instance()->a_show_reasons.argument() ||
                    "summary" == CommandLine::get_instance()->a_show_reasons.argument();
            }

            virtual bool want_unchanged_use_flags() const
            {
                return false;
            }

            virtual bool want_changed_use_flags() const
            {
                return false;
            }

            virtual bool want_new_use_flags() const
            {
                return false;
            }

            virtual bool want_use_summary() const
            {
                return false;
            }

            virtual std::string make_resume_command(const PackageIDSequence &) const
            {
                return "";
            }

            virtual void show_resume_command() const
            {
            }
    };
}

int
do_install(tr1::shared_ptr<Environment> env, std::string spec_str)
{
    Context context("When performing install action from command line:");

    DepListOptions options;

    options.circular = dl_circular_discard;
    options.circular = dl_circular_error;
    options.installed_deps_pre = dl_deps_discard;
    options.installed_deps_runtime = dl_deps_discard;
    options.installed_deps_post = dl_deps_discard;
    options.uninstalled_deps_pre = dl_deps_discard;
    options.uninstalled_deps_runtime = dl_deps_discard;
    options.uninstalled_deps_post = dl_deps_discard;
    options.reinstall = dl_reinstall_never;
    options.target_type = dl_target_set;

    OurInstallTask task(env, options);
    task.set_fetch_only(CommandLine::get_instance()->a_fetch.specified());
    task.set_pretend(CommandLine::get_instance()->a_pretend.specified());

    if (CommandLine::get_instance()->a_debug_build.specified())
    {
        if (CommandLine::get_instance()->a_debug_build.argument() == "none")
            task.set_debug_mode(iado_none);
        else if (CommandLine::get_instance()->a_debug_build.argument() == "split")
            task.set_debug_mode(iado_split);
        else if (CommandLine::get_instance()->a_debug_build.argument() == "internal")
            task.set_debug_mode(iado_internal);
        else
            throw DoHelp("bad value for --debug-build");
    }

    task.add_target(spec_str);

    task.execute();

    cout << endl;

    return task.exit_status();
}