r1844 - in nALFS/nALFS/trunk/src: . handlers lib

jamie at linuxfromscratch.org jamie at linuxfromscratch.org
Mon Apr 11 12:40:14 PDT 2005


Author: jamie
Date: 2005-04-11 13:40:08 -0600 (Mon, 11 Apr 2005)
New Revision: 1844

Modified:
   nALFS/nALFS/trunk/src/backend.c
   nALFS/nALFS/trunk/src/handlers/download.c
   nALFS/nALFS/trunk/src/handlers/unpack.c
   nALFS/nALFS/trunk/src/init.c
   nALFS/nALFS/trunk/src/lib/digest.c
   nALFS/nALFS/trunk/src/nalfs.c
   nALFS/nALFS/trunk/src/options.h
Log:
Added support for downloading and digest checking packages within the <unpack> and <download> elements without executing the other tags in a profile. 


Modified: nALFS/nALFS/trunk/src/backend.c
===================================================================
--- nALFS/nALFS/trunk/src/backend.c	2005-04-10 20:21:59 UTC (rev 1843)
+++ nALFS/nALFS/trunk/src/backend.c	2005-04-11 19:40:08 UTC (rev 1844)
@@ -1,9 +1,10 @@
 /*
  *  backend.c - Backend.
  *
- *  Copyright (C) 2001, 2002
+ *  Copyright (C) 2001, 2002, 2005
  *
  *  Neven Has <haski at sezampro.yu>
+ *  Jamie Bennett <jamie at linuxuk.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -350,8 +351,19 @@
 				change_to_profiles_dir(el);
 			}
 
-			i = el->handler->info->main(el);
+			if (*opt_download_check) {
 
+				char *handler_name = el->handler->info->name;
+				
+				if (!strcmp(handler_name, "unpack") ||
+					!strcmp(handler_name, "download"))
+					i = el->handler->info->main(el);
+				else
+					i = execute_children(el);
+			}
+			else 
+				i = el->handler->info->main(el);
+
 		} else { /* Never reached.
 			  * (Only elements with ->handler have TYPE_ELEMENT
 			  * type and only those elements can run.)

Modified: nALFS/nALFS/trunk/src/handlers/download.c
===================================================================
--- nALFS/nALFS/trunk/src/handlers/download.c	2005-04-10 20:21:59 UTC (rev 1843)
+++ nALFS/nALFS/trunk/src/handlers/download.c	2005-04-11 19:40:08 UTC (rev 1844)
@@ -1,10 +1,11 @@
 /*
  *  download.c - Handler.
  * 
- *  Copyright (C) 2003
+ *  Copyright (C) 2003, 2005
  *  
  *  Neven Has <haski at sezampro.yu>
  *  Vassili Dzuba <vdzuba at nerim.net>
+ *  Jamie Bennett <jamie at linuxuk.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -43,6 +44,7 @@
 #include "parser.h"
 #include "nalfs-core.h"
 #include "backend.h"
+#include "options.h"
 
 
 #define El_download_file(el) alloc_trimmed_param_value("file", el)
@@ -80,8 +82,9 @@
 	if (change_current_dir(destination))
 		goto free_all_and_return;
 
-	alloc_element_digest(el, &digest, &digest_type);
-
+	if (!*opt_disable_digest)
+		alloc_element_digest(el, &digest, &digest_type);
+	
 	/* Check if file exists. */
 	if ((stat(file, &file_stat))) {
 	        if (errno == ENOENT && first_param("url", el) != NULL) {
@@ -117,12 +120,20 @@
 			Nprint_h_err("    %s", strerror(errno));
 			goto free_all_and_return;
 		}
-	} else if (digest != NULL) {
-		if (verify_digest(digest_type, digest, file)) {
-			Nprint_h_err("Wrong %s digest of file: %s",
-				     digest_type, file);
-			goto free_all_and_return;
+	} 
+	else {
+		if (*opt_download_check) {
+			Nprint_h("File %s available", file);
+			status = 0;
 		}
+		if (digest != NULL) {
+			if (verify_digest(digest_type, digest, file)) {
+				Nprint_h_err("Wrong %s digest of file: %s",
+					     digest_type, file);
+				status = -1;
+				goto free_all_and_return;
+			}
+		}
 	}
 
 	/* operation was successful, set status */

Modified: nALFS/nALFS/trunk/src/handlers/unpack.c
===================================================================
--- nALFS/nALFS/trunk/src/handlers/unpack.c	2005-04-10 20:21:59 UTC (rev 1843)
+++ nALFS/nALFS/trunk/src/handlers/unpack.c	2005-04-11 19:40:08 UTC (rev 1844)
@@ -1,9 +1,10 @@
 /*
  *  unpack.c - Handler.
  * 
- *  Copyright (C) 2001-2003
+ *  Copyright (C) 2001-2003, 2005
  *  
  *  Neven Has <haski at sezampro.yu>
+ *  Jamie Bennett <jamie at linuxuk.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -233,12 +234,18 @@
 		goto free_all_and_return;
 	}
 
-	if (unpack_archive(archive)) {
-		Nprint_h_err("Unpacking %s failed.", archive);
-	} else {
-		Nprint_h("Done unpacking %s.", archive);
+	if (*opt_download_check) {
+		Nprint_h("File %s available", archive);
 		status = 0;
 	}
+	else {
+		if (unpack_archive(archive)) {
+			Nprint_h_err("Unpacking %s failed.", archive);
+		} else {
+			Nprint_h("Done unpacking %s.", archive);
+			status = 0;
+		}
+	}
 
  free_all_and_return:
 	xfree(digest_type);

Modified: nALFS/nALFS/trunk/src/init.c
===================================================================
--- nALFS/nALFS/trunk/src/init.c	2005-04-10 20:21:59 UTC (rev 1843)
+++ nALFS/nALFS/trunk/src/init.c	2005-04-11 19:40:08 UTC (rev 1844)
@@ -1,9 +1,10 @@
 /*
  *  init.c - Initializing options.
  *
- *  Copyright (C) 2001-2003
+ *  Copyright (C) 2001-2003, 2005
  *
  *  Neven Has <haski at sezampro.yu>
+ *  Jamie Bennett <jamie at linuxuk.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -305,6 +306,7 @@
 	LONG_OPTION_HELP,
 	LONG_OPTION_GENERATE_STAMP,
 	LONG_OPTION_DISABLE_DIGEST,
+	LONG_OPTION_DOWNLOAD_CHECK,
 	LONG_OPTION_RCFILE,
 };
 
@@ -360,6 +362,7 @@
 "                                  logging files.\n"
 "    -S, --generate-stamp          Toggle stamp mode.\n"
 "    -d, --disable-digest          Disable digest checking\n"
+"    -D, --download          	Download and check packages only\n"
 "    --rcfile <file>               Use <file> as configuration file.\n"
 "    -v, --verbose                 Toggle verbosity (%s).\n"
 "    --version                     Display program's version.\n"
@@ -422,6 +425,8 @@
 	
 	{"disable-digest", no_argument, NULL, LONG_OPTION_DISABLE_DIGEST},	
 
+	{"download", no_argument, NULL, LONG_OPTION_DOWNLOAD_CHECK},		
+
 	{"rcfile", required_argument, NULL, LONG_OPTION_RCFILE},
 
 	{NULL, no_argument, NULL, 0}
@@ -429,7 +434,7 @@
 	};
 
 
-	while ((i = getopt_long(*argc, *argv, "lPfhisBSdL:b:p:v", long_opts, NULL)) != -1) {
+	while ((i = getopt_long(*argc, *argv, "lPfhisBSdDL:b:p:v", long_opts, NULL)) != -1) {
 		switch (i) {
 			case LONG_OPTION_DISPLAY_ALFS:
 				Toggle(*opt_display_alfs);
@@ -500,6 +505,11 @@
 				Toggle(*opt_disable_digest);
 				break;
 
+			case 'D':
+			case LONG_OPTION_DOWNLOAD_CHECK:
+				Toggle(*opt_download_check);
+				break;
+			
 			case LONG_OPTION_RCFILE:
 				parse_rc_file(optarg);
 				break;

Modified: nALFS/nALFS/trunk/src/lib/digest.c
===================================================================
--- nALFS/nALFS/trunk/src/lib/digest.c	2005-04-10 20:21:59 UTC (rev 1843)
+++ nALFS/nALFS/trunk/src/lib/digest.c	2005-04-11 19:40:08 UTC (rev 1844)
@@ -137,7 +137,7 @@
 	                sprintf(&md_value_hex[0] + i * 2, "%02x", md_value[i]);
 
 		if (! strcmp(digest, &md_value_hex[0])) {
-			Nprint("Digest ok.");
+			Nprint("Digest ok for %s.", file);
 		        return 0;
 		}
 

Modified: nALFS/nALFS/trunk/src/nalfs.c
===================================================================
--- nALFS/nALFS/trunk/src/nalfs.c	2005-04-10 20:21:59 UTC (rev 1843)
+++ nALFS/nALFS/trunk/src/nalfs.c	2005-04-11 19:40:08 UTC (rev 1844)
@@ -1,9 +1,10 @@
 /*
  *  nalfs.c - Main file.
  *
- *  Copyright (C) 2001-2003
+ *  Copyright (C) 2001-2003, 2005
  *
  *  Neven Has <haski at sezampro.yu>
+ *  Jamie Bennett <jamie at linuxuk.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -1891,14 +1892,25 @@
 static INLINE void toggle_disable_digest(void)
 {
 	if (*opt_disable_digest) {
-		Nprint("Digest checking now enabled.");
+		Nprint("Digest checking now disabled.");
 		*opt_disable_digest = 0;
 	} else {
-		Nprint("Digest checking now disabled.");
+		Nprint("Digest checking now enabled.");
 		*opt_disable_digest = 1;
 	}
 }
 
+static INLINE void download_check(void)
+{
+	if (*opt_download_check) {
+		Nprint("Downloading and checking of packages disabled");
+		*opt_download_check = 0;
+	} else {
+		Nprint("Downloading and checking of packages enabled");
+		*opt_download_check = 1;
+	}
+}
+
 static INLINE void toggle_system_output(void)
 {
 	if (Backend_exists) {

Modified: nALFS/nALFS/trunk/src/options.h
===================================================================
--- nALFS/nALFS/trunk/src/options.h	2005-04-10 20:21:59 UTC (rev 1843)
+++ nALFS/nALFS/trunk/src/options.h	2005-04-11 19:40:08 UTC (rev 1844)
@@ -1,10 +1,11 @@
 /*
  *  options.h - Program's options.
  *
- *  Copyright (C) 2002
+ *  Copyright (C) 2002, 2005
  *
  *  Neven Has <haski at sezampro.yu>
  *  Kevin P. Fleming <kpfleming at linuxfromscratch.org>
+ *  Jamie Bennett <jamie at linuxuk.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -59,6 +60,7 @@
 BOOL_OPTION(stamp_packages, 0, NULL, NULL);
 STRING_OPTION(stamp_directory, "stamps", NULL, NULL);
 BOOL_OPTION(disable_digest, 0, NULL, NULL);
+BOOL_OPTION(download_check, 0, NULL, NULL);
 BOOL_OPTION(display_stage_header, 0, NULL, NULL);
 STRING_OPTION(find_base, "/", NULL, NULL);
 STRING_OPTION(find_prunes, "", NULL, NULL);




More information about the alfs-log mailing list