From b7d26b9ccaf38340afb638a92902e2400309378c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Tue, 16 May 2000 17:54:00 -0700
Subject: [PATCH] prefix=... and --new-style should now work with the NT binary
 install

Rev: bin/install.pike:1.56
Rev: src/uncompressor.c:1.3
---
 bin/install.pike   | 36 +++++++++++++++++++---
 src/uncompressor.c | 74 +++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 95 insertions(+), 15 deletions(-)

diff --git a/bin/install.pike b/bin/install.pike
index 994d6d7144..d78a270412 100644
--- a/bin/install.pike
+++ b/bin/install.pike
@@ -56,9 +56,21 @@ void status1(string fmt, mixed ... args)
   write("%s\n",sprintf(fmt,@args));
 }
 
+string some_strerror(int err)
+{
+  string ret;
+#if constant(strerror)  
+  ret=strerror(err);
+#endif
+  if(!ret || search("unknown error",lower_case(ret))!=-1)
+    ret=sprintf("errno=%d",err);
+
+  return ret;
+}
 
 void fail(string fmt, mixed ... args)
 {
+  int err=errno();
 #if defined(USE_GTK) && constant(GTK.parse_rc)
   if(label1)
   {
@@ -75,8 +87,9 @@ void fail(string fmt, mixed ... args)
 
 
   if(last_len) write("\n");
-  Stdio.perror(sprintf(fmt,@args));
-  werror("**Installation failed.\n");
+  werror("%s: %s\n",sprintf(fmt,@args),some_strerror(err));
+  werror("Current directory = %s\n",getcwd());
+  werror("**Installation failed..\n");
   exit(1);
 }
 
@@ -417,7 +430,8 @@ void do_export()
     RELAY(SRCDIR)
     RELAY(TMP_BINDIR)
     RELAY(MANDIR_SRC)
-    " TMP_BUILDDIR="+translate("", translator)
+    " TMP_BUILDDIR="+translate("", translator)+
+    " $" // $ = @argv
     ;
   
   p->write("s%4c%s",strlen(cmd),cmd);
@@ -906,10 +920,18 @@ int pre_install(array(string) argv)
 	    "   Welcome to the interactive "+version()+
 	    " installation script.\n"
 	    "\n"
+#ifndef __NT__
 	    "   The script will guide you through the installation process by asking\n"
 	    "   a few questions. Whenever you input a path or a filename, you may use\n"
 	    "   the <tab> key to perform filename completion. You will be able to\n"
 	    "   confirm your settings before the installation begin.\n"
+
+#else
+
+	    "   The script will guide you through the installation process by asking\n"
+	    "   a few questions.  You will be able to confirm your settings before\n"
+	    "   the installation begin.\n"
+#endif
 	    );
       
       interactive=ReadInteractive();
@@ -922,13 +944,19 @@ int pre_install(array(string) argv)
 //	if(!vars->prefix)
 	prefix=interactive->edit_directory(prefix,"Install prefix: ");
 	prefix = make_absolute_path(prefix);
-	
+
 	if(!vars->pike_name)
 	{
+#if constant(symlink)	
 	  bin_path=interactive->edit_filename
 		   (combine_path(vars->exec_prefix ||
 				 combine_path(prefix, "bin"),
 				 "pike"), "Pike binary name: ");
+#else
+	  bin_path=combine_path("/",getcwd(),prefix,"pike",
+				replace(version()-"Pike v"," release ","."),
+				"bin","pike");
+#endif
 	}
 
 	bin_path = make_absolute_path(bin_path);
diff --git a/src/uncompressor.c b/src/uncompressor.c
index 13323b3dee..34214d5e97 100644
--- a/src/uncompressor.c
+++ b/src/uncompressor.c
@@ -24,6 +24,8 @@
 
 #define FEND(X,Y) (strchr(X,Y)?strchr(X,Y):(X)+strlen(X))
 
+/* #define DEBUG */
+
 
 gzFile gz;
 
@@ -55,7 +57,7 @@ static unsigned int read_int(void)
 #endif
 
 
-void my_uncompress(char *file)
+void my_uncompress(char *file,int argc, char **argv)
 {
   unsigned int len;
   char buffer[8192];
@@ -92,7 +94,9 @@ void my_uncompress(char *file)
     perror("chdir");
     exit(1);
   }
-/*  fprintf(stderr,"Changing dir to %s\n",d); */
+#ifdef DEBUG
+  fprintf(stderr,"Changing dir to %s\n",d);
+#endif
 
   while(1)
   {
@@ -102,13 +106,17 @@ void my_uncompress(char *file)
     GR(type);
 
     len=read_int();
-/*    fprintf(stderr,"namelen=%d\n",len); */
+#ifdef DEBUG
+    fprintf(stderr,"namelen=%d\n",len);
+#endif
     
     gr(buffer, len);
     buffer[len]=0;
     
 
-/*    fprintf(stderr,"Type %c: %s\n",type,buffer); */
+#ifdef DEBUG
+    fprintf(stderr,"Type %c: %s\n",type,buffer);
+#endif
 
    switch(type)
     {
@@ -120,7 +128,9 @@ void my_uncompress(char *file)
 	break;
 
       case 'e': /* setenv */
-/*	fprintf(stderr,"putenv(%s)\n",buffer); */
+#ifdef DEBUG
+	fprintf(stderr,"putenv(%s)\n",buffer);
+#endif
 	putenv(buffer);
 	break;
 	
@@ -132,7 +142,42 @@ void my_uncompress(char *file)
 	 * Add support for concatenating all the parameters
 	 * to this command
 	 */
-/*	fprintf(stderr,"system(%s)\n",buffer); */
+	if(buffer[strlen(buffer)-1]=='$')
+	{
+	  char *ptr=buffer+strlen(buffer)-1;
+	  int e;
+	  for(e=0;e<argc;e++)
+	  {
+	    char *c;
+	    fprintf(stderr,"argv[%d]=%s\n",e,argv[e]);
+
+	    *(ptr++)=' ';
+	    *(ptr++)='"';
+	    for(c=argv[e];*c;c++)
+	    {
+	      switch(*c)
+	      {
+		case '\\':
+#ifdef __NT__
+		  *(ptr++)='"';
+		  *(ptr++)='\\';
+		  *(ptr++)='\\';
+		  *(ptr++)='"';
+		  break;
+#endif		  
+		case '"':
+		  *(ptr++)='\\';
+		default:
+		  *(ptr++)=*c;
+	      }
+	    }
+	    *(ptr++)='"';
+	  }
+	  *(ptr++)=0;
+	}
+#ifdef DEBUG
+	fprintf(stderr,"system(%s)\n",buffer);
+#endif
 	system(buffer);
 	break;
 	
@@ -147,7 +192,9 @@ void my_uncompress(char *file)
       case 'f': /* file */
       {
 	FILE *f;
-	/* fprintf(stderr,"file(%s)\n",buffer); */
+#ifdef DEBUG
+	fprintf(stderr,"file(%s)\n",buffer);
+#endif
 	f=fopen(buffer,"wb");
 	if(!f)
 	{
@@ -176,10 +223,15 @@ void my_uncompress(char *file)
       break;
       
       case 'D':
-/*	fprintf(stderr,"unlink(%s)\n",buffer); */
+#ifdef DEBUG
+	fprintf(stderr,"unlink(%s)\n",buffer);
+#endif
 	if(unlink(buffer)<0 && rmdir(buffer)<0)
 	{
+#ifdef DEBUG
+	  fprintf(stderr,"Failed to delete %s\n",buffer);
 	  perror("unlink");
+#endif
 /*	  exit(1); */
 	}
 	break;
@@ -204,14 +256,14 @@ int main(int argc, char **argv)
 	     sizeof(tmp),
 	     tmp,
 	     &file))
-    my_uncompress(tmp);
+    my_uncompress(tmp,argc-1,argv+1);
 #else
   char *path=getenv("PATH");
   char *pos;
   file=argv[0];
   if(!path || strchr(file, SLASH))
   {
-    my_uncompress(file);
+    my_uncompress(file,argc-1,argv-1);
     perror("open");
     exit(1);
   }
@@ -241,7 +293,7 @@ int main(int argc, char **argv)
       ptr+=strlen(file);
       *ptr=0;
 
-      my_uncompress(tmp);
+      my_uncompress(tmp,argc-1,argv+1);
     }
     if(!*next) break;
     pos=next+1;
-- 
GitLab