Index: include/dpkg-db.h =================================================================== RCS file: /home/mh21/cvs/dpkg/include/dpkg-db.h,v retrieving revision 1.1 diff -u -r1.1 dpkg-db.h --- include/dpkg-db.h 11 Dec 2004 16:59:39 -0000 1.1 +++ include/dpkg-db.h 13 Dec 2004 11:47:15 -0000 @@ -132,6 +132,9 @@ pri_optional, pri_extra, pri_contrib, pri_other, pri_unknown, pri_unset=-1 } priority; + enum pkgremove { + rem_manual, rem_suggested, rem_recommended, rem_required + } remove; const char *otherpriority; const char *section; struct versionrevision configversion; @@ -217,6 +220,7 @@ extern const struct namevalue statusinfos[]; extern const struct namevalue eflaginfos[]; extern const struct namevalue wantinfos[]; +extern const struct namevalue removeinfos[]; const char *skip_slash_dotslash(const char *p); Index: include/parsedump.h =================================================================== RCS file: /home/mh21/cvs/dpkg/include/parsedump.h,v retrieving revision 1.1 diff -u -r1.1 parsedump.h --- include/parsedump.h 11 Dec 2004 16:59:39 -0000 1.1 +++ include/parsedump.h 11 Dec 2004 17:13:00 -0000 @@ -49,6 +49,7 @@ freadfunction f_name, f_charfield, f_priority, f_section, f_status, f_filecharf; freadfunction f_boolean, f_dependency, f_conffiles, f_version, f_revision; freadfunction f_configversion; +freadfunction f_remove; enum fwriteflags { fw_printheader = 001 /* print field header and trailing newline */ @@ -60,6 +61,7 @@ fwritefunction w_name, w_charfield, w_priority, w_section, w_status, w_configversion; fwritefunction w_version, w_null, w_booleandefno, w_dependency, w_conffiles; fwritefunction w_filecharf; +fwritefunction w_remove; struct fieldinfo { const char *name; Index: lib/database.c =================================================================== RCS file: /home/mh21/cvs/dpkg/lib/database.c,v retrieving revision 1.1 diff -u -r1.1 database.c --- lib/database.c 11 Dec 2004 16:59:40 -0000 1.1 +++ lib/database.c 11 Dec 2004 17:44:50 -0000 @@ -64,6 +64,7 @@ pigp->eflag= eflagv_ok; pigp->want= want_unknown; pigp->priority= pri_unknown; + pigp->remove= rem_manual; pigp->otherpriority = NULL; pigp->section= NULL; blankversion(&pigp->configversion); Index: lib/dump.c =================================================================== RCS file: /home/mh21/cvs/dpkg/lib/dump.c,v retrieving revision 1.1 diff -u -r1.1 dump.c --- lib/dump.c 11 Dec 2004 16:59:40 -0000 1.1 +++ lib/dump.c 14 Dec 2004 10:26:43 -0000 @@ -155,6 +155,19 @@ varbufaddc(vb,'\n'); } +void w_remove(struct varbuf *vb, + const struct pkginfo *pigp, const struct pkginfoperfile *pifp, + enum fwriteflags flags, const struct fieldinfo *fip) { + if (pifp != &pigp->installed) return; + if (pigp->remove == rem_manual) return; + assert(pigp->remove <= rem_required); + if (flags&fw_printheader) + varbufaddstr(vb,"Automatic-Remove: "); + varbufaddstr(vb,removeinfos[pigp->remove].name); + if (flags&fw_printheader) + varbufaddc(vb,'\n'); +} + void w_status(struct varbuf *vb, const struct pkginfo *pigp, const struct pkginfoperfile *pifp, enum fwriteflags flags, const struct fieldinfo *fip) { Index: lib/fields.c =================================================================== RCS file: /home/mh21/cvs/dpkg/lib/fields.c,v retrieving revision 1.1 diff -u -r1.1 fields.c --- lib/fields.c 11 Dec 2004 16:59:40 -0000 1.1 +++ lib/fields.c 11 Dec 2004 17:13:00 -0000 @@ -155,6 +155,16 @@ if (pigp->priority == pri_other) pigp->otherpriority= nfstrsave(value); } +void f_remove(struct pkginfo *pigp, struct pkginfoperfile *pifp, + enum parsedbflags flags, + const char *filename, int lno, FILE *warnto, int *warncount, + const char *value, const struct fieldinfo *fip) { + if (!*value) return; + pigp->remove= convert_string(filename,lno,"word in `remove' field", rem_manual, + warnto,warncount,pigp, + value,removeinfos,NULL); +} + void f_status(struct pkginfo *pigp, struct pkginfoperfile *pifp, enum parsedbflags flags, const char *filename, int lno, FILE *warnto, int *warncount, Index: lib/parse.c =================================================================== RCS file: /home/mh21/cvs/dpkg/lib/parse.c,v retrieving revision 1.1 diff -u -r1.1 parse.c --- lib/parse.c 11 Dec 2004 16:59:41 -0000 1.1 +++ lib/parse.c 13 Dec 2004 11:08:28 -0000 @@ -55,6 +55,7 @@ { "Version", f_version, w_version, PKGIFPOFF(version) }, { "Revision", f_revision, w_null }, { "Config-Version", f_configversion, w_configversion }, + { "Automatic-Remove", f_remove, w_remove }, { "Replaces", f_dependency, w_dependency, dep_replaces }, { "Provides", f_dependency, w_dependency, dep_provides }, { "Depends", f_dependency, w_dependency, dep_depends }, @@ -303,6 +304,7 @@ pigp->want= newpig.want; pigp->eflag= newpig.eflag; pigp->status= newpig.status; + pigp->remove= newpig.remove; pigp->configversion= newpig.configversion; pigp->files= NULL; } else if (!(flags & pdb_ignorefiles)) { Index: lib/parsehelp.c =================================================================== RCS file: /home/mh21/cvs/dpkg/lib/parsehelp.c,v retrieving revision 1.1 diff -u -r1.1 parsehelp.c --- lib/parsehelp.c 11 Dec 2004 16:59:41 -0000 1.1 +++ lib/parsehelp.c 11 Dec 2004 17:13:00 -0000 @@ -105,6 +105,14 @@ { NULL } }; +const struct namevalue removeinfos[]= { /* Note ! These must be in order ! */ + { "manual", rem_manual, 6 }, + { "suggested", rem_suggested, 9 }, + { "recommended", rem_recommended, 11 }, + { "required", rem_required, 8 }, + { NULL } +}; + const char *illegal_packagename(const char *p, const char **ep) { static const char alsoallowed[]= "-+._"; /* _ is deprecated */ static char buf[150]; Index: main/Makefile.in =================================================================== RCS file: /home/mh21/cvs/dpkg/main/Makefile.in,v retrieving revision 1.1 diff -u -r1.1 Makefile.in --- main/Makefile.in 11 Dec 2004 16:59:41 -0000 1.1 +++ main/Makefile.in 13 Dec 2004 12:09:56 -0000 @@ -8,7 +8,7 @@ SOURCES = main.c enquiry.c filesdb.c archives.c processarc.c \ cleanup.c select.c packages.c configure.c remove.c \ - help.c depcon.c errors.c update.c + help.c depcon.c errors.c update.c autoremove.c MAN8PAGES = dpkg.8 dpkg-query.8 Index: main/autoremove.c =================================================================== RCS file: main/autoremove.c diff -N main/autoremove.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ main/autoremove.c 15 Dec 2004 14:31:44 -0000 @@ -0,0 +1,136 @@ +/* + * dpkg - main program for package management + * autoremove.c - automatic dependency flags + * + * Copyright (C) 2004 Michael Hofmann
+ * + * based on select.c, + * Copyright (C) 1995,1996 Ian Jackson + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with dpkg; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include