--- /dev/null
+.TH MKIMAGE 1 "September 2004" "Jigit jigdo tools"
+.SH NAME
+mkimage \- Create an ISO image from jigdo files
+.SH SYNOPSIS
+.B mkimage
+\-j \f jigdo\fR \-t \f template\fR
+[\fIoptions\fR]...
+.PP
+.B mkimage
+\-t \f template\fR \-z
+[\fIoptions\fR]...
+.PP
+.B mkimage
+\-f \f md5\-list\fR -t \f template\fR \-M \f missing\-list\fR
+[\fIoptions\fR]...
+.SH DESCRIPTION
+.PP
+mkimage knows how to parse a jigdo template file, commonly used when
+creating Debian CDs and DVDs. It can be used to actually convert a
+template file and associated files into an ISO image (hence the name
+mkimage), or with some command line options it will output useful
+information about the template file instead.
+.TP
+\fB\-t template file\fR
+The jigdo .template file is the most important thing that mkimage
+needs, and must be specified for all operations.
+.TP
+\fB\-j jigdo file\fR
+The jigdo .jigdo file will normally acompany the .template file. To
+rebuild the image you must specify \fBat least\fR one of the jigdo file and
+an MD5 file (\fB\-f\fR).
+.TP
+\fB\-f MD5 file\fR
+A file listing files available locally and their MD5 sums, in jigdo's
+base64-like format. Can be generated by jigdo-file or jigsum. To
+rebuild an image you must specify \fBat least\fR one of the MD5 file and
+a jigdo file (\fB\-j\fR).
+.TP
+\fB\-m item=path\fR
+Used in conjunction with a jigdo file; specify where mkimage should
+look on the local filesystem to find the files it needs to make an
+image. (e.g. "Debian=/mirror/debian").
+.TP
+\fB\-M missing file\fR
+If you're not sure if you have all the files needs to create an image,
+specify \fBboth\fR the jigdo file and an MD5 file along with the
+template file and \-M <file>. mkimage will check to see that all the
+files are available \fBinstead of\fR building the image. Any files
+that are missing will be listed in the file specified here. See jigit
+for usage examples.
+.TP
+\fB\-v\fR
+Make mkimage more verbose. Additional -v arguments will make it
+more verbose again. Default level is 0 (almost no output). 1 will
+print progress in % while the image is being created; 2 will list
+every file and data block that is appended to the image.
+.TP
+\fB\-l logfile\fR
+mkimage will normally write to stderr when it reports
+progress. Specify a logfile (or /dev/null) if you want it elsewhere.
+.TP
+\fB\-o outfile\fR
+mkimage will normally write the ISO image to stdout, ready for piping
+into cdrecord or to iso-image.pl. Specify an output filename if you
+want it written to disk instead.
+.TP
+\fB\-q\fR
+mkimage will normally check the MD5 sum of every file it reads and
+writes, and will fail if it finds any mismatches. Specify \fB-q\fR to
+tell it not to. This will normally run more quickly, but can leave you
+with a broken image so is \fBPOTENTIALLY DANGEROUS\fR. Use with care!
+.TP
+\fB\-s start offset\fR
+Rather than start at the beginning of the image, skip to the specified
+offset and start output there. Probably only useful in iso-image.pl
+when resuming a download. Specifying a non-zero offset also implies
+\fB-q\fR, as it's difficult to check MD5 sums when you're not checking
+the whole image.
+\fB\-e end offset\fR
+Rather than end at the end of the image, stop at the specified
+offset. Probably only useful in iso-image.pl when resuming a
+download. Specifying an end offset also implies \fB-q\fR, as it's
+difficult to check MD5 sums when you're not checking the whole image.
+.TP
+\fB\-z\fR
+Simply parse the template file and print the size of the image that
+would be generated, in bytes. Only needs the template file to be
+specified, any other arguments will ignored.
+.SH "EXAMPLES"
+.TP
+\fBmkimage -f MD5 -j test.jigdo -t test.template -M missing\fR
+Read in the files MD5, test.jigdo and test.template and check if all
+the needed files are available. If any are missing, list them in missing.
+.TP
+\fBmkimage -z -t test.template\fR
+Find out how big the ISO image would be from expanding test.template.
+.TP
+\fBmkimage -v -f MD5 -t test.template -o test.iso\fR
+Build the iso image in test.iso, using files listed in MD5 to fill in
+what's needed by the template file test.template. Show progress as the
+image is built.
+.SH "SEE ALSO"
+\fBjigdo-file\fP(1), \fBjigit\fP(1), \fBjigsum\fP(1) and \fBjigdump\fP(1).
+.SH "COPYRIGHT"
+Copyright 2004 Steve McIntyre (steve@einval.com)
+.PP
+mkimage may be copied under the terms and conditions of version 2
+of the GNU General Public License, as published by the Free
+Software Foundation (Cambridge, MA, USA).
+.SH "AUTHOR"
+Written by Steve McIntyre (steve@einval.com)
#ifdef BZ2_SUPPORT
# include <bzlib.h>
#endif
-#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
off_t total_offset;
} zip_state;
+/* Grab the file component from a full path */
+static char *file_base_name(char *path)
+{
+ char *endptr = path;
+ char *ptr = path;
+
+ while (*ptr != '\0')
+ {
+ if ('/' == *ptr)
+ endptr = ++ptr;
+ else
+ ++ptr;
+ }
+ return endptr;
+}
+
static void write_missing_entry(char *missing, char *filename)
{
if (!missing_file)
return sb.st_size;
}
-static void display_progress(FILE *file)
+static void display_progress(FILE *file, char *text)
{
off_t written = ftello(file);
if (out_size > 0)
- fprintf(logfile, "\r Image creation: %5.2f%% ",
- 100.0 * written / out_size);
+ fprintf(logfile, "\r %5.2f%% %-60.60s",
+ 100.0 * written / out_size, text);
}
static int add_match_entry(char *match)
return 0;
}
-static char *base64_dump(unsigned char *buf, size_t buf_size)
-{
- const char *b64_enc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
- int value = 0;
- unsigned int i;
- int bits = 0;
- char *out = calloc(1, 30);
- unsigned int out_pos = 0;
-
- if (!out)
- return NULL;
-
- for (i = 0; i < buf_size ; i++)
- {
- value = (value << 8) | buf[i];
- bits += 2;
- out[out_pos++] = b64_enc[(value >> bits) & 63U];
- if (bits >= 8) {
- bits -= 6;
- out[out_pos++] = b64_enc[(value >> bits) & 63U];
- }
- }
- if (bits > 0)
- {
- value <<= 8 - bits;
- out[out_pos++] = b64_enc[(value >> bits) & 63U];
- }
- return out;
-}
-
static int find_file_in_mirror(char *jigdo_entry, char **mirror_path, char **md5sum, off_t *file_size)
{
match_list_t *entry = match_list_head;
}
if (verbose)
- display_progress(outfile);
+ display_progress(outfile, "template data");
if (!quick)
mk_MD5Update(context, &zip_state.data_buf[zip_state.offset_in_curr_buf], size);
}
if (verbose)
- display_progress(outfile);
+ display_progress(outfile, file_base_name(md5_list_current->full_path));
remaining -= size;
}
return ENOENT;
}
-static int parse_template_file(char *filename, int sizeonly, char *missing)
+static int parse_template_file(char *filename, int sizeonly, char *missing, char *output_name)
{
off_t template_offset = 0;
off_t bytes = 0;
mk_MD5Init(&template_context);
template_offset = desc_start + 10;
+ if (1 == verbose)
+ fprintf(logfile, "Creating ISO image %s\n", output_name);
+
/* Main loop - walk through the template file and expand each entry we find */
while (1)
{
char *jigdo_filename = NULL;
char *md5_filename = NULL;
char *missing_filename = NULL;
+ char *output_name = NULL;
int c = -1;
int error = 0;
int sizeonly = 0;
setlinebuf(logfile);
break;
case 'o':
- outfile = fopen(optarg, "wb");
+ output_name = optarg;
+ outfile = fopen(output_name, "wb");
if (!outfile)
{
fprintf(stderr, "Unable to open output file %s\n", optarg);
return error;
}
}
-
+
+ if (!output_name)
+ output_name = "to stdout";
/* Read the template file and actually build the image to <outfile> */
- error = parse_template_file(template_filename, sizeonly, missing_filename);
+ error = parse_template_file(template_filename, sizeonly, missing_filename, output_name);
if (error)
{
fprintf(logfile, "Unable to recreate image from template file %s\n", template_filename);