[Slad] SLADinstaller Patch for windows filenames and process calls
Jan-Oliver Wagner
jan at intevation.de
Wed Mar 1 11:19:23 UTC 2006
Hi,
attached is a patch that care for Windows filenames
and correct system calls for tar command.
The latter ist especially important for
binary installations of SLADinstaller on Systems
without Cygwin.
Best
Jan
--
Jan-Oliver Wagner: www.intevation.de/~jan | GISpatcher: www.gispatcher.de
Kolab Konsortium : www.kolab-konsortium.de | Thuban : thuban.intevation.org
Intevation GmbH : www.intevation.de | Kolab : www.kolab.org
FreeGIS : www.freegis.org | GAV : www.grass-verein.de
-------------- next part --------------
Index: tools.cpp
===================================================================
RCS file: /anoncvs/sladinstaller/tools.cpp,v
retrieving revision 1.22
diff -u -3 -p -r1.22 tools.cpp
--- tools.cpp 13 Feb 2006 21:56:37 -0000 1.22
+++ tools.cpp 1 Mar 2006 11:16:49 -0000
@@ -1,5 +1,9 @@
#define _XOPEN_SOURCE /* glibc2 needs this */
+#ifdef CYGWIN
+#include <sys/cygwin.h>
+#endif
+
#include "memorymap.hpp"
#include "tools.hpp"
#include <arpa/inet.h>
@@ -22,6 +26,12 @@
#include <unistd.h>
#include <utime.h>
#include <sstream>
+#include <iosfwd>
+
+#ifdef CYGWIN
+#include <gtk/gtk.h>
+#undef pipe
+#endif
#define _(a) gettext (a)
@@ -349,7 +359,11 @@ std::string installonclient(void *ssh_se
// prepare some variables
std::string filename=pkg;
+#ifdef CYGWIN
+ unsigned pos=filename.find_last_of('\\');
+#else
unsigned pos=filename.find_last_of('/');
+#endif
if(pos!=std::string::npos)
filename.erase(0, pos+1);
@@ -623,21 +637,63 @@ mypopen(const char * dir, char ** argv,
std::string checkpackage(const std::string& pkg)
{
+#ifdef CYGWIN
+ char posixname_gzip_exe[PATH_MAX];
+ char posixname_bzip2_exe[PATH_MAX];
+ char posixname_pkg[PATH_MAX];
+
+ char * c_bin_dir = g_win32_get_package_installation_subdirectory(NULL,
+ NULL, "bin");
+ std::string bin_dir(c_bin_dir);
+ g_free(c_bin_dir);
+
+ std::string gzip_exe = bin_dir + "\\gzip.exe";
+ std::string bz2_exe = bin_dir + "\\bzip2.exe";
+
+ cygwin_conv_to_full_posix_path(gzip_exe.c_str(), posixname_gzip_exe);
+ cygwin_conv_to_full_posix_path(bz2_exe.c_str(), posixname_bzip2_exe);
+ cygwin_conv_to_full_posix_path(pkg.c_str(), posixname_pkg);
+
+ std::string gzip_cmd = "--use-compress-program=" + std::string(posixname_gzip_exe);
+ std::string bzip2_cmd = "--use-compress-program=" + std::string(posixname_bzip2_exe);
+#else
+ std::string gzip_cmd = "tfz";
+ std::string bzip2_cmd = "tfj";
+ std::string bin_dir(".");
+#endif
+
LOG(std::string("\n")+_("check")+' '+pkg+'\n');
- std::string tarcmd="tf";
+ std::string tarcmd="-tf";
+ std::string compress_cmd = "";
+
if(tolower(pkg[pkg.size()-2])=='g' && tolower(pkg[pkg.size()-1])=='z')
+#ifdef CYGWIN
+ compress_cmd = gzip_cmd;
+#else
tarcmd="tfz";
- if(tolower(pkg[pkg.size()-3])=='b' && tolower(pkg[pkg.size()-2])=='z' && pkg[pkg.size()-1]=='2')
+#endif
+ if(tolower(pkg[pkg.size()-3])=='b' && tolower(pkg[pkg.size()-2])=='z'
+ && pkg[pkg.size()-1]=='2')
+#ifdef CYGWIN
+ compress_cmd = bzip2_cmd;
+#else
tarcmd="tfj";
+#endif
- char * cmd[] = { "tar", (char*)tarcmd.c_str(), (char *)pkg.c_str(), 0};
+#ifdef CYGWIN
+ char * cmd[] = { "tar", (char *)compress_cmd.c_str(), (char*)tarcmd.c_str(),
+ posixname_pkg, 0 };
+ std::string cmd_str = std::string(cmd[0]) + ' ' + cmd[1] + ' ' + cmd[2] + ' ' + cmd[3];
+#else
+ char * cmd[] = { "tar", (char*)tarcmd.c_str(), (char *)pkg.c_str(), 0 };
+ std::string cmd_str = std::string(cmd[0]) + ' ' + cmd[1] + ' ' + cmd[2];
+#endif
pid_t tar_pid;
- LOG(std::string("\ntar command: ")+cmd[0]+" "+ cmd[1]+" "+ cmd[2]);
- FILE *f=mypopen(".", cmd, &tar_pid);
+ LOG(std::string("\ntar command: ")+cmd_str.c_str());
+ FILE *f=mypopen(bin_dir.c_str(), cmd, &tar_pid);
if(!f)
- return std::string(SLAD_ERROR) +' '+_("could not execute")+": "
- +cmd[0]+" "+ cmd[1]+" "+ cmd[2];
+ return std::string(SLAD_ERROR) +' '+_("could not execute")+": " + cmd_str.c_str();
bool ok=false;
std::string dir;
while(!feof(f))
More information about the Slad
mailing list