cvs commit: ALFS/nALFS/src/handlers execute.c remove.c

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Sat Feb 7 21:12:35 PST 2004


kpfleming    04/02/07 22:12:35

  Modified:    nALFS/src backend.c handlers.c handlers.h
               nALFS/src/handlers execute.c remove.c
  Log:
  implement alloc_stage_shell, which searches enclosing <stage> elements for a <shell> element, defaulting to "sh" if none is found
  convert <execute> syntax 3.2 to use execute_shell_command for normal commands
  modify execute_shell_command to use alloc_stage_shell to get desired shell name
  add alloc_base_dir_force declaration to handlers.h
  
  Revision  Changes    Path
  1.9       +11 -2     ALFS/nALFS/src/backend.c
  
  Index: backend.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/backend.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- backend.c	8 Feb 2004 03:15:09 -0000	1.8
  +++ backend.c	8 Feb 2004 05:12:35 -0000	1.9
  @@ -33,6 +33,7 @@
   #include <time.h>
   #include <sys/types.h>
   #include <sys/wait.h>
  +#include <libgen.h>
   
   #ifdef HAVE_CONFIG_H
   #include <config.h>
  @@ -294,6 +295,8 @@
   	int status = 0;
   	char command[MAX_COMMAND_LEN];
   	char *args[4];
  +	char *shell;
  +	char *temp;
   
   
   	va_start(ap, format);
  @@ -301,11 +304,17 @@
   	va_end(ap);
   
   	if (status > -1 && status < (int) sizeof command) {
  -		args[0] = "sh";
  +		shell = alloc_stage_shell(element);
  +		/* make a copy of shell because basename may modify it */
  +		temp = xstrdup(shell);
  +		args[0] = xstrdup(basename(temp));
   		args[1] = "-c";
   		args[2] = command;
   		args[3] = NULL;
  -		status = execute_direct_command("sh", args);
  +		status = execute_direct_command(shell, args);
  +		xfree(args[0]);
  +		xfree(temp);
  +		xfree(shell);
   	} else {
   		Nprint_err("System command is too long.");
   		return -1;
  
  
  
  1.14      +22 -0     ALFS/nALFS/src/handlers.c
  
  Index: handlers.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- handlers.c	3 Feb 2004 20:25:35 -0000	1.13
  +++ handlers.c	8 Feb 2004 05:12:35 -0000	1.14
  @@ -402,6 +402,28 @@
   	return dir;
   }
   
  +char *alloc_stage_shell(element_s *el)
  +{
  +	element_s *s;
  +	char *shell = "sh";
  +
  +	for (s = el->parent; s; s = s->parent) {
  +		if (Is_element_name(s, "stage")) {
  +			element_s *sinfo;
  +
  +			if ((sinfo = first_param("stageinfo", s)) == NULL) {
  +				continue;
  +			}
  +
  +			if ((shell = alloc_trimmed_param_value("shell", sinfo))) {
  +				return shell;
  +			}
  +		}
  +	}
  +
  +	return shell;
  +}
  +
   /* Used by the old syntax (2.0). */
   int option_exists(const char *option, element_s *element)
   {
  
  
  
  1.9       +2 -0      ALFS/nALFS/src/handlers.h
  
  Index: handlers.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- handlers.h	6 Feb 2004 05:54:36 -0000	1.8
  +++ handlers.h	8 Feb 2004 05:12:35 -0000	1.9
  @@ -94,6 +94,8 @@
   
   char *alloc_base_dir(element_s *el);
   char *alloc_base_dir_new(element_s *el);
  +char *alloc_base_dir_force(element_s *el);
  +char *alloc_stage_shell(element_s *el);
   int option_exists(const char *option, element_s *element);
   void check_options(int total, int *opts, const char *string_, element_s *el);
   char *append_param_elements(char **string, element_s *el);
  
  
  
  1.19      +1 -1      ALFS/nALFS/src/handlers/execute.c
  
  Index: execute.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/execute.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- execute.c	8 Feb 2004 03:15:09 -0000	1.18
  +++ execute.c	8 Feb 2004 05:12:35 -0000	1.19
  @@ -201,7 +201,7 @@
   		append_param_elements(&command, el);
   		Nprint_h("Executing system command in %s:", base);
   		Nprint_h("    %s", command);
  -		status = execute_command("%s", command);
  +		status = execute_shell_command(el, "%s", command);
   		xfree(command);
   	} else {
   		FILE *temp_script;
  
  
  
  1.16      +1 -1      ALFS/nALFS/src/handlers/remove.c
  
  Index: remove.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/remove.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- remove.c	30 Jan 2004 21:55:43 -0000	1.15
  +++ remove.c	8 Feb 2004 05:12:35 -0000	1.16
  @@ -236,6 +236,6 @@
   	},
   #endif
   	{
  -		NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0
  +		.name = NULL
   	}
   };
  
  
  



More information about the alfs-log mailing list