cvs commit: ALFS/nALFS/src/handlers alfs.c build.c check.c chroot.c conditionals.c configure.c copy.c download.c execute.c link.c log.c make.c mkdir.c move.c owner.c ownership.c package.c patch.c permissions.c postbuild.c prebuild.c remove.c search_replace.c setenv.c stage.c stamp.c su.c textdump.c unpack.c

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Mon Feb 23 22:30:12 PST 2004


kpfleming    04/02/23 23:30:12

  Modified:    nALFS/src backend.c backend.h handlers.c handlers.h
               nALFS/src/handlers alfs.c build.c check.c chroot.c
                        conditionals.c configure.c copy.c download.c
                        execute.c link.c log.c make.c mkdir.c move.c
                        owner.c ownership.c package.c patch.c permissions.c
                        postbuild.c prebuild.c remove.c search_replace.c
                        setenv.c stage.c stamp.c su.c textdump.c unpack.c
  Log:
  clean up base dir handling in v3+ handlers
  ensure shelltests (for <if>) are run in current base dir
  convert alfs handler to new parsing method
  
  Revision  Changes    Path
  1.13      +1 -1      ALFS/nALFS/src/backend.c
  
  Index: backend.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/backend.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- backend.c	13 Feb 2004 02:46:53 -0000	1.12
  +++ backend.c	24 Feb 2004 06:30:11 -0000	1.13
  @@ -291,7 +291,7 @@
   	return status;
   }
   
  -int execute_command(element_s *element, const char *format, ...)
  +int execute_command(const element_s * const element, const char *format, ...)
   {
   	va_list ap;
   	int status = 0;
  
  
  
  1.6       +1 -1      ALFS/nALFS/src/backend.h
  
  Index: backend.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/backend.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- backend.h	11 Feb 2004 05:08:12 -0000	1.5
  +++ backend.h	24 Feb 2004 06:30:11 -0000	1.6
  @@ -43,7 +43,7 @@
   void fatal_backend_error(const char *format, ...);
   
   int execute_direct_command(const char *command, char *const argv[]);
  -int execute_command(element_s *element, const char *format, ...);
  +int execute_command(const element_s * const element, const char *format, ...);
   
   int do_execute_test_element(element_s *element, int *result);
   int execute_children(element_s *element);
  
  
  
  1.24      +16 -12    ALFS/nALFS/src/handlers.c
  
  Index: handlers.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- handlers.c	23 Feb 2004 21:19:35 -0000	1.23
  +++ handlers.c	24 Feb 2004 06:30:11 -0000	1.24
  @@ -52,14 +52,14 @@
   
   /* Embedded "handlers" for the root (profile) element and comment elements. */
   
  -static int root_main(element_s * const el)
  +static int root_main(const element_s * const el)
   {
   	(void) el;
   
   	return 0;
   }
   
  -static int comment_main(element_s * const el)
  +static int comment_main(const element_s * const el)
   {
   	(void) el;
   
  @@ -422,31 +422,35 @@
   	return xstrdup("/");
   }
   
  -/* Used by new syntax (3.0+). */
  -char *alloc_base_dir_new(const element_s * const el, const int default_root)
  +int change_to_base_dir(const element_s * const element,
  +		       const char * const local_base,
  +		       const int default_root)
   {
   	const element_s *s;
   	char *dir;
  +	int result;
   
  -	if ((dir = attr_value("base", el)) && strlen(dir)) {
  -		return xstrdup(dir);
  -	}
  +	if (local_base)
  +		return change_current_dir(local_base);
   
  -	for (s = el->parent; s; s = s->parent) {
  +	for (s = element->parent; s; s = s->parent) {
   		if (!s->handler)
   			continue;
   		if ((s->handler->data & HDATA_BASE) == 0)
   			continue;
   
   		dir  = s->handler->alloc_data(s, HDATA_BASE);
  -		if (dir)
  -			return dir;
  +		if (dir) {
  +			result = change_current_dir(dir);
  +			xfree(dir);
  +			return result;
  +		}
   	}
   
   	if (default_root) {
  -		return xstrdup("/");
  +		return change_current_dir("/");
   	} else {
  -		return NULL;
  +		return -1;
   	}
   }
   
  
  
  
  1.20      +6 -3      ALFS/nALFS/src/handlers.h
  
  Index: handlers.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers.h,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- handlers.h	23 Feb 2004 21:19:35 -0000	1.19
  +++ handlers.h	24 Feb 2004 06:30:11 -0000	1.20
  @@ -66,8 +66,8 @@
   
   typedef char *(*handler_data_f)(const element_s * const element,
   				const handler_data_e data_requested);
  -typedef int (*handler_f)(element_s * const element);
  -typedef int (*handler_test)(element_s * const element, int * const result);
  +typedef int (*handler_f)(const element_s * const element);
  +typedef int (*handler_test)(const element_s * const element, int * const result);
   typedef int (*handler_setup)(element_s * const element);
   typedef void (*handler_free)(const element_s * const element);
   typedef int (*handler_attribute)(const element_s * const element,
  @@ -144,7 +144,10 @@
   char *alloc_execute_command(element_s *el);
   
   char *alloc_base_dir(element_s *el);
  -char *alloc_base_dir_new(const element_s * const el, const int default_root);
  +
  +int change_to_base_dir(const element_s * const element, const char * const local_base, 
  +		       const int default_root);
  +
   char *alloc_stage_shell(const element_s * const el);
   int option_exists(const char *option, element_s *element);
   void check_options(int total, int *opts, const char *string_, element_s *el);
  
  
  
  1.17      +84 -2     ALFS/nALFS/src/handlers/alfs.c
  
  Index: alfs.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/alfs.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- alfs.c	24 Feb 2004 02:25:34 -0000	1.16
  +++ alfs.c	24 Feb 2004 06:30:11 -0000	1.17
  @@ -33,9 +33,72 @@
   #include "handlers.h"
   #include "backend.h"
   #include "nprint.h"
  +#include "utility.h"
   
   
  -static int alfs_main(element_s * const el)
  +enum alfs_attribute_types {
  +	ALFS_VERSION
  +};
  +
  +static const struct handler_attribute alfs_attributes[] = {
  +	{ .name = "version", .private = ALFS_VERSION },
  +        { .name = NULL }
  +};
  +
  +struct alfs_data {
  +	char *version;
  +};
  +
  +static int alfs_setup(element_s * const element)
  +{
  +	struct alfs_data *data;
  +
  +	if ((data = xmalloc(sizeof(struct alfs_data))) == NULL)
  +		return 1;
  +
  +	data->version = NULL;
  +	element->handler_data = data;
  +
  +	return 0;
  +};
  +
  +static void alfs_free(const element_s * const element)
  +{
  +	struct alfs_data *data = (struct alfs_data *) element->handler_data;
  +
  +	xfree(data->version);
  +	xfree(data);
  +}
  +
  +static int alfs_attribute(const element_s * const element,
  +			  const struct handler_attribute * const attr,
  +			  const char * const value)
  +{
  +	struct alfs_data *data = (struct alfs_data *) element->handler_data;
  +
  +	switch (attr->private) {
  +	case ALFS_VERSION:
  +		data->version = xstrdup(value);
  +		return 0;
  +	default:
  +		return 1;
  +	}
  +}
  +
  +static int alfs_invalid_child(const element_s * const element,
  +			      const element_s * const child)
  +{
  +	(void) element;
  +
  +	return !(child->handler->type & (HTYPE_NORMAL |
  +					 HTYPE_COMMENT |
  +					 HTYPE_TEXTDUMP |
  +					 HTYPE_PACKAGE |
  +					 HTYPE_EXECUTE |
  +					 HTYPE_STAGE));
  +}
  +
  +static int alfs_main(const element_s * const el)
   {
   	int status;
   
  @@ -57,6 +120,11 @@
   		.syntax_version = "2.0",
   		.main = alfs_main,
   		.type = HTYPE_NORMAL,
  +		.setup = alfs_setup,
  +		.free = alfs_free,
  +		.attributes = alfs_attributes,
  +		.attribute = alfs_attribute,
  +		.invalid_child = alfs_invalid_child,
   	},
   #endif
   #if HANDLER_SYNTAX_3_0
  @@ -66,6 +134,11 @@
   		.syntax_version = "3.0",
   		.main = alfs_main,
   		.type = HTYPE_NORMAL,
  +		.setup = alfs_setup,
  +		.free = alfs_free,
  +		.attributes = alfs_attributes,
  +		.attribute = alfs_attribute,
  +		.invalid_child = alfs_invalid_child,
   	},
   #endif
   #if HANDLER_SYNTAX_3_1
  @@ -75,6 +148,11 @@
   		.syntax_version = "3.1",
   		.main = alfs_main,
   		.type = HTYPE_NORMAL,
  +		.setup = alfs_setup,
  +		.free = alfs_free,
  +		.attributes = alfs_attributes,
  +		.attribute = alfs_attribute,
  +		.invalid_child = alfs_invalid_child,
   	},
   #endif
   #if HANDLER_SYNTAX_3_2
  @@ -84,7 +162,11 @@
   		.syntax_version = "3.2",
   		.main = alfs_main,
   		.type = HTYPE_NORMAL,
  -		.alternate_shell = 1,
  +		.setup = alfs_setup,
  +		.free = alfs_free,
  +		.attributes = alfs_attributes,
  +		.attribute = alfs_attribute,
  +		.invalid_child = alfs_invalid_child,
   	},
   #endif
   	{
  
  
  
  1.16      +1 -1      ALFS/nALFS/src/handlers/build.c
  
  Index: build.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/build.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- build.c	24 Feb 2004 02:25:34 -0000	1.15
  +++ build.c	24 Feb 2004 06:30:11 -0000	1.16
  @@ -38,7 +38,7 @@
   #if HANDLER_SYNTAX_2_0
   
   
  -static int build_main(element_s * const el)
  +static int build_main(const element_s * const el)
   {
   	int i;
   
  
  
  
  1.15      +1 -1      ALFS/nALFS/src/handlers/check.c
  
  Index: check.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/check.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- check.c	24 Feb 2004 02:25:34 -0000	1.14
  +++ check.c	24 Feb 2004 06:30:11 -0000	1.15
  @@ -60,7 +60,7 @@
   #if HANDLER_SYNTAX_3_0
   
   
  -static int check_main(element_s * const el)
  +static int check_main(const element_s * const el)
   {
   	int status = 0;
   	char *package;
  
  
  
  1.17      +1 -1      ALFS/nALFS/src/handlers/chroot.c
  
  Index: chroot.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/chroot.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- chroot.c	24 Feb 2004 02:25:34 -0000	1.16
  +++ chroot.c	24 Feb 2004 06:30:11 -0000	1.17
  @@ -51,7 +51,7 @@
   	{ .name = NULL }
   };
   
  -static int chroot_main(element_s * const el)
  +static int chroot_main(const element_s * const el)
   {
   	int status;
   	pid_t chroot_pid, got_pid;
  
  
  
  1.10      +13 -9     ALFS/nALFS/src/handlers/conditionals.c
  
  Index: conditionals.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/conditionals.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- conditionals.c	24 Feb 2004 02:25:34 -0000	1.9
  +++ conditionals.c	24 Feb 2004 06:30:11 -0000	1.10
  @@ -38,12 +38,16 @@
   
   
   #if HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
  -static int do_shelltest(element_s *element, const char *test, int *result)
  +static int do_shelltest(const element_s * const element, const char * const test,
  +			int * const result)
   {
   	int status = 0;
   	long num_value;
   	char *temp;
   
  +	if (change_to_base_dir(element, NULL, 1))
  +		return -1;
  +
   	num_value = strtol(test, &temp, 0);
   	if (*temp == '\0') {
   		/* strtol found the test string to be completely numeric */
  @@ -92,7 +96,7 @@
   	{ .name = NULL }
   };
   
  -static int if_main_3_1(element_s * const element)
  +static int if_main_3_1(const element_s * const element)
   {
   	char *shelltest;
   	char *packagetest;
  @@ -146,7 +150,7 @@
   	{ .name = NULL }
   };
   
  -static int if_main_3_2(element_s * const element)
  +static int if_main_3_2(const element_s * const element)
   {
   	int i;
   	element_s *child;
  @@ -171,7 +175,7 @@
   	return execute_children_filtered(element, result_handler_type);
   }
   
  -static int and_test_3_2(element_s * const element, int * const result)
  +static int and_test_3_2(const element_s * const element, int * const result)
   {
   	int i;
   	element_s *child;
  @@ -192,7 +196,7 @@
   	return 0;
   }
   
  -static int or_test_3_2(element_s * const element, int * const result)
  +static int or_test_3_2(const element_s * const element, int * const result)
   {
   	int i;
   	element_s *child;
  @@ -213,7 +217,7 @@
   	return 0;
   }
   
  -static int not_test_3_2(element_s * const element, int * const result)
  +static int not_test_3_2(const element_s * const element, int * const result)
   {
   	int i;
   	element_s *child;
  @@ -238,7 +242,7 @@
   	return 0;
   }
   
  -static int shelltest_test_3_2(element_s * const element, int * const result)
  +static int shelltest_test_3_2(const element_s * const element, int * const result)
   {
   	char *test;
   	int status = -1;
  @@ -253,7 +257,7 @@
   	return status;
   }
   
  -static int package_version_test_3_2(element_s * const element,
  +static int package_version_test_3_2(const element_s * const element,
   				    int * const result)
   {
   	(void) element;
  @@ -261,7 +265,7 @@
   	return 0;
   }
   
  -static int package_built_test_3_2(element_s * const element,
  +static int package_built_test_3_2(const element_s * const element,
   				  int * const result)
   {
   	(void) element;
  
  
  
  1.18      +4 -10     ALFS/nALFS/src/handlers/configure.c
  
  Index: configure.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/configure.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- configure.c	24 Feb 2004 02:25:34 -0000	1.17
  +++ configure.c	24 Feb 2004 06:30:11 -0000	1.18
  @@ -49,7 +49,7 @@
   	{ .name = NULL }
   };
   
  -static int configure_main_ver2(element_s * const el)
  +static int configure_main_ver2(const element_s * const el)
   {
   	int status;
   	char *c, *command = NULL;
  @@ -99,19 +99,14 @@
   	{ .name = NULL }
   };
   
  -static int configure_main_ver3(element_s * const el)
  +static int configure_main_ver3(const element_s * const el)
   {
   	int status;
   	char *c, *command = NULL;
  -	char *base;
          
   
  -	base = alloc_base_dir_new(el, 1);
  -
  -	if (change_current_dir(base)) {
  -		xfree(base);
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
   		return -1;
  -	}
   
   	command = xstrdup("");
   
  @@ -125,11 +120,10 @@
   
   	append_param_elements(&command, el);
   
  -	Nprint_h("Executing in %s:", base);
  +	Nprint_h("Executing:");
   	Nprint_h("    %s", command);
   	status = execute_command(el, "%s", command);
   
  -	xfree(base);
   	xfree(command);
   
   	return status;
  
  
  
  1.18      +5 -14     ALFS/nALFS/src/handlers/copy.c
  
  Index: copy.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/copy.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- copy.c	24 Feb 2004 02:25:34 -0000	1.17
  +++ copy.c	24 Feb 2004 06:30:11 -0000	1.18
  @@ -54,7 +54,7 @@
   	{ .name = NULL }
   };
   
  -static int copy_main_ver2(element_s * const el)
  +static int copy_main_ver2(const element_s * const el)
   {
   	int status = 0;
   	int archive = option_exists("archive",el);
  @@ -146,15 +146,16 @@
   	{ .name = NULL }
   };
   
  -static int copy_main_ver3(element_s * const el)
  +static int copy_main_ver3(const element_s * const el)
   {
   	int options[5];
   	int status = 0;
   	char *common_command;
  -	char *base;
   	char *destination;
   	element_s *p;
   
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
  +		return -1;
   
   	if (first_param("source", el) == NULL) {
   		Nprint_h_err("No source files specified.");
  @@ -186,15 +187,6 @@
   		append_str(&common_command, " -R");
   	}
   
  -	base = alloc_base_dir_new(el, 1);
  -
  -	if (change_current_dir(base)) {
  -		xfree(destination);
  -		xfree(common_command);
  -		xfree(base);
  -		return -1;
  -	}
  -
   	for (p = first_param("source", el); p; p = next_param(p)) {
   		char *s, *command;
   
  @@ -211,7 +203,7 @@
   		append_str(&command, " ");
   		append_str(&command, destination);
   
  -		Nprint_h("Executing in %s:", base);
  +		Nprint_h("Executing:");
   		Nprint_h("    %s", command);
   
   		status = execute_command(el, "%s", command);
  @@ -227,7 +219,6 @@
   
   	xfree(destination);
   	xfree(common_command);
  -	xfree(base);
   	
   	return status;
   }
  
  
  
  1.19      +3 -17     ALFS/nALFS/src/handlers/download.c
  
  Index: download.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/download.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- download.c	24 Feb 2004 02:25:34 -0000	1.18
  +++ download.c	24 Feb 2004 06:30:11 -0000	1.19
  @@ -58,7 +58,7 @@
   	{ .name = NULL }
   };
   
  -static int download_main(element_s * const el)
  +static int download_main(const element_s * const el)
   {
   	/* status assumes failure until set otherwise */
   	int status = -1;
  @@ -157,12 +157,11 @@
   	{ .name = NULL }
   };
   
  -static int download_main_3_2(element_s * const el)
  +static int download_main_3_2(const element_s * const el)
   {
   	/* status assumes failure until set otherwise */
   	int status = -1;
   	char *file = NULL;
  -	char *base = NULL;
   	char *digest = NULL;
   	char *digest_type = NULL;
   	struct stat file_stat;
  @@ -173,20 +172,8 @@
   		goto free_all_and_return;
   	}
   
  -	/* <base> is mandatory, we don't want to download just anywhere! */
  -	if ((base = alloc_base_dir_new(el, 0)) == NULL) {
  -		Nprint_h_err("<base> is missing.");
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
   		goto free_all_and_return;
  -	}
  -
  -	/* changing to <base> directory */
  -	if (change_current_dir(base))
  -		goto free_all_and_return;
  -
  -	Nprint_h("downloading to %s", base);
  -		
  -    /* base is not needed anymore so free it */
  -	xfree(base);	
   
   	alloc_element_digest(el, &digest, &digest_type);
   
  @@ -240,7 +227,6 @@
   	xfree(digest_type);
   	xfree(digest);
   	xfree(file);
  -	xfree(base);
   
   	return status;
   }
  
  
  
  1.24      +12 -24    ALFS/nALFS/src/handlers/execute.c
  
  Index: execute.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/execute.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- execute.c	24 Feb 2004 02:25:34 -0000	1.23
  +++ execute.c	24 Feb 2004 06:30:11 -0000	1.24
  @@ -53,7 +53,7 @@
   	{ .name = NULL }
   };
   
  -static int execute_main_ver2(element_s * const el)
  +static int execute_main_ver2(const element_s * const el)
   {
   	int status;
   	char *base;
  @@ -112,22 +112,17 @@
   	{ .name = NULL }
   };
   
  -static int execute_main_ver3(element_s * const el)
  +static int execute_main_ver3(const element_s * const el)
   {
   	int status;
  -	char *base;
   	char *c, *command;
   
   
  -	if ((c = attr_value("command", el)) == NULL) {
  -		Nprint_h_err("No command specified.");
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
   		return -1;
  -	}
  -
  -	base = alloc_base_dir_new(el, 1);
   
  -	if (change_current_dir(base)) {
  -		xfree(base);
  +	if ((c = attr_value("command", el)) == NULL) {
  +		Nprint_h_err("No command specified.");
   		return -1;
   	}
   
  @@ -139,12 +134,11 @@
   
   	append_param_elements(&command, el);
   
  -	Nprint_h("Executing system command in %s:", base);
  +	Nprint_h("Executing system command:");
   	Nprint_h("    %s", command);
   
   	status = execute_command(el, "%s", command);
   
  -	xfree(base);
   	xfree(command);
   
   	return status;
  @@ -182,13 +176,15 @@
   	{ .name = NULL }
   };
   
  -static int execute_main_ver3_2(element_s * const el)
  +static int execute_main_ver3_2(const element_s * const el)
   {
   	int status = -1;
  -	char *base;
   	char *c;
   	char *content = NULL;
   
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
  +		return -1;
  +
   	c = attr_value("command", el);
   	content = alloc_trimmed_param_value("content", el);
   
  @@ -208,13 +204,6 @@
   		return -1;
   	}
   
  -	base = alloc_base_dir_new(el, 1);
  -
  -	if (change_current_dir(base)) {
  -		xfree(base);
  -		return -1;
  -	}
  -
   	if (c) {
   		char *command;
   
  @@ -222,7 +211,7 @@
   		append_prefix_elements(&command, el);
   		append_str(&command, c);
   		append_param_elements(&command, el);
  -		Nprint_h("Executing system command in %s:", base);
  +		Nprint_h("Executing system command:");
   		Nprint_h("    %s", command);
   		status = execute_command(el, "%s", command);
   		xfree(command);
  @@ -247,7 +236,7 @@
   					Nprint_h_err("Cannot make temporary script executable.");
   					Nprint_h_err("    %s (%s)", temp_file_name, strerror(errno));
   				} else {
  -					Nprint_h("Executing script in %s:", base);
  +					Nprint_h("Executing script");
   					args[0] = "nALFS_temp_script";
   					args[1] = NULL;
   					status = execute_direct_command(temp_file_name, args);
  @@ -260,7 +249,6 @@
   		xfree(temp_file_name);
   	}
   
  -	xfree(base);
   	xfree(content);
   
   	return status;
  
  
  
  1.18      +7 -16     ALFS/nALFS/src/handlers/link.c
  
  Index: link.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/link.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- link.c	24 Feb 2004 02:25:34 -0000	1.17
  +++ link.c	24 Feb 2004 06:30:11 -0000	1.18
  @@ -58,7 +58,7 @@
   	{ .name = NULL }
   };
   
  -static int link_main_ver2(element_s * const el)
  +static int link_main_ver2(const element_s * const el)
   {
   	int status;
   	int force = option_exists("force", el);
  @@ -158,12 +158,11 @@
   	{ .name = NULL }
   };
   
  -static int link_main_ver3(element_s * const el)
  +static int link_main_ver3(const element_s * const el)
   {
   	int options[2], force, no_dereference;
   	int status;
   	char *type;
  -	char *base;
   	char *targets = NULL;
   	char *link_name;
   	char *command = NULL;
  @@ -171,6 +170,9 @@
   	element_s *p;
   
   
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
  +		return -1;
  +
   	/* Read all <option>s. */
   	check_options(2, options, "force no-dereference", el);
   	force = options[0];
  @@ -178,13 +180,6 @@
   
   	link_name = alloc_trimmed_param_value("name", el);
   
  -	base = alloc_base_dir_new(el, 1);
  -	if (change_current_dir(base)) {
  -		xfree(base);
  -		xfree(link_name);
  -		return -1;
  -	}
  -
   	type = attr_value("type", el);
   
   	if (type == NULL || strcmp(type, "symbolic") == 0) {
  @@ -197,12 +192,10 @@
   
   	} else {
   		Nprint_h_warn("Unknown link type (%s), using symbolic.", type);
  -		append_str(&message, "Creating symbolic link in ");
  +		append_str(&message, "Creating symbolic link");
   		append_str(&command, "ln -s");
   	}
   
  -	append_str(&message, base);
  -
   	if (force) {
   		append_str(&message, " (force)");
   		append_str(&command, " -f");
  @@ -251,8 +244,7 @@
   		Nprint_h("    %s", targets);
   
   		if ((status = execute_command(el, "%s", command))) {
  -			Nprint_h_err("Executing \"%s\" in %s failed.",
  -				command, base);
  +			Nprint_h_err("Executing \"%s\" failed.", command);
   		}
   
   	} else {
  @@ -260,7 +252,6 @@
   		status = -1;
   	}
   
  -	xfree(base);
   	xfree(link_name);
   	xfree(command);
   	xfree(message);
  
  
  
  1.16      +1 -1      ALFS/nALFS/src/handlers/log.c
  
  Index: log.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/log.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- log.c	21 Feb 2004 19:03:32 -0000	1.15
  +++ log.c	24 Feb 2004 06:30:11 -0000	1.16
  @@ -37,7 +37,7 @@
   #if HANDLER_SYNTAX_2_0 || HANDLER_SYNTAX_3_0
   
   
  -static int log_main(element_s * const el)
  +static int log_main(const element_s * const el)
   {
   	Nprint_h("%s", el->content ? el->content : "");
   
  
  
  
  1.18      +4 -10     ALFS/nALFS/src/handlers/make.c
  
  Index: make.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/make.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- make.c	24 Feb 2004 02:25:34 -0000	1.17
  +++ make.c	24 Feb 2004 06:30:11 -0000	1.18
  @@ -48,7 +48,7 @@
   	{ .name = NULL }
   };
   
  -static int make_main_ver2(element_s * const el)
  +static int make_main_ver2(const element_s * const el)
   {
   	int status;
   	char *base;
  @@ -92,19 +92,14 @@
   	{ .name = NULL }
   };
   
  -static int make_main_ver3(element_s * const el)
  +static int make_main_ver3(const element_s * const el)
   {
   	int status;
  -	char *base;
   	char *command;
   
   	
  -	base = alloc_base_dir_new(el, 1);
  -
  -	if (change_current_dir(base)) {
  -		xfree(base);
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
   		return -1;
  -	}
   
   	command = xstrdup("");
   
  @@ -114,12 +109,11 @@
   
   	append_param_elements(&command, el);
   
  -	Nprint_h("Executing in %s:", base);
  +	Nprint_h("Executing:");
   	Nprint_h("    %s", command);
   
   	status = execute_command(el, "%s", command);
   
  -	xfree(base);
   	xfree(command);
   
   	return status;
  
  
  
  1.18      +5 -13     ALFS/nALFS/src/handlers/mkdir.c
  
  Index: mkdir.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/mkdir.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- mkdir.c	24 Feb 2004 02:25:34 -0000	1.17
  +++ mkdir.c	24 Feb 2004 06:30:11 -0000	1.18
  @@ -54,7 +54,7 @@
   	{ .name = NULL }
   };
   
  -static int mkdir_main_ver2(element_s * const el)
  +static int mkdir_main_ver2(const element_s * const el)
   {
   	int status = 0;
   	int parents = option_exists("parents", el);
  @@ -135,14 +135,15 @@
   	{ .name = NULL }
   };
   
  -static int mkdir_main_ver3(element_s * const el)
  +static int mkdir_main_ver3(const element_s * const el)
   {
   	int options[1], parents;
   	int status = 0;
  -	char *base;
   	char *perm;
   	element_s *p;
   
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
  +		return -1;
   
   	check_options(1, options, "parents", el);
   	parents = options[0];
  @@ -152,13 +153,6 @@
   		return -1;
   	}
   
  -	base = alloc_base_dir_new(el, 1);
  -
  -	if (change_current_dir(base)) {
  -		xfree(base);
  -		return -1;
  -	}
  -
   	perm = alloc_trimmed_param_value("permissions", el);
   
   	for (p = first_param("name", el); p; p = next_param(p)) {
  @@ -172,8 +166,7 @@
   		}
   
   		command = xstrdup("mkdir ");
  -		message = xstrdup("Creating directory in ");
  -		append_str(&message, base);
  +		message = xstrdup("Creating directory");
   
   		if (parents) {
   			append_str(&command, " -p ");
  @@ -218,7 +211,6 @@
   		xfree(message);
   	}
   
  -	xfree(base);
   	xfree(perm);
   	
   	return status;
  
  
  
  1.18      +7 -14     ALFS/nALFS/src/handlers/move.c
  
  Index: move.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/move.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- move.c	24 Feb 2004 02:25:34 -0000	1.17
  +++ move.c	24 Feb 2004 06:30:11 -0000	1.18
  @@ -54,7 +54,7 @@
   	{ .name = NULL }
   };
   
  -static int move_main_ver2(element_s * const el)
  +static int move_main_ver2(const element_s * const el)
   {
   	int status = 0;
   	int force = option_exists("force", el);
  @@ -125,15 +125,17 @@
   	{ .name = NULL }
   };
   
  -static int move_main_ver3(element_s * const el)
  +static int move_main_ver3(const element_s * const el)
   {
   	int options[1], force;
   	int status = 0;
  -	char *base;
   	char *destination;
   	element_s *p;
   
   
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
  +		return -1;
  +
   	check_options(1, options, "force", el);
   	force = options[0];
   
  @@ -148,14 +150,6 @@
   		return -1;
   	}
   
  -	base = alloc_base_dir_new(el, 1);
  -
  -	if (change_current_dir(base)) {
  -		xfree(base);
  -		xfree(destination);
  -		return -1;
  -	}
  -
   	for (p = first_param("source", el); p; p = next_param(p)) {
   		char *s;
   
  @@ -164,8 +158,8 @@
   			continue;
   		}
   
  -		Nprint_h("Moving from %s to %s%s: %s",
  -			base, destination, force ? " (force)" : "", s);
  +		Nprint_h("Moving to %s%s: %s",
  +			destination, force ? " (force)" : "", s);
   
   		if (force) {
   			status = execute_command(el, "mv -f %s %s", s, destination);
  @@ -181,7 +175,6 @@
   		}
   	}
   
  -	xfree(base);
   	xfree(destination);
   	
   	return status;
  
  
  
  1.17      +1 -1      ALFS/nALFS/src/handlers/owner.c
  
  Index: owner.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/owner.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- owner.c	23 Feb 2004 21:19:35 -0000	1.16
  +++ owner.c	24 Feb 2004 06:30:11 -0000	1.17
  @@ -56,7 +56,7 @@
   	{ .name = NULL }
   };
   
  -static int owner_main(element_s * const el)
  +static int owner_main(const element_s * const el)
   {
   	int status = 0;
   	int recursive = option_exists("recursive", el);
  
  
  
  1.16      +5 -14     ALFS/nALFS/src/handlers/ownership.c
  
  Index: ownership.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/ownership.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ownership.c	24 Feb 2004 02:25:34 -0000	1.15
  +++ ownership.c	24 Feb 2004 06:30:11 -0000	1.16
  @@ -52,14 +52,17 @@
   	{ .name = NULL }
   };
   
  -static int ownership_main(element_s *const el)
  +static int ownership_main(const element_s *const el)
   {
   	int status = 0;
   	int options[1], recursive;
  -	char *base, *user, *group;
  +	char *user, *group;
   	element_s *p;
   
   
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
  +		return -1;
  +
   	check_options(1, options, "recursive", el);
   	recursive = options[0];
   
  @@ -71,12 +74,6 @@
   		return -1;
   	}
   
  -	base = alloc_base_dir_new(el, 1);
  -	if (change_current_dir(base)) {
  -		xfree(base);
  -		return -1;
  -	}
  -
   	for (p = first_param("name", el); p; p = next_param(p)) {
   		char *s;
   
  @@ -101,8 +98,6 @@
   				append_str(&message, " (recursive)");
   			}
   
  -			append_str(&message, " in ");
  -			append_str(&message, base);
   			append_str(&message, ": ");
   			append_str(&message, s);
   
  @@ -140,8 +135,6 @@
   				append_str(&message, "(recursive) ");
   			}
   
  -			append_str(&message, "in ");
  -			append_str(&message, base);
   			append_str(&message, ": ");
   			append_str(&message, s);
   
  @@ -166,8 +159,6 @@
   		xfree(s);
   	}
   
  -	xfree(base);
  -	
   	return status;
   }
   
  
  
  
  1.20      +2 -2      ALFS/nALFS/src/handlers/package.c
  
  Index: package.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/package.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- package.c	24 Feb 2004 02:25:34 -0000	1.19
  +++ package.c	24 Feb 2004 06:30:11 -0000	1.20
  @@ -49,7 +49,7 @@
   	{ .name = NULL }
   };
   
  -static int package_main_ver2(element_s * const el)
  +static int package_main_ver2(const element_s * const el)
   {
   	int i;
   
  @@ -243,7 +243,7 @@
   	{ .name = NULL }
   };
   
  -static int package_main_ver3(element_s * const el)
  +static int package_main_ver3(const element_s * const el)
   {
   	int status = 0;
   	element_s *packageinfo;
  
  
  
  1.22      +10 -26    ALFS/nALFS/src/handlers/patch.c
  
  Index: patch.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/patch.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- patch.c	24 Feb 2004 02:25:34 -0000	1.21
  +++ patch.c	24 Feb 2004 06:30:11 -0000	1.22
  @@ -50,7 +50,7 @@
   	{ .name = NULL }
   };
   
  -static int patch_main_ver2(element_s * const el)
  +static int patch_main_ver2(const element_s * const el)
   {
   	int status;
   	char *base;
  @@ -99,30 +99,22 @@
   	{ .name = NULL }
   };
   
  -// char *HANDLER_SYMBOL(attributes)[] = { "base", NULL };
  -
  -static int patch_main_ver3(element_s * const el)
  +static int patch_main_ver3(const element_s * const el)
   {
   	int status;
  -	char *base;
   	char *parameters = NULL;
   	char *command;
   
   
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
  +		return -1;
  +
   	if (append_param_elements(&parameters, el) == NULL) {
   		Nprint_h_err("No patch parameters specified.");
   		return -1;
   	}
   
  -	base = alloc_base_dir_new(el, 1);
  -
  -	if (change_current_dir(base)) {
  -		xfree(base);
  -		xfree(parameters);
  -		return -1;
  -	}
  -	
  -	Nprint_h("Patching in %s", base);
  +	Nprint_h("Patching");
   	command = xstrdup("");
   
   	append_prefix_elements(&command, el);
  @@ -144,7 +136,6 @@
   	}
   	
   	xfree(command);
  -	xfree(base);
   	xfree(parameters);
   
   	return status;
  @@ -171,10 +162,9 @@
   	{ .name = NULL }
   };
   
  -static int patch_main_ver3_2(element_s * const el)
  +static int patch_main_ver3_2(const element_s * const el)
   {
           int status = -1;
  -	char *base = NULL;
   	char *file = NULL;
   	char *command = NULL;
   	char *digest = NULL;
  @@ -185,17 +175,14 @@
   	struct stat file_stat;
   
   
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
  +		return -1;
  +
   	if ((file = alloc_trimmed_param_value("file", el)) == NULL) {
   		Nprint_h_err("File name is missing.");
   		goto free_all_and_return;
   	}
   
  -	base = alloc_base_dir_new(el, 1);
  -
  -	if (change_current_dir(base)) {
  -		goto free_all_and_return;
  -	}
  -	
   	alloc_element_digest(el, &digest, &digest_type);
   
   	/* Check if file exists and if not attempt to download it. */
  @@ -238,8 +225,6 @@
   		goto free_all_and_return;
   	}
   
  -	Nprint_h("Patching in %s", base);
  -
   	decompressor = alloc_decompress_command(get_compression_type(file));
   
   	if (decompressor == NULL)
  @@ -286,7 +271,6 @@
   	xfree(digest);
   	xfree(file);
   	xfree(command);
  -	xfree(base);
   
   	return status;
   }
  
  
  
  1.18      +3 -11     ALFS/nALFS/src/handlers/permissions.c
  
  Index: permissions.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/permissions.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- permissions.c	24 Feb 2004 02:25:34 -0000	1.17
  +++ permissions.c	24 Feb 2004 06:30:11 -0000	1.18
  @@ -54,7 +54,7 @@
   	{ .name = NULL }
   };
   
  -static int permissions_main_ver2(element_s * const el)
  +static int permissions_main_ver2(const element_s * const el)
   {
   	int status = 0;
   	int recursive = option_exists("recursive", el);
  @@ -147,11 +147,10 @@
   	{ .name = NULL }
   };
   
  -static int permissions_main_ver3(element_s * const el)
  +static int permissions_main_ver3(const element_s * const el)
   {
   	int options[1], recursive;
   	int status = 0;
  -	char *base;
   	char *mode;
   	element_s *p;
   
  @@ -164,11 +163,8 @@
   		return -1;
   	}
   
  -	base = alloc_base_dir_new(el, 1);
  -	if (change_current_dir(base)) {
  -		xfree(base);
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
   		return -1;
  -	}
   
   	for (p = first_param("name", el); p; p = next_param(p)) {
   		char *name;
  @@ -191,8 +187,6 @@
   			append_str(&message, " (recursive)");
   
   		}
  -		append_str(&message, " in ");
  -		append_str(&message, base);
   		append_str(&message, ": ");
   		append_str(&message, name);
   
  @@ -214,8 +208,6 @@
   			break;
   	}
   
  -	xfree(base);
  -	
   	return status;
   }
   
  
  
  
  1.16      +1 -1      ALFS/nALFS/src/handlers/postbuild.c
  
  Index: postbuild.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/postbuild.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- postbuild.c	24 Feb 2004 02:25:34 -0000	1.15
  +++ postbuild.c	24 Feb 2004 06:30:11 -0000	1.16
  @@ -37,7 +37,7 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static int postbuild_main(element_s * const el)
  +static int postbuild_main(const element_s * const el)
   {
   	int i;
   
  
  
  
  1.16      +1 -1      ALFS/nALFS/src/handlers/prebuild.c
  
  Index: prebuild.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/prebuild.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- prebuild.c	24 Feb 2004 02:25:34 -0000	1.15
  +++ prebuild.c	24 Feb 2004 06:30:11 -0000	1.16
  @@ -37,7 +37,7 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static int prebuild_main(element_s * const el)
  +static int prebuild_main(const element_s * const el)
   {
   	int i;
   
  
  
  
  1.22      +4 -11     ALFS/nALFS/src/handlers/remove.c
  
  Index: remove.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/remove.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- remove.c	24 Feb 2004 02:25:34 -0000	1.21
  +++ remove.c	24 Feb 2004 06:30:11 -0000	1.22
  @@ -55,7 +55,7 @@
   }
   
   
  -static int remove_main_ver2(element_s * const el)
  +static int remove_main_ver2(const element_s * const el)
   {
   	int status = 0;
   	char *tok;
  @@ -94,7 +94,7 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 
   
  -static int remove_main_ver3(element_s * const el)
  +static int remove_main_ver3(const element_s * const el)
   {
   	int status = 0;
   	char *name;
  @@ -134,11 +134,10 @@
   	{ .name = NULL }
   };
   
  -static int remove_main_ver3_2(element_s * const el)
  +static int remove_main_ver3_2(const element_s * const el)
   {
   	int status   = 0;
   	char *name   = NULL;
  -	char *base   = NULL;
   	element_s *p = NULL;
   
   	if ((first_param("file", el)) == NULL) {
  @@ -146,14 +145,8 @@
   		return -1;
   	}
   
  -	base = alloc_base_dir_new(el, 1);
  -
  -	if (change_current_dir(base)) {
  -		xfree(base);
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
   		return -1;
  -	}
  -
  -	xfree(base);
   
   	for (p = first_param("file", el); p; p = next_param(p)) {
   
  
  
  
  1.19      +5 -9      ALFS/nALFS/src/handlers/search_replace.c
  
  Index: search_replace.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/search_replace.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- search_replace.c	24 Feb 2004 02:25:34 -0000	1.18
  +++ search_replace.c	24 Feb 2004 06:30:11 -0000	1.19
  @@ -193,7 +193,7 @@
   	{ .name = NULL }
   };
   
  -static int search_replace_main_ver2(element_s * const el)
  +static int search_replace_main_ver2(const element_s * const el)
   {
   	int i;
   	char *base = alloc_base_dir(el);
  @@ -222,16 +222,12 @@
   	{ .name = NULL }
   };
   
  -static int search_replace_main_ver3(element_s * const el)
  +static int search_replace_main_ver3(const element_s * const el)
   {
  -	int i;
  -	char *base = alloc_base_dir_new(el, 1);
  -
  -	i = search_replace_main(el, base);
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
  +		return -1;
   
  -	xfree(base);
  -
  -	return i;
  +	return search_replace_main(el, ".");
   }
   
   #endif /* HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2 */
  
  
  
  1.16      +1 -1      ALFS/nALFS/src/handlers/setenv.c
  
  Index: setenv.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/setenv.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- setenv.c	24 Feb 2004 02:25:34 -0000	1.15
  +++ setenv.c	24 Feb 2004 06:30:11 -0000	1.16
  @@ -119,7 +119,7 @@
   	{ .name = NULL }
   };
   
  -static int setenv_main(element_s * const el)
  +static int setenv_main(const element_s * const el)
   {
   	int i;
   	char *variable;
  
  
  
  1.26      +9 -9      ALFS/nALFS/src/handlers/stage.c
  
  Index: stage.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/stage.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- stage.c	23 Feb 2004 21:19:35 -0000	1.25
  +++ stage.c	24 Feb 2004 06:30:11 -0000	1.26
  @@ -49,8 +49,8 @@
   #include "options.h"
   
   /* Forward declarations for cross-handler references */
  -static int environment_main(element_s * const element);
  -static int variable_main(element_s * const element);
  +static int environment_main(const element_s * const element);
  +static int variable_main(const element_s * const element);
   
   
   extern char **environ;
  @@ -234,7 +234,7 @@
      the element's children
   */
   
  -static int process_stage(element_s *element)
  +static int process_stage(const element_s * const element)
   {
   	struct stage_data *data = (struct stage_data *) element->handler_data;
   	int status;
  @@ -353,7 +353,7 @@
   					 HTYPE_STAGE));
   }
   
  -static int stage_main(element_s * const element)
  +static int stage_main(const element_s * const element)
   {
   	int status;
   	struct stage_data *data = (struct stage_data *) element->handler_data;
  @@ -401,7 +401,7 @@
   
   #if HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static int then_main(element_s * const el)
  +static int then_main(const element_s * const el)
   {
   	int status;
   
  @@ -420,7 +420,7 @@
   	return status;
   }
   
  -static int else_main(element_s * const el)
  +static int else_main(const element_s * const el)
   {
   	int status;
   
  @@ -539,7 +539,7 @@
   	return 0;
   }
   
  -static int stageinfo_main(element_s * const element)
  +static int stageinfo_main(const element_s * const element)
   {
   	struct stageinfo_data *data = (struct stageinfo_data *) element->handler_data;
   
  @@ -604,7 +604,7 @@
   	return 0;
   }
   
  -static int environment_main(element_s * const element)
  +static int environment_main(const element_s * const element)
   {
   	return execute_children(element);
   }
  @@ -722,7 +722,7 @@
   	return 1;
   }
   
  -static int variable_main(element_s * const element)
  +static int variable_main(const element_s * const element)
   {
   	struct variable_data *data = (struct variable_data *) element->handler_data;
   
  
  
  
  1.15      +1 -1      ALFS/nALFS/src/handlers/stamp.c
  
  Index: stamp.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/stamp.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- stamp.c	24 Feb 2004 02:25:34 -0000	1.14
  +++ stamp.c	24 Feb 2004 06:30:11 -0000	1.15
  @@ -43,7 +43,7 @@
   	{ .name = NULL }
   };
   
  -static int stamp_main(element_s * const el)
  +static int stamp_main(const element_s * const el)
   {
   	int status = 0;
   	char *name;
  
  
  
  1.18      +1 -1      ALFS/nALFS/src/handlers/su.c
  
  Index: su.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/su.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- su.c	24 Feb 2004 02:25:34 -0000	1.17
  +++ su.c	24 Feb 2004 06:30:11 -0000	1.18
  @@ -143,7 +143,7 @@
   	{ .name = NULL }
   };
   
  -static int su_main(element_s * const el)
  +static int su_main(const element_s * const el)
   {
   	int status;
   	pid_t su_pid, got_pid;
  
  
  
  1.20      +8 -14     ALFS/nALFS/src/handlers/textdump.c
  
  Index: textdump.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/textdump.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- textdump.c	24 Feb 2004 02:25:34 -0000	1.19
  +++ textdump.c	24 Feb 2004 06:30:11 -0000	1.20
  @@ -122,16 +122,14 @@
   	{ .name = NULL }
   };
   
  -static int textdump_main_ver2(element_s * const el)
  +static int textdump_main_ver2(const element_s * const el)
   {
  -	int i;
   	char *base = alloc_base_dir(el);
  +	int result;
   
  -	i = textdump_main(el, base);
  -
  +	result = textdump_main(el, base);
   	xfree(base);
  -
  -	return i;
  +	return result;
   }
   
   #endif /* HANDLER_SYNTAX_2_0 */
  @@ -151,16 +149,12 @@
   	{ .name = NULL }
   };
   
  -static int textdump_main_ver3(element_s * const el)
  +static int textdump_main_ver3(const element_s * const el)
   {
  -	int i;
  -	char *base = alloc_base_dir_new(el, 1);
  -
  -	i = textdump_main(el, base);
  -
  -	xfree(base);
  +	if (change_to_base_dir(el, attr_value("base", el), 1))
  +		return -1;
   
  -	return i;
  +	return textdump_main(el, ".");
   }
   
   
  
  
  
  1.25      +5 -17     ALFS/nALFS/src/handlers/unpack.c
  
  Index: unpack.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/unpack.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- unpack.c	24 Feb 2004 02:25:34 -0000	1.24
  +++ unpack.c	24 Feb 2004 06:30:11 -0000	1.25
  @@ -71,7 +71,7 @@
   	return base_name;
   }
   
  -static int unpack_archive(element_s *element, const char *archive)
  +static int unpack_archive(const element_s * const element, const char * const archive)
   {
   	char *decompressor = NULL;
   	char *unpacker = NULL;
  @@ -119,7 +119,7 @@
   	{ .name = NULL }
   };
   
  -static int unpack_main_ver2(element_s * const el)
  +static int unpack_main_ver2(const element_s * const el)
   {
   	int status = 0;
   	char *archive, *destination;
  @@ -176,7 +176,7 @@
   	{ .name = NULL }
   };
   
  -static int unpack_main_ver3(element_s * const el)
  +static int unpack_main_ver3(const element_s * const el)
   {
   	int status = -1;
   	char *archive = NULL;
  @@ -272,11 +272,10 @@
   	{ .name = NULL }
   };
   
  -static int unpack_main_ver3_2(element_s * const el)
  +static int unpack_main_ver3_2(const element_s * const el)
   {
   	int status = -1;
   	char *archive = NULL;
  -	char *base = NULL;
   	char *digest = NULL;
   	char *digest_type = NULL;
   	struct stat file_stat;
  @@ -287,18 +286,8 @@
   		goto free_all_and_return;
   	}
   
  -	/* <base> is mandatory, we don't want to unpack just anywhere! */
  -	if ((base = alloc_base_dir_new(el, 0)) == NULL) {
  -		Nprint_h_err("<base> is missing.");
  +	if (change_to_base_dir(el, attr_value("base", el), 0))
   		goto free_all_and_return;
  -	}
  -
  -	/* changing to <base> directory */
  -	if (change_current_dir(base))
  -		goto free_all_and_return;
  -
  -	/* base is not needed anymore so free it */
  -	xfree(base);	
   
   	alloc_element_digest(el, &digest, &digest_type);
   
  @@ -352,7 +341,6 @@
   	xfree(digest_type);
   	xfree(digest);
   	xfree(archive);
  -	xfree(base);
   	
   	return status;
   }
  
  
  



More information about the alfs-log mailing list