possibly working basedebs support
Ok,
This patch appears to work for me. A few things still need to be
fixed, but I'm posting this here now because it's my first patch for
b-f that is somewhat intrusive, so if I have the totally wrong
approach or anything, I'd like to know, before I finish shaking out
any bugs.
I still need to test if this breaks anything else...
Index: utilities/dbootstrap/choose_medium.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/choose_medium.c,v
retrieving revision 1.106
diff -u -r1.106 choose_medium.c
--- utilities/dbootstrap/choose_medium.c 2001/07/05 14:13:49 1.106
+++ utilities/dbootstrap/choose_medium.c 2001/07/12 07:10:36
@@ -23,6 +23,7 @@
int dirc = 0;
char **dirv;
char *pattern;
+char *backuppattern;
/* #### This and several other globals probably belong in a header also once more of this is librified. */
char *cdrom_device = NULL;
@@ -212,7 +213,7 @@
{
char buffer[PATH_MAX+1];
char buffer2[PATH_MAX+1];
- int i;
+ int i, found;
char *mountpoint, *descr = "", *def;
static char *preventry = NULL;
/* glob_t globbuf; */
@@ -284,6 +285,7 @@
break;
case debootstrap:
pattern = DEBIAN_ARCHIVE_PREFIX ARCHNAME "/Release";
+ backuppattern = BASETGZ;
descr = _("the Base system");
break;
#if #cpu(alpha)
@@ -312,33 +314,38 @@
else
snprintf(prtbuf, sizeof(prtbuf),
"%s/" DEBIAN_ARCHIVE_PREFIX ARCHNAME "/Release", mountpoint);
-
- if (NAME_ISREG(prtbuf, &statbuf)) {
- DEBUGMSG("located file at %s", prtbuf);
- /* do an additional test when installing kernel and modules,
- since we need drivers disk */
- if (disqtype == kernel) {
- snprintf(prtbuf, sizeof(prtbuf),"%s/" ARCHIVE_LOCATION "/%s",
- mountpoint, ARCHNAME, drivers_path);
- if (NAME_ISREG(prtbuf, &statbuf)) {
- /* success */
- snprintf(prtbuf, sizeof(prtbuf), "%s/" ARCHIVE_LOCATION,
- mountpoint, ARCHNAME);
- def = strdup(prtbuf);
- } else {
- INFOMSG("found kernel, but no drivers at %s", prtbuf);
- }
- } else {
- /* success, the file is where we expect it */
- if (disqtype != debootstrap ) {
- snprintf(prtbuf, sizeof(prtbuf), "%s/" ARCHIVE_LOCATION,
- mountpoint, ARCHNAME);
- def = strdup(prtbuf);
+
+ found = NAME_ISREG(prtbuf, &statbuf);
+ if (!found && backuppattern) {
+ snprintf(prtbuf, sizeof(prtbuf), "%s/%s",
+ mountpoint, backuppattern);
+ found = NAME_ISREG(prtbuf, &statbuf);
+ }
+
+ if (found) {
+ DEBUGMSG("located file at %s", prtbuf);
+ /* do an additional test when installing kernel and modules,
+ since we need drivers disk */
+ if (disqtype == kernel) {
+ snprintf(prtbuf, sizeof(prtbuf),"%s/" ARCHIVE_LOCATION "/%s",
+ mountpoint, ARCHNAME, drivers_path);
+ if (NAME_ISREG(prtbuf, &statbuf)) {
+ /* success */
+ snprintf(prtbuf, sizeof(prtbuf), "%s/" ARCHIVE_LOCATION,
+ mountpoint, ARCHNAME);
+ def = strdup(prtbuf);
+ } else {
+ INFOMSG("found kernel, but no drivers at %s", prtbuf);
+ }
+ } else if (disqtype == debootstrap) {
+ /* If we found basedebs.tgz, tell debootstrap about it */
+ def = strdup(strstr(prtbuf, BASETGZ) ? prtbuf : mountpoint);
+ DEBUGMSG("disqtype = debootstrap, def: %s", def ? def : "(null)");
} else {
- /* special handling for debootstrap, it wants the mountpoint */
- def = strdup(mountpoint);
+ snprintf(prtbuf, sizeof(prtbuf), "%s/" ARCHIVE_LOCATION,
+ mountpoint, ARCHNAME);
+ def = strdup(prtbuf);
}
- }
} else if (disqtype == kernel) {
/* try a flat dir structure */
INFOMSG(_("no file '%s' found, kernel not in default location"), prtbuf);
@@ -363,21 +370,34 @@
INFOMSG(_("no file '%s' found, Debian archive not in default location"),
prtbuf);
}
+
+ DEBUGMSG("def: %s", def ? def : "(null)");
+
if (def && ! bootargs.isverbose) {
/* there's a default, lets go with it */
status = 0;
} else {
if (def) {
- snprintf(prtbuf, sizeof(prtbuf),
- _("Please select the directory containing a file %s that you will use to install %s.\nUnless you really know what you need choose the default."),
- pattern, descr);
+ if (backuppattern)
+ snprintf(prtbuf, sizeof(prtbuf),
+ _("Please select the directory containing a file %s or %s that you will use to install %s.\nUnless you really know what you need choose the default."),
+ pattern, backuppattern, descr);
+ else
+ snprintf(prtbuf, sizeof(prtbuf),
+ _("Please select the directory containing a file %s that you will use to install %s.\nUnless you really know what you need choose the default."),
+ pattern, descr);
choices--;
ilist--;
items++;
} else {
- snprintf(prtbuf, sizeof(prtbuf),
- _("Please select the directory containing a file %s that you will use to install %s."),
- pattern, descr);
+ if (backuppattern)
+ snprintf(prtbuf, sizeof(prtbuf),
+ _("Please select the directory containing a file %s or %s that you will use to install %s."),
+ pattern, backuppattern, descr);
+ else
+ snprintf(prtbuf, sizeof(prtbuf),
+ _("Please select the directory containing a file %s that you will use to install %s."),
+ pattern, descr);
}
status = menuBox(prtbuf, _("Select Debian Archive path"),
choices, items, 1);
@@ -390,8 +410,8 @@
switch (data) {
case ARC_default:
- Archive_Dir = strdup(def);
- free(def);
+ Archive_Dir = def;
+ DEBUGMSG("default chosen, Archive_Dir: %s", Archive_Dir);
break;
case ARC_list:
/*
@@ -430,6 +450,13 @@
recursiveAction(mountpoint, TRUE, FALSE, FALSE, match_find, NULL);
}
#endif
+ if (dirc < 1 && backuppattern) {
+ char *opattern = pattern;
+ pattern = backuppattern;
+ DEBUGMSG(_("looking for %s under %s"), pattern, mountpoint);
+ recursiveAction(mountpoint, TRUE, FALSE, FALSE, match_find, NULL);
+ pattern = opattern;
+ }
boxPopWindow();
@@ -497,6 +524,7 @@
Archive_Dir = strdup(buffer);
snprintf(prtbuf, sizeof(prtbuf), "%s/%s", Archive_Dir,
pattern);
+ /* FIXME: add support for backuppattern here */
if (!NAME_ISREG(prtbuf, &statbuf)) {
INFOMSG("manual dir specified for %s, but %s not found", descr, prtbuf);
snprintf(prtbuf, sizeof(prtbuf),
Index: utilities/dbootstrap/extract_base.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/extract_base.c,v
retrieving revision 1.53
diff -u -r1.53 extract_base.c
--- utilities/dbootstrap/extract_base.c 2001/07/08 14:24:33 1.53
+++ utilities/dbootstrap/extract_base.c 2001/07/12 07:11:10
@@ -241,6 +241,7 @@
struct stat statbuf;
char *suite;
char *basesuite;
+ char *tem;
char *source;
char *msg=_("Please choose the release you would like to install. Unless you have specific needs you should choose \"stable\".");
char *title=_("Select a Distribution");
@@ -328,7 +329,7 @@
return -1;
}
-
+ DEBUGMSG("Extracting base, Archive_Dir: %s", Archive_Dir);
if (!strcmp (Archive_Dir, "netfetch"))
{
nf_initialize();
@@ -384,16 +385,22 @@
source = strdup("null:");
}
/* Are we trying to install from basedebs.tgz? */
- else if (strstr(Archive_Dir, BASETGZ)) {
+ else if (
+ ({
+ snprintf(prtbuf, sizeof(prtbuf), "%s/%s",
+ Archive_Dir, BASETGZ);
+ NAME_ISREG(prtbuf, &statbuf);
+ })) {
+ char *filename = strdup(prtbuf);
status = extract_from_file (filename, _("Basedebs"));
if (status) {
- ERRMSG("extracting %s failed with %d", Archive_Dir, status);
+ ERRMSG("extracting %s failed with %d", filename, status);
+ free(filename);
return 1;
}
+ free(filename);
source = strdup("null:");
- }
- else
- {
+ } else {
/* archive is on the filesystem */
snprintf(prtbuf, sizeof prtbuf, "file:%s", Archive_Dir);
source = strdup(prtbuf);
Reply to: