|
ali@24
|
1 |
/*
|
|
ali@24
|
2 |
* Copyright (C) 2014 J. Ali Harlow <ali@juiblex.co.uk>
|
|
ali@24
|
3 |
*
|
|
ali@24
|
4 |
* This program is free software; you can redistribute it and/or modify
|
|
ali@24
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
ali@24
|
6 |
* the Free Software Foundation; either version 2 of the License, or
|
|
ali@24
|
7 |
* (at your option) any later version.
|
|
ali@24
|
8 |
*
|
|
ali@24
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
ali@24
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
ali@24
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
ali@24
|
12 |
* GNU General Public License for more details.
|
|
ali@24
|
13 |
*
|
|
ali@24
|
14 |
* You should have received a copy of the GNU General Public License along
|
|
ali@24
|
15 |
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
ali@24
|
16 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
ali@24
|
17 |
*/
|
|
ali@24
|
18 |
|
|
ali@24
|
19 |
#include "config.h"
|
|
ali@24
|
20 |
#include <stdlib.h>
|
|
ali@24
|
21 |
#include <string.h>
|
|
ali@24
|
22 |
#include <errno.h>
|
|
ali@24
|
23 |
#include <glib.h>
|
|
ali@24
|
24 |
#include <gio/gio.h>
|
|
ali@24
|
25 |
#include <gtk/gtk.h>
|
|
ali@24
|
26 |
#include <plover/plover.h>
|
|
ali@24
|
27 |
#include <plover/transaction.h>
|
|
ali@24
|
28 |
#include <plover/packageset.h>
|
|
ali@24
|
29 |
#include <plover-gtk/transactionhelper.h>
|
|
ali@24
|
30 |
#include "app-manager.h"
|
|
ali@24
|
31 |
|
|
ali@24
|
32 |
gboolean setup(PloverPackageSet *installed,const char *base)
|
|
ali@24
|
33 |
{
|
|
ali@24
|
34 |
gchar *s;
|
|
ali@24
|
35 |
const char *prefix;
|
|
ali@24
|
36 |
GError *error=NULL;
|
|
ali@24
|
37 |
static PloverTransactionHelper *helper=NULL;
|
|
ali@24
|
38 |
if (!helper)
|
|
ali@24
|
39 |
{
|
|
ali@24
|
40 |
helper=plover_transaction_helper_new(ui);
|
|
ali@24
|
41 |
plover_transaction_helper_set_installed(helper,installed);
|
|
ali@24
|
42 |
plover_transaction_helper_set_base(helper,base);
|
|
ali@24
|
43 |
prefix=plover_transaction_helper_get_prefix(helper,&error);
|
|
ali@24
|
44 |
if (error)
|
|
ali@24
|
45 |
g_clear_error(&error);
|
|
ali@24
|
46 |
else
|
|
ali@24
|
47 |
{
|
|
ali@24
|
48 |
s=g_strconcat(prefix?prefix:"","/var/log/setup",NULL);
|
|
ali@24
|
49 |
plover_log_open(s);
|
|
ali@24
|
50 |
g_free(s);
|
|
ali@24
|
51 |
}
|
|
ali@24
|
52 |
plover_transaction_helper_set_check_vendor(helper,TRUE);
|
|
ali@24
|
53 |
g_signal_connect(helper,"close",G_CALLBACK(gtk_main_quit),NULL);
|
|
ali@24
|
54 |
}
|
|
ali@24
|
55 |
if (!plover_transaction_helper_get_visible(helper))
|
|
ali@24
|
56 |
{
|
|
ali@24
|
57 |
if (!plover_transaction_helper_install_group(helper,"base",&error))
|
|
ali@24
|
58 |
{
|
|
ali@24
|
59 |
if (g_error_matches(error,PLOVER_GENERAL_ERROR,
|
|
ali@24
|
60 |
PLOVER_GENERAL_ERROR_NO_WORK))
|
|
ali@24
|
61 |
{
|
|
ali@24
|
62 |
g_error_free(error);
|
|
ali@24
|
63 |
error=g_error_new_literal(PLOVER_GENERAL_ERROR,
|
|
ali@24
|
64 |
PLOVER_GENERAL_ERROR_NO_WORK,
|
|
ali@24
|
65 |
"All packages already installed");
|
|
ali@24
|
66 |
plover_transaction_helper_set_error(helper,error,
|
|
ali@24
|
67 |
"Software installation");
|
|
ali@24
|
68 |
}
|
|
ali@24
|
69 |
else if (g_error_matches(error,PLOVER_GENERAL_ERROR,
|
|
ali@24
|
70 |
PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET))
|
|
ali@24
|
71 |
{
|
|
ali@24
|
72 |
g_error_free(error);
|
|
ali@24
|
73 |
error=g_error_new_literal(PLOVER_GENERAL_ERROR,
|
|
ali@24
|
74 |
PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET,
|
|
ali@24
|
75 |
"Software cannot be installed because of missing updates. "
|
|
ali@24
|
76 |
"Installing all updates first should resolve this problem");
|
|
ali@24
|
77 |
plover_transaction_helper_set_error(helper,error,
|
|
ali@24
|
78 |
"Software installation failed");
|
|
ali@24
|
79 |
}
|
|
ali@24
|
80 |
else
|
|
ali@24
|
81 |
plover_transaction_helper_set_error(helper,error,
|
|
ali@24
|
82 |
"Software installation failed");
|
|
ali@24
|
83 |
g_error_free(error);
|
|
ali@24
|
84 |
}
|
|
ali@24
|
85 |
}
|
|
ali@24
|
86 |
plover_transaction_helper_present(helper);
|
|
ali@24
|
87 |
return TRUE;
|
|
ali@24
|
88 |
}
|