Main Page | Data Structures | File List | Data Fields | Globals

install.c

Go to the documentation of this file.
00001 /*
00002  * luau (Lib Update/Auto-Update): Simple Update Library
00003  * Copyright (C) 2003  David Eklund
00004  *
00005  * - This library is free software; you can redistribute it and/or             -
00006  * - modify it under the terms of the GNU Lesser General Public                -
00007  * - License as published by the Free Software Foundation; either              -
00008  * - version 2.1 of the License, or (at your option) any later version.        -
00009  * -                                                                           -
00010  * - This library is distributed in the hope that it will be useful,           -
00011  * - but WITHOUT ANY WARRANTY; without even the implied warranty of            -
00012  * - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         -
00013  * - Lesser General Public License for more details.                           -
00014  * -                                                                           -
00015  * - You should have received a copy of the GNU Lesser General Public          -
00016  * - License along with this library; if not, write to the Free Software       -
00017  * - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA -
00018  */
00019 
00020 #ifdef HAVE_CONFIG_H
00021 #  include <config.h>
00022 #endif
00023 
00024 #include <glib.h>
00025 
00026 #include <stdlib.h>
00027 #include <string.h>
00028 #include <sys/types.h>
00029 #include <sys/wait.h>
00030 
00031 #include "util.h"
00032 #include "error.h"
00033 
00034 #include "install.h"
00035 #ifdef WITH_DMALLOC
00036 #  include <dmalloc.h>
00037 #endif
00038 
00039 gboolean
00040 luau_install_rpm(const char *filename) {
00041         int ret, len;
00042         char *execString;
00043         gboolean result;
00044         
00045         len = strlen(filename) + 30;
00046         execString = lutil_createString(len);
00047         
00048         snprintf(execString, len, "rpm -U --nodeps %s", filename);
00049         
00050         ret = system(execString);
00051         
00052         if (ret == -1) {
00053                 ERROR("Couldn't execute command: %s", execString);
00054                 result = FALSE;
00055         } else if (WEXITSTATUS(ret) == 127) {
00056                 ERROR("Couldn't install rpm: 'rpm' command not found by shell!");
00057                 result = FALSE;
00058         } else if (WEXITSTATUS(ret) != 0) {
00059                 ERROR("RPM Command failed: %s", execString);
00060                 result = FALSE;
00061         } else {
00062                 result = TRUE;
00063         }
00064         
00065         g_free(execString);
00066                 
00067         return result;
00068 }
00069 
00070 gboolean luau_install_deb(const char *filename) {
00071         int ret, len;
00072         char *execString;
00073         gboolean result;
00074         
00075         len = strlen(filename) + 20;
00076         execString = lutil_createString(len);
00077         
00078         snprintf(execString, len, "dpkg -i %s", filename);
00079         
00080         ret = system(execString);
00081         
00082         if (ret == -1) {
00083                 ERROR("Couldn't execute command: %s", execString);
00084                 result = FALSE;
00085         } else if (WEXITSTATUS(ret) == 127) {
00086                 ERROR("Couldn't install deb package: 'dpkg' command not found by shell!");
00087                 result = FALSE;
00088         } else if (WEXITSTATUS(ret) != 0) {
00089                 ERROR("Dpkg Command failed: %s", execString);
00090                 result = FALSE;
00091         } else {
00092                 result = TRUE;
00093         }
00094         
00095         g_free(execString);
00096         
00097         return result;
00098 }
00099 
00100 gboolean luau_install_src(const char *filename) {
00101         ERROR("Source package cannot be installed.  You must download and install them by hand");
00102         return FALSE;
00103 }
00104 
00105 gboolean luau_install_exec(const char *filename) {
00106         int ret;
00107         gboolean result;
00108         
00109         ret = system(filename);
00110         
00111         if (ret == -1) {
00112                 ERROR("Couldn't execute command: %s", filename);
00113                 result = FALSE;
00114         } else if (WEXITSTATUS(ret) == 127) {
00115                 ERROR("Execution failed: could not find specified file");
00116                 result = FALSE;
00117         } else if (WEXITSTATUS(ret) != 0) {
00118                 ERROR("Execution failed.  See STDOUT for details");
00119                 result = FALSE;
00120         } else {
00121                 result = TRUE;
00122         }
00123         
00124         return result;
00125 }
00126 
00127 gboolean luau_install_autopkg(const char *filename) {
00128         return luau_install_exec(filename);
00129 }

Generated on Mon Apr 12 22:17:10 2004 for luau by doxygen 1.3.2