[Debburn-changes] r830 - in cdrkit/trunk: . genisoimage
Steve McIntyre
93sam at alioth.debian.org
Thu May 14 01:34:04 UTC 2009
Author: 93sam
Date: 2009-05-14 01:34:04 +0000 (Thu, 14 May 2009)
New Revision: 830
Modified:
cdrkit/trunk/Changelog
cdrkit/trunk/genisoimage/checksum.c
cdrkit/trunk/genisoimage/checksum.h
cdrkit/trunk/genisoimage/genisoimage.c
cdrkit/trunk/genisoimage/jte.c
cdrkit/trunk/genisoimage/jte.h
Log:
genisoimage: allow user to specify which checksum algorithms to run
on the command line.
Modified: cdrkit/trunk/Changelog
===================================================================
--- cdrkit/trunk/Changelog 2009-05-13 23:31:48 UTC (rev 829)
+++ cdrkit/trunk/Changelog 2009-05-14 01:34:04 UTC (rev 830)
@@ -5,6 +5,8 @@
when making jigdo files.
* genisoimage: checksumming with lots of algorithms can be very
time-consuming, so split it out into multiple threads if possible.
+ * genisoimage: allow user to specify which checksum algorithms to run
+ on the command line.
-- Steve McIntyre <93sam at debian.org> Thu, 14 May 2009 00:28:48 +0100
Modified: cdrkit/trunk/genisoimage/checksum.c
===================================================================
--- cdrkit/trunk/genisoimage/checksum.c 2009-05-13 23:31:48 UTC (rev 829)
+++ cdrkit/trunk/genisoimage/checksum.c 2009-05-14 01:34:04 UTC (rev 830)
@@ -14,6 +14,8 @@
#include <fctldefs.h>
#include <regex.h>
#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
#include "md5.h"
#include "sha1.h"
#include "sha256.h"
@@ -440,6 +442,65 @@
return NULL;
}
+
+/* Parse the command line options for which checksums to use */
+int parse_checksum_algo(char *arg, int *algo)
+{
+ int error = 0;
+ int i = 0;
+ char *start_ptr = arg;
+ int len = 0;
+
+ *algo = 0;
+
+ if (!strcasecmp(arg, "all"))
+ {
+ *algo = 0xFF;
+ return 0;
+ }
+
+ while (*start_ptr != 0)
+ {
+ int match = 0;
+ len = 0;
+
+ while (start_ptr[len] != ',' && start_ptr[len] != 0)
+ len++;
+
+ if (len)
+ {
+ for (i = 0; i < NUM_CHECKSUMS; i++)
+ {
+ if (len == strlen(algorithms[i].name) &&
+ !strncasecmp(start_ptr, algorithms[i].name, len))
+ {
+ match = 1;
+ *algo |= (1 << i);
+ }
+ }
+
+ if (!match)
+ {
+ fprintf(stderr, "invalid algorithm name found in %s\n", arg);
+ return EINVAL;
+ }
+ }
+
+ if (start_ptr[len] == 0)
+ break;
+
+ start_ptr += len + 1;
+ }
+
+ if (! (*algo & CHECK_MD5_USED))
+ {
+ fprintf(stderr, "invalid choices: algorithms *must* include MD5\n");
+ return EINVAL;
+ }
+
+ return 0;
+}
+
#ifdef CHECKSUM_SELF_TEST
#include <sys/types.h>
#include <sys/stat.h>
Modified: cdrkit/trunk/genisoimage/checksum.h
===================================================================
--- cdrkit/trunk/genisoimage/checksum.h 2009-05-13 23:31:48 UTC (rev 829)
+++ cdrkit/trunk/genisoimage/checksum.h 2009-05-14 01:34:04 UTC (rev 830)
@@ -69,3 +69,6 @@
const char * checksum_hex(checksum_context_t *context,
enum checksum_types which);
+
+extern int parse_checksum_algo(char *arg,
+ int *algo);
Modified: cdrkit/trunk/genisoimage/genisoimage.c
===================================================================
--- cdrkit/trunk/genisoimage/genisoimage.c 2009-05-13 23:31:48 UTC (rev 829)
+++ cdrkit/trunk/genisoimage/genisoimage.c 2009-05-14 01:34:04 UTC (rev 830)
@@ -414,6 +414,9 @@
#define OPTION_JT_INCLUDE 1106
#define OPTION_JT_EXCLUDE 1107
#define OPTION_JT_COMPRESS_ALGO 1108
+
+#define OPTION_JT_CHECKSUM_ALGO_ISO 1120
+#define OPTION_JT_CHECKSUM_ALGO_TMPL 1121
#endif
#define OPTION_BOOTALPHA 1200
@@ -691,6 +694,10 @@
'\0', "FILE", "File containing MD5 sums of the files that should be checked", ONE_DASH },
{{"jigdo-template-compress", required_argument, NULL, OPTION_JT_COMPRESS_ALGO},
'\0', "ALGORITHM", "Choose to use gzip or bzip2 compression for template data; default is gzip", ONE_DASH },
+ {{"checksum_algorithm_iso", required_argument, NULL, OPTION_JT_CHECKSUM_ALGO_ISO},
+ '\0', "alg1,alg2,...", "Specify the checksum types desired for the output image", ONE_DASH},
+ {{"checksum_algorithm_template", required_argument, NULL, OPTION_JT_CHECKSUM_ALGO_TMPL},
+ '\0', "alg1,alg2,...", "Specify the checksum types desired for the output jigdo template", ONE_DASH},
#endif
#ifdef SORTING
@@ -1496,7 +1503,33 @@
exit(1);
#endif
}
- break;
+ break;
+
+ case OPTION_JT_CHECKSUM_ALGO_ISO:
+ if (parse_checksum_algo(optarg, &checksum_algo_iso))
+ {
+#ifdef USE_LIBSCHILY
+ comerrno(EX_BAD, "Problem with ISO checksum choices: %s \n", optarg);
+#else
+ fprintf(stderr, "Problem with ISO checksum choices: %s\n", optarg);
+ exit(1);
+#endif
+ }
+
+ break;
+
+ case OPTION_JT_CHECKSUM_ALGO_TMPL:
+ if (parse_checksum_algo(optarg, &checksum_algo_tmpl))
+ {
+#ifdef USE_LIBSCHILY
+ comerrno(EX_BAD, "Problem with template checksum choices: %s \n", optarg);
+#else
+ fprintf(stderr, "Problem with template checksum choices: %s\n", optarg);
+ exit(1);
+#endif
+ }
+ break;
+
#endif /* JIGDO_TEMPLATE */
case OPTION_NOBAK:
all_files = 0;
Modified: cdrkit/trunk/genisoimage/jte.c
===================================================================
--- cdrkit/trunk/genisoimage/jte.c 2009-05-13 23:31:48 UTC (rev 829)
+++ cdrkit/trunk/genisoimage/jte.c 2009-05-14 01:34:04 UTC (rev 830)
@@ -79,13 +79,15 @@
struct path_mapping *map_list = NULL;
unsigned long long template_size = 0;
unsigned long long image_size = 0;
+int checksum_algo_iso = (CHECK_MD5_USED | \
+ CHECK_SHA1_USED | \
+ CHECK_SHA256_USED | \
+ CHECK_SHA512_USED);
+int checksum_algo_tmpl = CHECK_MD5_USED;
static checksum_context_t *iso_context = NULL;
static checksum_context_t *template_context = NULL;
-#define CHECK_USED_ISO (CHECK_MD5_USED | CHECK_SHA1_USED | CHECK_SHA256_USED | CHECK_SHA512_USED)
-#define CHECK_USED_TPL (CHECK_MD5_USED)
-
/* List of files that we've seen, ready to write into the template and
jigdo files */
typedef struct _file_entry
@@ -425,7 +427,7 @@
memset(buf, 0, sizeof(buf));
- template_context = checksum_init_context(CHECK_USED_TPL, "template");
+ template_context = checksum_init_context(checksum_algo_tmpl, "template");
if (!template_context)
{
#ifdef USE_LIBSCHILY
@@ -549,7 +551,7 @@
j_file = jigdo_file;
/* Start checksum work for the image */
- iso_context = checksum_init_context(CHECK_USED_ISO, "iso");
+ iso_context = checksum_init_context(checksum_algo_iso, "iso");
if (!iso_context)
{
#ifdef USE_LIBSCHILY
@@ -818,12 +820,20 @@
fprintf(j_file, "Template-MD5Sum=%s \n",
base64_dump(&template_md5sum[0], sizeof(template_md5sum)));
- fprintf(j_file, "# Template Hex MD5sum %s\n", checksum_hex(template_context, CHECK_MD5));
+
+ for (i = 0; i < NUM_CHECKSUMS; i++)
+ {
+ if (checksum_algo_tmpl & (1 << i))
+ {
+ info = checksum_information(i);
+ fprintf(j_file, "# Template Hex %sSum %s\n", info->name, checksum_hex(template_context, i));
+ }
+ }
fprintf(j_file, "# Template size %lld bytes\n", template_size);
for (i = 0; i < NUM_CHECKSUMS; i++)
{
- if (CHECK_USED_ISO & (1 << i))
+ if (checksum_algo_iso & (1 << i))
{
info = checksum_information(i);
fprintf(j_file, "# Image Hex %sSum %s\n", info->name, checksum_hex(iso_context, i));
Modified: cdrkit/trunk/genisoimage/jte.h
===================================================================
--- cdrkit/trunk/genisoimage/jte.h 2009-05-13 23:31:48 UTC (rev 829)
+++ cdrkit/trunk/genisoimage/jte.h 2009-05-14 01:34:04 UTC (rev 830)
@@ -15,6 +15,8 @@
extern FILE *jtjigdo;
extern FILE *jttemplate;
extern int jte_min_size;
+extern int checksum_algo_iso;
+extern int checksum_algo_tmpl;
extern void write_jt_header(FILE *template_file, FILE *jigdo_file);
extern void write_jt_footer(void);
More information about the Debburn-changes
mailing list