Add --format option to mkinitrd(1).
This commit is contained in:
parent
5e124c9df0
commit
e7844535e0
2
Makefile
2
Makefile
|
@ -230,7 +230,7 @@ $(INITRD): sysroot
|
||||||
echo "exclude /tix/$$OTHER_PLATFORM" >> $(INITRD).filter; \
|
echo "exclude /tix/$$OTHER_PLATFORM" >> $(INITRD).filter; \
|
||||||
done;
|
done;
|
||||||
if ! which mkinitrd; then echo You need to install mkinitrd; fi
|
if ! which mkinitrd; then echo You need to install mkinitrd; fi
|
||||||
mkinitrd --filter $(INITRD).filter "$(SYSROOT)" -o $(INITRD)
|
mkinitrd --format=sortix-initrd-2 --filter=$(INITRD).filter "$(SYSROOT)" -o $(INITRD)
|
||||||
rm -f $(INITRD).filter
|
rm -f $(INITRD).filter
|
||||||
|
|
||||||
.PHONY: initrd
|
.PHONY: initrd
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#define VERSIONSTR "unknown version"
|
#define VERSIONSTR "unknown version"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DEFAULT_FORMAT "sortix-initrd-2"
|
||||||
|
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
#include "rules.h"
|
#include "rules.h"
|
||||||
|
|
||||||
|
@ -517,6 +519,7 @@ static void help(FILE* fp, const char* argv0)
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
fprintf(fp, "Mandatory arguments to long options are mandatory for short options too.\n");
|
fprintf(fp, "Mandatory arguments to long options are mandatory for short options too.\n");
|
||||||
fprintf(fp, " --filter=FILE import filter rules from FILE\n");
|
fprintf(fp, " --filter=FILE import filter rules from FILE\n");
|
||||||
|
fprintf(fp, " --format=FORMAT format version [%s]\n", DEFAULT_FORMAT);
|
||||||
fprintf(fp, " -o, --output=FILE write result to FILE\n");
|
fprintf(fp, " -o, --output=FILE write result to FILE\n");
|
||||||
fprintf(fp, " --help display this help and exit\n");
|
fprintf(fp, " --help display this help and exit\n");
|
||||||
fprintf(fp, " --version output version information and exit\n");
|
fprintf(fp, " --version output version information and exit\n");
|
||||||
|
@ -533,6 +536,7 @@ static void version(FILE* fp, const char* argv0)
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
char* arg_filter = NULL;
|
char* arg_filter = NULL;
|
||||||
|
char* arg_format = strdup(DEFAULT_FORMAT);
|
||||||
char* arg_output = NULL;
|
char* arg_output = NULL;
|
||||||
|
|
||||||
const char* argv0 = argv[0];
|
const char* argv0 = argv[0];
|
||||||
|
@ -587,6 +591,7 @@ int main(int argc, char* argv[])
|
||||||
free(arg_filter);
|
free(arg_filter);
|
||||||
arg_filter = NULL;
|
arg_filter = NULL;
|
||||||
}
|
}
|
||||||
|
else if ( GET_OPTION_VARIABLE("--format", &arg_format) ) { }
|
||||||
else if ( GET_OPTION_VARIABLE("--output", &arg_output) ) { }
|
else if ( GET_OPTION_VARIABLE("--output", &arg_output) ) { }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -625,6 +630,18 @@ int main(int argc, char* argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* format = arg_format;
|
||||||
|
|
||||||
|
if ( !strcmp(format, "default") )
|
||||||
|
format = DEFAULT_FORMAT;
|
||||||
|
|
||||||
|
if ( strcmp(format, "sortix-initrd-2") != 0 )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: Unsupported format `%s'\n", argv0, format);
|
||||||
|
fprintf(stderr, "Try `%s --help' for more information.\n", argv0);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const char* rootstr = argv[1];
|
const char* rootstr = argv[1];
|
||||||
|
|
||||||
uint32_t inodecount = 1;
|
uint32_t inodecount = 1;
|
||||||
|
|
|
@ -102,7 +102,7 @@ initrd:
|
||||||
echo exclude /etc/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
|
echo exclude /etc/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
|
||||||
echo exclude /include/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
|
echo exclude /include/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
|
||||||
echo exclude /tix/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
|
echo exclude /tix/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
|
||||||
mkinitrd $(ROOT)/ -o $(INITRD) --filter $(INITRD_FILTER)
|
mkinitrd $(ROOT)/ -o $(INITRD) --format=sortix-initrd-2 --filter=$(INITRD_FILTER)
|
||||||
rm -f $(INITRD_FILTER)
|
rm -f $(INITRD_FILTER)
|
||||||
gzip -v $(INITRD)
|
gzip -v $(INITRD)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue