ali@24: /* ali@24: * Copyright (C) 2014 J. Ali Harlow ali@24: * ali@24: * This program is free software; you can redistribute it and/or modify ali@24: * it under the terms of the GNU General Public License as published by ali@24: * the Free Software Foundation; either version 2 of the License, or ali@24: * (at your option) any later version. ali@24: * ali@24: * This program is distributed in the hope that it will be useful, ali@24: * but WITHOUT ANY WARRANTY; without even the implied warranty of ali@24: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ali@24: * GNU General Public License for more details. ali@24: * ali@24: * You should have received a copy of the GNU General Public License along ali@24: * with this program; if not, write to the Free Software Foundation, Inc., ali@24: * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ali@24: */ ali@24: ali@24: #include "config.h" ali@24: #include ali@24: #include ali@24: #include ali@24: #include ali@24: #include ali@24: #include ali@24: #include ali@24: #include ali@24: #include ali@24: #include ali@24: #include "app-manager.h" ali@24: ali@24: gboolean update(PloverPackageSet *installed,const char *base) ali@24: { ali@24: gchar *s; ali@24: const char *prefix; ali@24: GError *error=NULL; ali@24: static PloverTransactionHelper *helper=NULL; ali@24: if (!helper) ali@24: { ali@24: helper=plover_transaction_helper_new(ui); ali@24: plover_transaction_helper_set_installed(helper,installed); ali@24: plover_transaction_helper_set_base(helper,base); ali@24: prefix=plover_transaction_helper_get_prefix(helper,&error); ali@24: if (error) ali@24: g_clear_error(&error); ali@24: else ali@24: { ali@24: s=g_strconcat(prefix?prefix:"","/var/log/update",NULL); ali@24: plover_log_open(s); ali@24: g_free(s); ali@24: } ali@24: plover_transaction_helper_set_check_vendor(helper,TRUE); ali@24: g_signal_connect(helper,"close",G_CALLBACK(gtk_main_quit),NULL); ali@24: } ali@24: if (!plover_transaction_helper_get_visible(helper)) ali@24: { ali@24: if (!plover_transaction_helper_update(helper,&error)) ali@24: { ali@24: if (g_error_matches(error,PLOVER_GENERAL_ERROR, ali@24: PLOVER_GENERAL_ERROR_NO_WORK)) ali@24: { ali@24: g_error_free(error); ali@24: error=g_error_new_literal(PLOVER_GENERAL_ERROR, ali@24: PLOVER_GENERAL_ERROR_NO_WORK, ali@24: "All relevant updates already applied"); ali@24: plover_transaction_helper_set_error(helper,error, ali@24: "Software update"); ali@24: } ali@24: else if (g_error_matches(error,PLOVER_GENERAL_ERROR, ali@24: PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET)) ali@24: { ali@24: g_error_free(error); ali@24: error=g_error_new_literal(PLOVER_GENERAL_ERROR, ali@24: PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET, ali@24: "Updates cannot be applied because some earlier updates are " ali@24: "missing. Installing updates in sequence should resolve this " ali@24: "problem"); ali@24: plover_transaction_helper_set_error(helper,error, ali@24: "Software update failed"); ali@24: } ali@24: else ali@24: plover_transaction_helper_set_error(helper,error, ali@24: "Software update failed"); ali@24: g_error_free(error); ali@24: } ali@24: } ali@24: plover_transaction_helper_present(helper); ali@24: return TRUE; ali@24: }