1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/app-manager/setup.c Thu Jun 16 18:00:21 2016 +0100
1.3 @@ -0,0 +1,88 @@
1.4 +/*
1.5 + * Copyright (C) 2014 J. Ali Harlow <ali@juiblex.co.uk>
1.6 + *
1.7 + * This program is free software; you can redistribute it and/or modify
1.8 + * it under the terms of the GNU General Public License as published by
1.9 + * the Free Software Foundation; either version 2 of the License, or
1.10 + * (at your option) any later version.
1.11 + *
1.12 + * This program is distributed in the hope that it will be useful,
1.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 + * GNU General Public License for more details.
1.16 + *
1.17 + * You should have received a copy of the GNU General Public License along
1.18 + * with this program; if not, write to the Free Software Foundation, Inc.,
1.19 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1.20 + */
1.21 +
1.22 +#include "config.h"
1.23 +#include <stdlib.h>
1.24 +#include <string.h>
1.25 +#include <errno.h>
1.26 +#include <glib.h>
1.27 +#include <gio/gio.h>
1.28 +#include <gtk/gtk.h>
1.29 +#include <plover/plover.h>
1.30 +#include <plover/transaction.h>
1.31 +#include <plover/packageset.h>
1.32 +#include <plover-gtk/transactionhelper.h>
1.33 +#include "app-manager.h"
1.34 +
1.35 +gboolean setup(PloverPackageSet *installed,const char *base)
1.36 +{
1.37 + gchar *s;
1.38 + const char *prefix;
1.39 + GError *error=NULL;
1.40 + static PloverTransactionHelper *helper=NULL;
1.41 + if (!helper)
1.42 + {
1.43 + helper=plover_transaction_helper_new(ui);
1.44 + plover_transaction_helper_set_installed(helper,installed);
1.45 + plover_transaction_helper_set_base(helper,base);
1.46 + prefix=plover_transaction_helper_get_prefix(helper,&error);
1.47 + if (error)
1.48 + g_clear_error(&error);
1.49 + else
1.50 + {
1.51 + s=g_strconcat(prefix?prefix:"","/var/log/setup",NULL);
1.52 + plover_log_open(s);
1.53 + g_free(s);
1.54 + }
1.55 + plover_transaction_helper_set_check_vendor(helper,TRUE);
1.56 + g_signal_connect(helper,"close",G_CALLBACK(gtk_main_quit),NULL);
1.57 + }
1.58 + if (!plover_transaction_helper_get_visible(helper))
1.59 + {
1.60 + if (!plover_transaction_helper_install_group(helper,"base",&error))
1.61 + {
1.62 + if (g_error_matches(error,PLOVER_GENERAL_ERROR,
1.63 + PLOVER_GENERAL_ERROR_NO_WORK))
1.64 + {
1.65 + g_error_free(error);
1.66 + error=g_error_new_literal(PLOVER_GENERAL_ERROR,
1.67 + PLOVER_GENERAL_ERROR_NO_WORK,
1.68 + "All packages already installed");
1.69 + plover_transaction_helper_set_error(helper,error,
1.70 + "Software installation");
1.71 + }
1.72 + else if (g_error_matches(error,PLOVER_GENERAL_ERROR,
1.73 + PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET))
1.74 + {
1.75 + g_error_free(error);
1.76 + error=g_error_new_literal(PLOVER_GENERAL_ERROR,
1.77 + PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET,
1.78 + "Software cannot be installed because of missing updates. "
1.79 + "Installing all updates first should resolve this problem");
1.80 + plover_transaction_helper_set_error(helper,error,
1.81 + "Software installation failed");
1.82 + }
1.83 + else
1.84 + plover_transaction_helper_set_error(helper,error,
1.85 + "Software installation failed");
1.86 + g_error_free(error);
1.87 + }
1.88 + }
1.89 + plover_transaction_helper_present(helper);
1.90 + return TRUE;
1.91 +}