diff options
author | jkh <jkh@FreeBSD.org> | 1999-05-12 09:02:37 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1999-05-12 09:02:37 +0000 |
commit | b76d716b0e46a03bde2cb1977af5a3a20799b1ef (patch) | |
tree | fa59b89744e2f5cc41f6a77c3a0efbdc8f089ea7 /usr.sbin | |
parent | 380c585aafacaf71050db6a68b08f8c8597405f2 (diff) | |
download | FreeBSD-src-b76d716b0e46a03bde2cb1977af5a3a20799b1ef.zip FreeBSD-src-b76d716b0e46a03bde2cb1977af5a3a20799b1ef.tar.gz |
Completely change the way package_add() does its work. Now we
handle dependencies at a lower level and use package add for this.
Also made index searches stricter.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/sade/config.c | 73 | ||||
-rw-r--r-- | usr.sbin/sade/install.c | 4 | ||||
-rw-r--r-- | usr.sbin/sade/sade.h | 5 | ||||
-rw-r--r-- | usr.sbin/sysinstall/config.c | 73 | ||||
-rw-r--r-- | usr.sbin/sysinstall/index.c | 58 | ||||
-rw-r--r-- | usr.sbin/sysinstall/install.c | 4 | ||||
-rw-r--r-- | usr.sbin/sysinstall/package.c | 30 | ||||
-rw-r--r-- | usr.sbin/sysinstall/sysinstall.h | 5 |
8 files changed, 130 insertions, 122 deletions
diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c index e9d3c03..5262cc1 100644 --- a/usr.sbin/sade/config.c +++ b/usr.sbin/sade/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.129 1999/05/05 11:34:00 jkh Exp $ + * $Id: config.c,v 1.130 1999/05/12 04:52:40 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -482,32 +482,32 @@ configXDesktop(dialogMenuItem *self) !(desk = variable_get(VAR_DESKSTYLE))) return DITEM_FAILURE; if (!strcmp(desk, "kde")) { - ret = package_add("@kde"); + ret = package_add("kde"); if (DITEM_STATUS(ret) != DITEM_FAILURE) write_root_xprofile("exec startkde\n"); } else if (!strcmp(desk, "gnome")) { - ret = package_add("@gnomecore"); + ret = package_add("gnomecore"); if (DITEM_STATUS(ret) != DITEM_FAILURE) { - ret = package_add("@afterstep"); + ret = package_add("afterstep"); if (DITEM_STATUS(ret) != DITEM_FAILURE) write_root_xprofile("gnome-session &\nexec afterstep"); } } else if (!strcmp(desk, "afterstep")) { - ret = package_add("@afterstep"); + ret = package_add("afterstep"); if (DITEM_STATUS(ret) != DITEM_FAILURE) write_root_xprofile("xterm &\nexec afterstep\n"); } else if (!strcmp(desk, "windowmaker")) { - ret = package_add("@windowmaker"); + ret = package_add("windowmaker"); if (DITEM_STATUS(ret) != DITEM_FAILURE) { vsystem("/usr/X11R6/bin/wmaker.inst"); write_root_xprofile("xterm &\nexec wmaker\n"); } } else if (!strcmp(desk, "enlightenment")) { - ret = package_add("@enlightenment"); + ret = package_add("enlightenment"); if (DITEM_STATUS(ret) != DITEM_FAILURE) write_root_xprofile("xterm &\nexec enlightenment\n"); } @@ -657,7 +657,7 @@ configRouter(dialogMenuItem *self) if (cp && strcmp(cp, "NO")) { variable_set2(VAR_ROUTER_ENABLE, "YES", 1); if (!strcmp(cp, "gated")) { - if (package_add("@gated") != DITEM_SUCCESS) { + if (package_add("gated") != DITEM_SUCCESS) { msgConfirm("Unable to load gated package. Falling back to no router."); variable_unset(VAR_ROUTER); variable_unset(VAR_ROUTERFLAGS); @@ -685,62 +685,35 @@ configRouter(dialogMenuItem *self) return ret | DITEM_RESTORE; } +/* Shared between us and index_initialize() */ +extern PkgNode Top, Plist; + int configPackages(dialogMenuItem *self) { - static PkgNode top, plist; - static Boolean index_initted = FALSE; + int i; PkgNodePtr tmp; - FILE *fp; - if (!mediaVerify()) - return DITEM_FAILURE; + /* Did we get an INDEX? */ + i = index_initialize("packages/INDEX"); + if (DITEM_STATUS(i) == DITEM_FAILURE) + return i; - if (!mediaDevice->init(mediaDevice)) - return DITEM_FAILURE; - - if (!index_initted) { - msgNotify("Attempting to fetch packages/INDEX file from selected media."); - fp = mediaDevice->get(mediaDevice, "packages/INDEX", TRUE); - if (!fp) { - dialog_clear_norefresh(); - msgConfirm("Unable to get packages/INDEX file from selected media.\n" - "This may be because the packages collection is not available at\n" - "on the distribution media you've chosen (most likely an FTP site\n" - "without the packages collection mirrored). Please verify media\n" - "(or path to media) and try again. If your local site does not\n" - "carry the packages collection, then we recommend either a CD\n" - "distribution or the master distribution on ftp.freebsd.org."); - mediaDevice->shutdown(mediaDevice); - return DITEM_FAILURE | DITEM_RESTORE; - } - msgNotify("Located INDEX, now reading package data from it..."); - index_init(&top, &plist); - if (index_read(fp, &top)) { - msgConfirm("I/O or format error on packages/INDEX file.\n" - "Please verify media (or path to media) and try again."); - fclose(fp); - return DITEM_FAILURE | DITEM_RESTORE; - } - fclose(fp); - index_sort(&top); - index_initted = TRUE; - } while (1) { int ret, pos, scroll; /* Bring up the packages menu */ pos = scroll = 0; - index_menu(&top, &top, &plist, &pos, &scroll); + index_menu(&Top, &Top, &Plist, &pos, &scroll); - if (plist.kids && plist.kids->name) { + if (Plist.kids && Plist.kids->name) { /* Now show the packing list menu */ pos = scroll = 0; - ret = index_menu(&plist, &plist, NULL, &pos, &scroll); + ret = index_menu(&Plist, &Plist, NULL, &pos, &scroll); if (ret & DITEM_LEAVE_MENU) break; else if (DITEM_STATUS(ret) != DITEM_FAILURE) { - index_extract(mediaDevice, &top, &plist); + index_extract(mediaDevice, &Top, &Plist); break; } } @@ -750,14 +723,14 @@ configPackages(dialogMenuItem *self) break; } } - tmp = plist.kids; + tmp = Plist.kids; while (tmp) { PkgNodePtr tmp2 = tmp->next; safe_free(tmp); tmp = tmp2; } - index_init(NULL, &plist); + index_init(NULL, &Plist); return DITEM_SUCCESS | DITEM_RESTORE; } @@ -767,7 +740,7 @@ configPCNFSD(dialogMenuItem *self) { int ret; - ret = package_add("@pcnfsd"); + ret = package_add("pcnfsd"); if (DITEM_STATUS(ret) == DITEM_SUCCESS) { variable_set2(VAR_PCNFSD, "YES", 0); variable_set2("mountd_flags", "-n", 1); diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index ac975b7..6e8141e 100644 --- a/usr.sbin/sade/install.c +++ b/usr.sbin/sade/install.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: install.c,v 1.234 1999/05/05 11:34:02 jkh Exp $ + * $Id: install.c,v 1.235 1999/05/07 11:02:56 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -1042,7 +1042,7 @@ installVarDefaults(dialogMenuItem *self) cp = "/usr/bin/ee"; variable_set2(VAR_EDITOR, cp, 0); variable_set2(VAR_FTP_USER, "ftp", 0); - variable_set2(VAR_BROWSER_PACKAGE, "@lynx", 0); + variable_set2(VAR_BROWSER_PACKAGE, "lynx", 0); variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx", 0); variable_set2(VAR_FTP_STATE, "passive", 0); variable_set2(VAR_NFS_SECURE, "YES", 0); diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index 123ed84..685eaa0 100644 --- a/usr.sbin/sade/sade.h +++ b/usr.sbin/sade/sade.h @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: sysinstall.h,v 1.162 1999/04/27 14:33:29 jkh Exp $ + * $Id: sysinstall.h,v 1.163 1999/05/07 11:02:58 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -529,6 +529,9 @@ void index_node_free(PkgNodePtr top, PkgNodePtr plist); void index_sort(PkgNodePtr top); void index_print(PkgNodePtr top, int level); int index_extract(Device *dev, PkgNodePtr top, PkgNodePtr plist); +int index_extract_one(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended); +int index_initialize(char *path); +PkgNodePtr index_search(PkgNodePtr top, char *str, PkgNodePtr *tp); /* install.c */ extern Boolean checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev); diff --git a/usr.sbin/sysinstall/config.c b/usr.sbin/sysinstall/config.c index e9d3c03..5262cc1 100644 --- a/usr.sbin/sysinstall/config.c +++ b/usr.sbin/sysinstall/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.129 1999/05/05 11:34:00 jkh Exp $ + * $Id: config.c,v 1.130 1999/05/12 04:52:40 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -482,32 +482,32 @@ configXDesktop(dialogMenuItem *self) !(desk = variable_get(VAR_DESKSTYLE))) return DITEM_FAILURE; if (!strcmp(desk, "kde")) { - ret = package_add("@kde"); + ret = package_add("kde"); if (DITEM_STATUS(ret) != DITEM_FAILURE) write_root_xprofile("exec startkde\n"); } else if (!strcmp(desk, "gnome")) { - ret = package_add("@gnomecore"); + ret = package_add("gnomecore"); if (DITEM_STATUS(ret) != DITEM_FAILURE) { - ret = package_add("@afterstep"); + ret = package_add("afterstep"); if (DITEM_STATUS(ret) != DITEM_FAILURE) write_root_xprofile("gnome-session &\nexec afterstep"); } } else if (!strcmp(desk, "afterstep")) { - ret = package_add("@afterstep"); + ret = package_add("afterstep"); if (DITEM_STATUS(ret) != DITEM_FAILURE) write_root_xprofile("xterm &\nexec afterstep\n"); } else if (!strcmp(desk, "windowmaker")) { - ret = package_add("@windowmaker"); + ret = package_add("windowmaker"); if (DITEM_STATUS(ret) != DITEM_FAILURE) { vsystem("/usr/X11R6/bin/wmaker.inst"); write_root_xprofile("xterm &\nexec wmaker\n"); } } else if (!strcmp(desk, "enlightenment")) { - ret = package_add("@enlightenment"); + ret = package_add("enlightenment"); if (DITEM_STATUS(ret) != DITEM_FAILURE) write_root_xprofile("xterm &\nexec enlightenment\n"); } @@ -657,7 +657,7 @@ configRouter(dialogMenuItem *self) if (cp && strcmp(cp, "NO")) { variable_set2(VAR_ROUTER_ENABLE, "YES", 1); if (!strcmp(cp, "gated")) { - if (package_add("@gated") != DITEM_SUCCESS) { + if (package_add("gated") != DITEM_SUCCESS) { msgConfirm("Unable to load gated package. Falling back to no router."); variable_unset(VAR_ROUTER); variable_unset(VAR_ROUTERFLAGS); @@ -685,62 +685,35 @@ configRouter(dialogMenuItem *self) return ret | DITEM_RESTORE; } +/* Shared between us and index_initialize() */ +extern PkgNode Top, Plist; + int configPackages(dialogMenuItem *self) { - static PkgNode top, plist; - static Boolean index_initted = FALSE; + int i; PkgNodePtr tmp; - FILE *fp; - if (!mediaVerify()) - return DITEM_FAILURE; + /* Did we get an INDEX? */ + i = index_initialize("packages/INDEX"); + if (DITEM_STATUS(i) == DITEM_FAILURE) + return i; - if (!mediaDevice->init(mediaDevice)) - return DITEM_FAILURE; - - if (!index_initted) { - msgNotify("Attempting to fetch packages/INDEX file from selected media."); - fp = mediaDevice->get(mediaDevice, "packages/INDEX", TRUE); - if (!fp) { - dialog_clear_norefresh(); - msgConfirm("Unable to get packages/INDEX file from selected media.\n" - "This may be because the packages collection is not available at\n" - "on the distribution media you've chosen (most likely an FTP site\n" - "without the packages collection mirrored). Please verify media\n" - "(or path to media) and try again. If your local site does not\n" - "carry the packages collection, then we recommend either a CD\n" - "distribution or the master distribution on ftp.freebsd.org."); - mediaDevice->shutdown(mediaDevice); - return DITEM_FAILURE | DITEM_RESTORE; - } - msgNotify("Located INDEX, now reading package data from it..."); - index_init(&top, &plist); - if (index_read(fp, &top)) { - msgConfirm("I/O or format error on packages/INDEX file.\n" - "Please verify media (or path to media) and try again."); - fclose(fp); - return DITEM_FAILURE | DITEM_RESTORE; - } - fclose(fp); - index_sort(&top); - index_initted = TRUE; - } while (1) { int ret, pos, scroll; /* Bring up the packages menu */ pos = scroll = 0; - index_menu(&top, &top, &plist, &pos, &scroll); + index_menu(&Top, &Top, &Plist, &pos, &scroll); - if (plist.kids && plist.kids->name) { + if (Plist.kids && Plist.kids->name) { /* Now show the packing list menu */ pos = scroll = 0; - ret = index_menu(&plist, &plist, NULL, &pos, &scroll); + ret = index_menu(&Plist, &Plist, NULL, &pos, &scroll); if (ret & DITEM_LEAVE_MENU) break; else if (DITEM_STATUS(ret) != DITEM_FAILURE) { - index_extract(mediaDevice, &top, &plist); + index_extract(mediaDevice, &Top, &Plist); break; } } @@ -750,14 +723,14 @@ configPackages(dialogMenuItem *self) break; } } - tmp = plist.kids; + tmp = Plist.kids; while (tmp) { PkgNodePtr tmp2 = tmp->next; safe_free(tmp); tmp = tmp2; } - index_init(NULL, &plist); + index_init(NULL, &Plist); return DITEM_SUCCESS | DITEM_RESTORE; } @@ -767,7 +740,7 @@ configPCNFSD(dialogMenuItem *self) { int ret; - ret = package_add("@pcnfsd"); + ret = package_add("pcnfsd"); if (DITEM_STATUS(ret) == DITEM_SUCCESS) { variable_set2(VAR_PCNFSD, "YES", 0); variable_set2("mountd_flags", "-n", 1); diff --git a/usr.sbin/sysinstall/index.c b/usr.sbin/sysinstall/index.c index c02d4ad..da4c3e9 100644 --- a/usr.sbin/sysinstall/index.c +++ b/usr.sbin/sysinstall/index.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: index.c,v 1.63 1999/02/15 04:57:07 jkh Exp $ + * $Id: index.c,v 1.64 1999/04/06 08:25:52 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -55,9 +55,11 @@ struct ListPtrs }; typedef struct ListPtrs* ListPtrsPtr; -static int index_extract_one(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended); static void index_recorddeps(Boolean add, PkgNodePtr root, IndexEntryPtr ie); +/* Shared between index_initialize() and the various clients of it */ +PkgNode Top, Plist; + /* Smarter strdup */ inline char * _strdup(char *ptr) @@ -409,7 +411,7 @@ index_search(PkgNodePtr top, char *str, PkgNodePtr *tp) continue; /* If tp == NULL, we're looking for an exact package match */ - if (!tp && !strncmp(p->name, str, strlen(str))) + if (!tp && !strcmp(p->name, str)) return p; /* If tp, we're looking for both a package and a pointer to the place it's in */ @@ -624,11 +626,11 @@ index_extract(Device *dev, PkgNodePtr top, PkgNodePtr plist) int status = DITEM_SUCCESS; for (tmp = plist->kids; tmp && tmp->name; tmp = tmp->next) - status = index_extract_one(dev, top, tmp, FALSE); + status |= index_extract_one(dev, top, tmp, FALSE); return status; } -static int +int index_extract_one(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended) { int status = DITEM_SUCCESS; @@ -703,3 +705,49 @@ index_recorddeps(Boolean add, PkgNodePtr root, IndexEntryPtr ie) todo = NULL; } } + +static Boolean index_initted; + +/* Read and initialize global index */ +int +index_initialize(char *path) +{ + FILE *fp; + + if (!index_initted) { + /* Got any media? */ + if (!mediaVerify()) + return DITEM_FAILURE; + + /* Does it move when you kick it? */ + if (!mediaDevice->init(mediaDevice)) + return DITEM_FAILURE; + + msgNotify("Attempting to fetch %s file from selected media.", path); + fp = mediaDevice->get(mediaDevice, path, TRUE); + if (!fp) { + dialog_clear_norefresh(); + msgConfirm("Unable to get packages/INDEX file from selected media.\n" + "This may be because the packages collection is not available at\n" + "on the distribution media you've chosen (most likely an FTP site\n" + "without the packages collection mirrored). Please verify media\n" + "(or path to media) and try again. If your local site does not\n" + "carry the packages collection, then we recommend either a CD\n" + "distribution or the master distribution on ftp.freebsd.org."); + mediaDevice->shutdown(mediaDevice); + return DITEM_FAILURE | DITEM_RESTORE; + } + msgNotify("Located INDEX, now reading package data from it..."); + index_init(&Top, &Plist); + if (index_read(fp, &Top)) { + msgConfirm("I/O or format error on packages/INDEX file.\n" + "Please verify media (or path to media) and try again."); + fclose(fp); + return DITEM_FAILURE | DITEM_RESTORE; + } + fclose(fp); + index_sort(&Top); + index_initted = TRUE; + } + return DITEM_SUCCESS | DITEM_RESTORE; +} diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index ac975b7..6e8141e 100644 --- a/usr.sbin/sysinstall/install.c +++ b/usr.sbin/sysinstall/install.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: install.c,v 1.234 1999/05/05 11:34:02 jkh Exp $ + * $Id: install.c,v 1.235 1999/05/07 11:02:56 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -1042,7 +1042,7 @@ installVarDefaults(dialogMenuItem *self) cp = "/usr/bin/ee"; variable_set2(VAR_EDITOR, cp, 0); variable_set2(VAR_FTP_USER, "ftp", 0); - variable_set2(VAR_BROWSER_PACKAGE, "@lynx", 0); + variable_set2(VAR_BROWSER_PACKAGE, "lynx", 0); variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx", 0); variable_set2(VAR_FTP_STATE, "passive", 0); variable_set2(VAR_NFS_SECURE, "YES", 0); diff --git a/usr.sbin/sysinstall/package.c b/usr.sbin/sysinstall/package.c index 31bb9fb..96058b9 100644 --- a/usr.sbin/sysinstall/package.c +++ b/usr.sbin/sysinstall/package.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: package.c,v 1.69 1999/05/12 06:11:32 jkh Exp $ + * $Id: package.c,v 1.70 1999/05/12 07:12:01 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -49,13 +49,27 @@ catch_pipe(int sig) sigpipe_caught = TRUE; } -/* Like package_extract, but assumes current media device */ +extern PkgNode Top; + +/* Like package_extract, but assumes current media device and chases deps */ int package_add(char *name) { + PkgNodePtr tmp; + int i; + if (!mediaVerify()) return DITEM_FAILURE; - return package_extract(mediaDevice, name, FALSE); + i = index_initialize("packages/INDEX"); + if (DITEM_STATUS(i) != DITEM_SUCCESS) + return i; + tmp = index_search(&Top, name, NULL); + if (tmp) + return index_extract_one(mediaDevice, &Top, tmp, FALSE); + else { + msgConfirm("Sorry, package %s was not found in the INDEX.", name); + return DITEM_FAILURE | DITEM_RESTORE; + } } /* For use by dispatch */ @@ -79,10 +93,6 @@ package_exists(char *name) char fname[FILENAME_MAX]; int status /* = vsystem("pkg_info -e %s", name) */; - /* If in "Latest" syntax, ignore; can't tell with these */ - if (name[0] == '@') - return FALSE; - /* XXX KLUDGE ALERT! This makes evil assumptions about how XXX * packages register themselves and should *really be done with * `pkg_info -e <name>' except that this it's too slow for an @@ -126,10 +136,8 @@ package_extract(Device *dev, char *name, Boolean depended) Mkdir(variable_get(VAR_PKG_TMPDIR)); vsystem("chmod 1777 %s", variable_get(VAR_PKG_TMPDIR)); - if (name[0] == '@') { - /* @ at the beginning of the package name means "get latest" */ - sprintf(path, "packages/Latest/%s.tgz", ++name); - } + if (!strpbrk(name, "-_")) + sprintf(path, "packages/Latest/%s.tgz", name); else if (!index(name, '/')) sprintf(path, "packages/All/%s%s", name, strstr(name, ".tgz") ? "" : ".tgz"); else diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index 123ed84..685eaa0 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.h @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: sysinstall.h,v 1.162 1999/04/27 14:33:29 jkh Exp $ + * $Id: sysinstall.h,v 1.163 1999/05/07 11:02:58 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -529,6 +529,9 @@ void index_node_free(PkgNodePtr top, PkgNodePtr plist); void index_sort(PkgNodePtr top); void index_print(PkgNodePtr top, int level); int index_extract(Device *dev, PkgNodePtr top, PkgNodePtr plist); +int index_extract_one(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended); +int index_initialize(char *path); +PkgNodePtr index_search(PkgNodePtr top, char *str, PkgNodePtr *tp); /* install.c */ extern Boolean checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev); |