Support parallel installations. The idea is that for CAD screener, we want
to be able to install this on the same machine as a standard AVOT setup
(most notably for John's laptop). To allow for the possibility of a second
application that might have the same requirements, we add the concept of
vendor-specific distributions. Thus we can have one distribution for CAD
screener and one for The Next Big Thing. It doesn't seem trivial to have
both CAD screener and AVOT under the same vendor tag so we'll have to have
AVOT under "City Occupational" and CAD screener under "City Occupational Ltd"
or some such kludge.
Most of this is done although we are very short of test cases (in particular
we don't test that it's actually possible to install CAD screener in parallel
with AVOT or to update either of them once installed, which is fundamental).
We also have a lot of baggage left over, including an intercept of razor_set.
The problem that this was introduced to debug has been fixed but it looks
like there are a number of memory leaks which it might be useful to help
track down so it has been left in place for now.
There is still a lot of confusion in plover between path-based and URI-based
API. We should review the API, decide what we want and have a general clear up.
There is also confusion as to the purpose of RAZOR_ROOT (and meaning; path or
URI). This is not used at all in librazor (although it is used in razor.exe).
Ideally we shouldn't use it in plover or plover-gtk either although again, we
might want to support it or an equivalent in (some of) the various executables.
Work that would still to nice to do for CAD screener:
- uninstall (ideally as an installed program that hooks into Add/Remove programs
but even re-running the installer would be acceptable).
- xz support (smaller packages).
- repomd.xml and xml:base (would be needed for an Internet installer).
- graphical installer.
2 * Copyright (C) 2014 J. Ali Harlow <ali@juiblex.co.uk>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <whelk/whelk.h>
30 #include <plover/plover.h>
31 #include <plover/package.h>
32 #include <plover/packageset.h>
33 #include <plover-gtk/transactionhelper.h>
34 #include <plover-gtk/stockicons.h>
36 LUALIB_API int luaopen_posix(lua_State *L);
38 #define LOGO_NAME "application-x-redhat-package-manager"
40 gboolean install(PloverPackageSet *installed,const char *path)
43 const char *prefix,*unsatisfied;
44 const char *filenames[2];
46 GSList *packages,*lnk;
47 struct plover_vector *selected_packages;
48 PloverPackage *package;
49 PloverPackageSet *set;
50 PloverRepository *upstream;
51 PloverTransactionHelper *helper;
52 helper=plover_transaction_helper_new(NULL);
53 g_signal_connect(helper,"close",G_CALLBACK(gtk_main_quit),NULL);
54 plover_transaction_helper_set_installed(helper,installed);
55 if (plover_transaction_helper_get_error(helper,NULL))
57 plover_transaction_helper_present(helper);
62 upstream=plover_repository_new_from_files(filenames,&error);
64 plover_transaction_helper_set_upstream(helper,upstream);
67 plover_transaction_helper_set_error(helper,error,
68 "Software installation failed");
69 g_clear_error(&error);
70 plover_transaction_helper_present(helper);
73 prefix=plover_transaction_helper_get_prefix(helper,&error);
75 g_clear_error(&error);
78 s=g_strconcat(prefix?prefix:"","/var/log/open",NULL);
82 set=plover_repository_get_package_set(upstream);
83 packages=plover_package_set_get_packages(set);
84 selected_packages=plover_vector_new();
85 for(lnk=packages;lnk;lnk=lnk->next)
87 package=PLOVER_PACKAGE(lnk->data);
88 plover_vector_append(selected_packages,
89 plover_package_get_name(package));
91 if (!plover_transaction_helper_install_packages(helper,selected_packages,
94 if (g_error_matches(error,PLOVER_GENERAL_ERROR,
95 PLOVER_GENERAL_ERROR_NO_WORK))
98 error=g_error_new_literal(PLOVER_GENERAL_ERROR,
99 PLOVER_GENERAL_ERROR_NO_WORK,
100 "All packages already installed");
101 plover_transaction_helper_set_error(helper,error,
102 "Software installation");
104 else if (g_error_matches(error,PLOVER_GENERAL_ERROR,
105 PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET))
108 unsatisfied=plover_transaction_helper_get_unsatisfied(helper);
109 error=g_error_new(PLOVER_GENERAL_ERROR,
110 PLOVER_GENERAL_ERROR_REQUIREMENTS_NOT_MET,
111 "Software cannot be installed because the following requirements "
112 "were not met:\n\n%s",unsatisfied);
113 plover_transaction_helper_set_error(helper,error,
114 "Software installation failed");
117 plover_transaction_helper_set_error(helper,error,
118 "Software installation failed");
121 plover_vector_free(selected_packages);
122 g_object_unref(upstream);
123 plover_transaction_helper_present(helper);
127 static void install_icons(void)
129 GtkIconSet *icon_set;
130 plover_icons_add_to_stock("mimetypes",LOGO_NAME);
131 icon_set=gtk_icon_factory_lookup_default(LOGO_NAME);
132 gtk_window_set_default_icon_name(LOGO_NAME);
135 int main(int argc,char **argv)
138 gchar *install_path=NULL;
139 PloverPackageSet *set;
142 gchar *s,*t,*contents;
143 GSList *objects,*lnk;
145 GOptionEntry options[]={
146 {"install",0,0,G_OPTION_ARG_FILENAME,&install_path,
147 "Install an RPM","path"},
152 * plover-open is normally a GUI application, but rpm scripts may well
153 * call console applications and it looks ugly if console windows keep
154 * popping up. Avoid this by allocating our own console and hiding it.
156 * - If plover-open is a console application (typically for debugging),
157 * then skip this step.
158 * - Call ShowWindow twice to negate special handling on first call.
160 if (!GetConsoleWindow())
163 ShowWindow(GetConsoleWindow(),SW_HIDE);
164 ShowWindow(GetConsoleWindow(),SW_HIDE);
167 plover_exception_handler_init();
168 razor_set_lua_loader("posix",(void (*)())luaopen_posix);
169 razor_set_lua_loader("whelk",(void (*)())luaopen_whelk);
170 if (!gtk_init_with_args(&argc,&argv,NULL,options,NULL,&err))
172 g_printerr("%s\n",err->message);
177 ui=gtk_builder_new();
178 if (!g_file_get_contents("plover-open.ui",&contents,&len,&err) &&
179 g_error_matches(err,G_FILE_ERROR,G_FILE_ERROR_NOENT))
182 t=g_win32_get_package_installation_directory_of_module(NULL);
183 s=g_build_filename(t,"share","plover","plover-open.ui",NULL);
186 s=g_build_filename(PLOVER_DATADIR,"plover-open.ui",NULL);
189 (void)g_file_get_contents(s,&contents,&len,&err);
194 (void)gtk_builder_add_from_string(ui,contents,len,&err);
199 g_error("%s",err->message);
202 gtk_builder_connect_signals(ui,NULL);
204 set=plover_package_set_new();
205 (void)plover_package_set_open(set,"",TRUE,NULL);
207 if (install(set,install_path))
209 g_clear_object(&set);
211 objects=gtk_builder_get_objects(ui);
212 for(lnk=objects;lnk;lnk=lnk->next)
213 if (GTK_IS_WIDGET(lnk->data) &&
214 gtk_widget_is_toplevel(GTK_WIDGET(lnk->data)))
215 gtk_widget_destroy(GTK_WIDGET(lnk->data));
216 g_slist_free(objects);
219 g_free(install_path);