~ubuntu-branches/ubuntu/lucid/dpkg/lucid

« back to all changes in this revision

Viewing changes to lib/fields.c

  • Committer: Bazaar Package Importer
  • Author(s): Guillem Jover, Guillem Jover, Raphael Hertzog, Modestas Vainius, Updated dpkg translations, Updated dselect translations, Updated man page translations, Updated scripts translations
  • Date: 2009-09-06 09:37:45 UTC
  • mto: (1.4.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 68.
  • Revision ID: james.westby@ubuntu.com-20090906093745-orb3im04ozfxypis
Tags: 1.15.4
[ Guillem Jover ]
* Call _g instead of g_ in dpkg-name.
* Fix inverted logic when deciding to assume the architecture in dpkg-name
  when the package didn't have such field.
* Do not take into account Revision and Package_Revision fields in dpkg-name
  and dpkg-scanpackages as they have been handled already by “dpkg-deb -I”.
* Switch dpkg-scansources to use Dpkg::Cdata instead of duplicating the
  .dsc parsing code. As a side effect it now handles properly bogus files.
* Do not remap obsolete fields in dpkg-scanpackages as they have been
  handled already by “dpkg-deb -I”.
* Properly mark packages being purged for disappearance from the database.
  This will make the status database not be left behind with traces of old
  not-installed packages. Closes: #472208
* On parse mark not-installed leftover packages for automatic removal from
  the database on next dump. This obsoletes the --forget-old-unavail option,
  thus making it now a no-op. Closes: #33394, #429262
* Document “hold” under package selection states instead of flags in dpkg(1).
* Remove trailing ‘/’ and ‘/.’ from the directory name to be used as the
  package name on “dpkg-deb -b”. Closes: #218018, #373602
* Remove obsolete ‘hold’ and ‘hold-reinstreq’ internal status flags.
* Add fakeroot to dpkg-dev Recommends. Closes: #536821
* Fix an always false test when trying to decide which package to deselect
  to resolve a dependency problem in dselect.
* Add uClibc Linux support to ostable and triplettable. Closes: #455501
* Add uClinux support to ostable and triplettable.
  Thanks to Simon Richter <sjr@debian.org>.
* When aborting due to file conflicts print the version of the conflicted
  package. Closes: #540019
* Remove double slash in database path visible to the user in some error
  conditions.
* Stop macthing sparc64-*-* GNU triplets with sparc Debian architecture.
* Add support for config.d style directories in dpkg and dselect,
  (/etc/dpkg/dpkg.cfg.d and /etc/dpkg/dselect.cfg.d respectively).
* Define DPKG_MAINTSCRIPT_ARCH on the maintainer script environment to the
  architecture the package got built for.
* Document DPKG_MAINTSCRIPT_PACKAGE maintainer script environment variable
  in dpkg man page.
* Document DPKG_RUNNING_VERSION maintainer script environment variable
  in dpkg man page.
* Change po4a usage to not create unwated changes depending if doing out or
  in-tree builds.
* Use po4a “--previous” support when updating the man pages.
  Suggested by Christian Perrier <bubulle@debian.org>.
* On configuration error print file name and line number.
* Allow quoting values in configuration file options.
* Add new --pre-invoke and --post-invoke hooks in dpkg.
* Add new --control-path command to dpkg-query.
* Use ohshit on bad version syntax in --compare-versions.
* Add Multi-Arch to the list of known binary package fields for dpkg-dev.
  Thanks to Steve Langasek <vorlon@debian.org>.

[ Raphael Hertzog ]
* Replace install-info by a wrapper around GNU's install-info. The wrapper
  will be dropped in squeeze+1. dpkg now Breaks: old versions of
  info-browsers that do not depend on the new install-info package
  that provides the real functionality. Closes: #9771, #523980
  See http://wiki.debian.org/Transitions/DpkgToGnuInstallInfo for details.
* Fix dpkg's preinst in case /var/lib/dpkg/alternatives contains unexpected
  sub-directories. Closes: #535138
  And also when one of the file doesn't contain correct alternatives
  information (improper number of lines). Closes: #537558
* Upgrade Standards-Version to 3.8.2 (no changes).
* Update deb-substvars(5) to list fields that do not support substvars.
  Closes: #535353
* Fix dpkg-parsechangelog to include all entries with -v0 parameter.
  Closes: #537800
* Fix update-alternatives to mention the correct slave link that can't
  be installed due to a conflicting file instead of quoting the master link.
* Add support for extra override file in dpkg-scanpackages. Thanks to Robert
  Millan for the patch. Closes: #537559
* Add support for extra override file in dpkg-scansources.
* Document format of extra override file in a new manual page
  deb-extra-override(5).
* Update sample in dpkg-gensymbols(1) to give an accurate listing of
  64 bit arches. Thanks to Julien Cristau for the patch. Closes: #540382
* Create /etc/cron.daily/dpkg to handle the backup of
  /var/lib/dpkg/status in /var/backups. This is taken out of the cron
  package and need no conflicts/breaks as the code does nothing if
  the current status file is already backupped. Thanks to Leo 'costela'
  Antunes <costela@debian.org> for the patch. Closes: #541412
* Change behaviour of dpkg --merge-avail to not update a package's
  information if the version provided is older than the one already listed
  in the available file. Thanks to Ian Jackson
  <ian@davenant.greenend.org.uk> for the patch. Closes: #496114
* dpkg-architecture can now export DEB_{HOST,BUILD}_ARCH_{BITS,ENDIAN}
  (pointer size and endianness):
  - cputable (in dpkg) modified to contain those information
  - dpkg-dev depends on dpkg (>= 1.15.4) to ensure that we have an updated
    cputable (and so that a versioned build-dependency on dpkg-dev is enough
    to use this new feature)
  Closes: #531307
* Split overly long Binary: field values over multiple lines. This is
  allowed since policy 3.8.3. Closes: #494714
* Improve performance of dpkg-shlibdeps by caching minimal version
  associated to each library in Dpkg::Shlib::SymbolFile. Thanks to
  Jiří Paleček <jpalecek@web.de> for the patch.
* Slightly improve dpkg-source(1) by giving the section name that we're
  referring to. Closes: #544037
* Fix translation error in german manpage of dpkg-buildpackage. Thanks
  to Joachim Breitner <nomeata@debian.org>. Closes: #541829

[ Modestas Vainius ]
* Provide a meaningful label for dpkg-gensymbols diff.

[ Updated dpkg translations ]
* Asturian (Marcos Alvarez Costales). Closes: #535327
* French (Christian Perrier).
* German (Sven Joachim).
* Italian (Milo Casagrande). Closes: #536538
* Russian (Yuri Kozlov). Closes: #542254
* Slovak (Ivan Masár). Closes: #537742
* Swedish (Peter Krefting).

[ Updated dselect translations ]
* Russian (Yuri Kozlov). Closes: #542254
* Slovak (Ivan Masár). Closes: #537741

[ Updated man page translations ]
* French (Christian Perrier).
* German (Helge Kreutzmann), proofread by Jens Seidel.
* Swedish (Peter Krefting).

[ Updated scripts translations ]
* French completed (Christian Perrier).
* German (Helge Kreutzmann).
* Russian (Yuri Kozlov). Closes: #542254
* Swedish (Peter Krefting).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * libdpkg - Debian packaging suite library routines
3
 
 * fields.c - parsing of all the different fields, when reading in
4
 
 *
5
 
 * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
6
 
 * Copyright © 2001 Wichert Akkerman
7
 
 *
8
 
 * This is free software; you can redistribute it and/or modify
9
 
 * it under the terms of the GNU General Public License as
10
 
 * published by the Free Software Foundation; either version 2,
11
 
 * or (at your option) any later version.
12
 
 *
13
 
 * This is distributed in the hope that it will be useful, but
14
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU General Public
19
 
 * License along with dpkg; if not, write to the Free Software
20
 
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
 
 */
22
 
#include <config.h>
23
 
#include <compat.h>
24
 
 
25
 
#include <dpkg-i18n.h>
26
 
 
27
 
#include <stdio.h>
28
 
#include <ctype.h>
29
 
#include <string.h>
30
 
 
31
 
#include <dpkg.h>
32
 
#include <dpkg-db.h>
33
 
#include <dpkg-priv.h>
34
 
#include "parsedump.h"
35
 
 
36
 
static int
37
 
convert_string(const char *filename, int lno, const char *what, int otherwise,
38
 
               const struct pkginfo *pigp,
39
 
               const char *startp, const struct namevalue *ivip,
40
 
               const char **endpp)
41
 
{
42
 
  const char *ep;
43
 
  const struct namevalue *nvip = ivip;
44
 
 
45
 
  if (!*startp)
46
 
    parse_error(filename, lno, pigp, _("%s is missing"), what);
47
 
  while (nvip->name) {
48
 
    if (strncasecmp(nvip->name, startp, nvip->length))
49
 
      nvip++;
50
 
    else
51
 
      break;
52
 
  }
53
 
  if (!nvip->name) {
54
 
    if (otherwise != -1) return otherwise;
55
 
    parse_error(filename, lno, pigp, _("`%.*s' is not allowed for %s"),
56
 
                strnlen(startp, 50), startp, what);
57
 
  }
58
 
 
59
 
  ep = startp + nvip->length;
60
 
  while (isspace(*ep))
61
 
    ep++;
62
 
  if (*ep && !endpp)
63
 
    parse_error(filename, lno, pigp, _("junk after %s"), what);
64
 
  if (endpp) *endpp= ep;
65
 
  return nvip->value;
66
 
}
67
 
 
68
 
void f_name(struct pkginfo *pigp, struct pkginfoperfile *pifp, enum parsedbflags flags,
69
 
            const char *filename, int lno, FILE *warnto, int *warncount,
70
 
            const char *value, const struct fieldinfo *fip) {
71
 
  const char *e;
72
 
  if ((e= illegal_packagename(value,NULL)) != NULL)
73
 
    parse_error(filename, lno, pigp, _("invalid package name (%.250s)"), e);
74
 
  pigp->name= findpackage(value)->name;
75
 
  /* We use the new name, as findpackage() may have
76
 
     done a tolower for us.
77
 
   */
78
 
}
79
 
 
80
 
void f_filecharf(struct pkginfo *pigp, struct pkginfoperfile *pifp,
81
 
                 enum parsedbflags flags,
82
 
                 const char *filename, int lno, FILE *warnto, int *warncount,
83
 
                 const char *value, const struct fieldinfo *fip) {
84
 
  struct filedetails *fdp, **fdpp;
85
 
  char *cpos, *space;
86
 
  int allowextend;
87
 
 
88
 
  if (!*value)
89
 
    parse_error(filename, lno, pigp, _("empty file details field `%s'"), fip->name);
90
 
  if (!(flags & pdb_recordavailable))
91
 
    parse_error(filename, lno, pigp,
92
 
                _("file details field `%s' not allowed in status file"),
93
 
               fip->name);
94
 
  allowextend= !pigp->files;
95
 
  fdpp= &pigp->files;
96
 
  cpos= nfstrsave(value);
97
 
  while (*cpos) {
98
 
    space= cpos; while (*space && !isspace(*space)) space++;
99
 
    if (*space)
100
 
      *space++ = '\0';
101
 
    fdp= *fdpp;
102
 
    if (!fdp) {
103
 
      if (!allowextend)
104
 
        parse_error(filename, lno, pigp,
105
 
                    _("too many values in file details field `%s' "
106
 
                      "(compared to others)"), fip->name);
107
 
      fdp= nfmalloc(sizeof(struct filedetails));
108
 
      fdp->next= NULL;
109
 
      fdp->name= fdp->msdosname= fdp->size= fdp->md5sum= NULL;
110
 
      *fdpp= fdp;
111
 
    }
112
 
    FILEFFIELD(fdp,fip->integer,const char*)= cpos;
113
 
    fdpp= &fdp->next;
114
 
    while (*space && isspace(*space)) space++;
115
 
    cpos= space;
116
 
  }
117
 
  if (*fdpp)
118
 
    parse_error(filename, lno, pigp,
119
 
                _("too few values in file details field `%s' "
120
 
                  "(compared to others)"), fip->name);
121
 
}
122
 
 
123
 
void f_charfield(struct pkginfo *pigp, struct pkginfoperfile *pifp,
124
 
                 enum parsedbflags flags,
125
 
                 const char *filename, int lno, FILE *warnto, int *warncount,
126
 
                 const char *value, const struct fieldinfo *fip) {
127
 
  if (*value) PKGPFIELD(pifp,fip->integer,char*)= nfstrsave(value);
128
 
}
129
 
 
130
 
void f_boolean(struct pkginfo *pigp, struct pkginfoperfile *pifp,
131
 
               enum parsedbflags flags,
132
 
               const char *filename, int lno, FILE *warnto, int *warncount,
133
 
               const char *value, const struct fieldinfo *fip) {
134
 
  int boolean;
135
 
 
136
 
  if (!*value)
137
 
    return;
138
 
 
139
 
  boolean = convert_string(filename, lno, _("yes/no in boolean field"),
140
 
                           -1, pigp, value, booleaninfos, NULL);
141
 
  PKGPFIELD(pifp, fip->integer, int) = boolean;
142
 
}
143
 
 
144
 
void f_section(struct pkginfo *pigp, struct pkginfoperfile *pifp,
145
 
               enum parsedbflags flags,
146
 
               const char *filename, int lno, FILE *warnto, int *warncount,
147
 
               const char *value, const struct fieldinfo *fip) {
148
 
  if (!*value) return;
149
 
  pigp->section= nfstrsave(value);
150
 
}
151
 
 
152
 
void f_priority(struct pkginfo *pigp, struct pkginfoperfile *pifp,
153
 
                enum parsedbflags flags,
154
 
                const char *filename, int lno, FILE *warnto, int *warncount,
155
 
                const char *value, const struct fieldinfo *fip) {
156
 
  if (!*value) return;
157
 
  pigp->priority = convert_string(filename, lno, _("word in `priority' field"),
158
 
                                  pri_other, pigp, value, priorityinfos, NULL);
159
 
  if (pigp->priority == pri_other) pigp->otherpriority= nfstrsave(value);
160
 
}
161
 
 
162
 
void f_status(struct pkginfo *pigp, struct pkginfoperfile *pifp,
163
 
              enum parsedbflags flags,
164
 
              const char *filename, int lno, FILE *warnto, int *warncount,
165
 
              const char *value, const struct fieldinfo *fip) {
166
 
  const char *ep;
167
 
 
168
 
  if (flags & pdb_rejectstatus)
169
 
    parse_error(filename, lno, pigp,
170
 
                _("value for `status' field not allowed in this context"));
171
 
  if (flags & pdb_recordavailable) return;
172
 
  
173
 
  pigp->want = convert_string(filename, lno,
174
 
                             _("first (want) word in `status' field"), -1,
175
 
                              pigp, value, wantinfos, &ep);
176
 
  pigp->eflag = convert_string(filename, lno,
177
 
                              _("second (error) word in `status' field"), -1,
178
 
                               pigp, ep, eflaginfos, &ep);
179
 
  if (pigp->eflag & eflagf_obsoletehold) {
180
 
    pigp->want= want_hold;
181
 
    pigp->eflag &= ~eflagf_obsoletehold;
182
 
  }
183
 
  pigp->status= convert_string(filename,lno,_("third (status) word in `status' field"), -1,
184
 
                               pigp, ep, statusinfos, NULL);
185
 
}
186
 
 
187
 
void f_version(struct pkginfo *pigp, struct pkginfoperfile *pifp,
188
 
               enum parsedbflags flags,
189
 
               const char *filename, int lno, FILE *warnto, int *warncount,
190
 
               const char *value, const struct fieldinfo *fip) {
191
 
  const char *emsg;
192
 
  
193
 
  emsg= parseversion(&pifp->version,value);
194
 
  if (emsg)
195
 
    parse_error(filename, lno, pigp,
196
 
                _("error in Version string `%.250s': %.250s"), value, emsg);
197
 
}  
198
 
 
199
 
void f_revision(struct pkginfo *pigp, struct pkginfoperfile *pifp,
200
 
                enum parsedbflags flags,
201
 
                const char *filename, int lno, FILE *warnto, int *warncount,
202
 
                const char *value, const struct fieldinfo *fip) {
203
 
  char *newversion;
204
 
 
205
 
  parse_warn(filename, lno, warnto, warncount, pigp,
206
 
             _("obsolete `Revision' or `Package-Revision' field used"));
207
 
  if (!*value) return;
208
 
  if (pifp->version.revision && *pifp->version.revision) {
209
 
    newversion= nfmalloc(strlen(pifp->version.version)+strlen(pifp->version.revision)+2);
210
 
    sprintf(newversion,"%s-%s",pifp->version.version,pifp->version.revision);
211
 
    pifp->version.version= newversion;
212
 
  }
213
 
  pifp->version.revision= nfstrsave(value);
214
 
}  
215
 
 
216
 
void f_configversion(struct pkginfo *pigp, struct pkginfoperfile *pifp,
217
 
                     enum parsedbflags flags,
218
 
                     const char *filename, int lno, FILE *warnto, int *warncount,
219
 
                     const char *value, const struct fieldinfo *fip) {
220
 
  const char *emsg;
221
 
  
222
 
  if (flags & pdb_rejectstatus)
223
 
    parse_error(filename, lno, pigp,
224
 
                _("value for `config-version' field not allowed in this context"));
225
 
  if (flags & pdb_recordavailable) return;
226
 
 
227
 
  emsg= parseversion(&pigp->configversion,value);
228
 
  if (emsg)
229
 
    parse_error(filename, lno, pigp,
230
 
                _("error in Config-Version string `%.250s': %.250s"),
231
 
                value, emsg);
232
 
}
233
 
 
234
 
static void conffvalue_lastword(const char *value, const char *from,
235
 
                                const char *endent,
236
 
                                const char **word_start_r, int *word_len_r,
237
 
                                const char **new_from_r,
238
 
                                const char *filename, int lno,
239
 
                                struct pkginfo *pigp)
240
 
{
241
 
  /* the code in f_conffiles ensures that value[-1]==' ', which is helpful */
242
 
  const char *lastspc;
243
 
  
244
 
  if (from <= value+1) goto malformed;
245
 
  for (lastspc= from-1; *lastspc != ' '; lastspc--);
246
 
  if (lastspc <= value+1 || lastspc >= endent-1) goto malformed;
247
 
 
248
 
  *new_from_r= lastspc;
249
 
  *word_start_r= lastspc + 1;
250
 
  *word_len_r= (int)(from - *word_start_r);
251
 
  return;
252
 
 
253
 
malformed:
254
 
  parse_error(filename, lno, pigp,
255
 
              _("value for `conffiles' has malformatted line `%.*s'"),
256
 
              (int)min(endent - value, 250), value);
257
 
}
258
 
 
259
 
void f_conffiles(struct pkginfo *pigp, struct pkginfoperfile *pifp,
260
 
                 enum parsedbflags flags,
261
 
                 const char *filename, int lno, FILE *warnto, int *warncount,
262
 
                 const char *value, const struct fieldinfo *fip) {
263
 
  static const char obsolete_str[]= "obsolete";
264
 
  struct conffile **lastp, *newlink;
265
 
  const char *endent, *endfn, *hashstart;
266
 
  int c, namelen, hashlen, obsolete;
267
 
  char *newptr;
268
 
  
269
 
  lastp= &pifp->conffiles;
270
 
  while (*value) {
271
 
    c= *value++;
272
 
    if (c == '\n') continue;
273
 
    if (c != ' ')
274
 
      parse_error(filename, lno, pigp,
275
 
                  _("value for `conffiles' has line starting with non-space `%c'"),
276
 
                  c);
277
 
    for (endent = value; (c = *endent) != '\0' && c != '\n'; endent++) ;
278
 
    conffvalue_lastword(value, endent, endent,
279
 
                        &hashstart, &hashlen, &endfn,
280
 
                        filename, lno, pigp);
281
 
    obsolete= (hashlen == sizeof(obsolete_str)-1 &&
282
 
               !memcmp(hashstart, obsolete_str, hashlen));
283
 
    if (obsolete)
284
 
      conffvalue_lastword(value, endfn, endent,
285
 
                          &hashstart, &hashlen, &endfn,
286
 
                          filename, lno, pigp);
287
 
    newlink= nfmalloc(sizeof(struct conffile));
288
 
    value = path_skip_slash_dotslash(value);
289
 
    namelen= (int)(endfn-value);
290
 
    if (namelen <= 0)
291
 
      parse_error(filename, lno, pigp,
292
 
                  _("root or null directory is listed as a conffile"));
293
 
    newptr = nfmalloc(namelen+2);
294
 
    newptr[0]= '/';
295
 
    memcpy(newptr+1,value,namelen);
296
 
    newptr[namelen+1] = '\0';
297
 
    newlink->name= newptr;
298
 
    newptr= nfmalloc(hashlen+1);
299
 
    memcpy(newptr, hashstart, hashlen);
300
 
    newptr[hashlen] = '\0';
301
 
    newlink->hash= newptr;
302
 
    newlink->obsolete= obsolete;
303
 
    newlink->next =NULL;
304
 
    *lastp= newlink;
305
 
    lastp= &newlink->next;
306
 
    value= endent;
307
 
  }
308
 
}
309
 
 
310
 
void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
311
 
                  enum parsedbflags flags,
312
 
                  const char *filename, int lno, FILE *warnto, int *warncount,
313
 
                  const char *value, const struct fieldinfo *fip) {
314
 
  char c1, c2;
315
 
  const char *p, *emsg;
316
 
  const char *depnamestart, *versionstart;
317
 
  int depnamelength, versionlength;
318
 
  static int depnameused= 0, versionused= 0;
319
 
  static char *depname= NULL, *version= NULL;
320
 
 
321
 
  struct dependency *dyp, **ldypp;
322
 
  struct deppossi *dop, **ldopp;
323
 
 
324
 
  if (!*value) return; /* empty fields are ignored */
325
 
  p= value;
326
 
  ldypp= &pifp->depends; while (*ldypp) ldypp= &(*ldypp)->next;
327
 
  for (;;) { /* loop creating new struct dependency's */
328
 
    dyp= nfmalloc(sizeof(struct dependency));
329
 
    dyp->up= NULL; /* Set this to zero for now, as we don't know what our real
330
 
                 * struct pkginfo address (in the database) is going to be yet.
331
 
                 */
332
 
    dyp->next= NULL; *ldypp= dyp; ldypp= &dyp->next;
333
 
    dyp->list= NULL; ldopp= &dyp->list;
334
 
    dyp->type= fip->integer;
335
 
    for (;;) { /* loop creating new struct deppossi's */
336
 
      depnamestart= p;
337
 
/* skip over package name characters */
338
 
      while (*p && !isspace(*p) && *p != '(' && *p != ',' && *p != '|') {
339
 
        p++;
340
 
      }
341
 
      depnamelength= p - depnamestart ;
342
 
      if (depnamelength >= depnameused) {
343
 
        depnameused= depnamelength;
344
 
        depname = m_realloc(depname, depnamelength + 1);
345
 
      }
346
 
      strncpy(depname, depnamestart, depnamelength);
347
 
      *(depname + depnamelength) = '\0';
348
 
      if (!*depname)
349
 
        parse_error(filename, lno, pigp,
350
 
                    _("`%s' field, missing package name, or garbage where "
351
 
                      "package name expected"), fip->name);
352
 
      emsg= illegal_packagename(depname,NULL);
353
 
      if (emsg)
354
 
        parse_error(filename, lno, pigp,
355
 
                    _("`%s' field, invalid package name `%.255s': %s"),
356
 
                    fip->name, depname, emsg);
357
 
      dop= nfmalloc(sizeof(struct deppossi));
358
 
      dop->up= dyp;
359
 
      dop->ed= findpackage(depname);
360
 
      dop->next= NULL; *ldopp= dop; ldopp= &dop->next;
361
 
      dop->nextrev= NULL; /* Don't link this (which is after all only `newpig' from */
362
 
      dop->backrev= NULL; /* the main parsing loop in parsedb) into the depended on
363
 
                        * packages' lists yet.  This will be done later when we
364
 
                        * install this (in parse.c).  For the moment we do the
365
 
                        * `forward' links in deppossi (`ed') only, and the backward
366
 
                        * links from the depended on packages to dop are left undone.
367
 
                        */
368
 
      dop->cyclebreak= 0;
369
 
/* skip whitespace after packagename */
370
 
      while (isspace(*p)) p++;
371
 
      if (*p == '(') {                  /* if we have a versioned relation */
372
 
        p++; while (isspace(*p)) p++;
373
 
        c1= *p;
374
 
        if (c1 == '<' || c1 == '>') {
375
 
          c2= *++p;
376
 
          dop->verrel= (c1 == '<') ? dvrf_earlier : dvrf_later;
377
 
          if (c2 == '=') {
378
 
            dop->verrel |= (dvrf_orequal | dvrf_builtup);
379
 
            p++;
380
 
          } else if (c2 == c1) {
381
 
            dop->verrel |= (dvrf_strict | dvrf_builtup);
382
 
            p++;
383
 
          } else if (c2 == '<' || c2 == '>') {
384
 
            parse_error(filename, lno, pigp,
385
 
                        _("`%s' field, reference to `%.255s':\n"
386
 
                          " bad version relationship %c%c"),
387
 
                        fip->name, depname, c1, c2);
388
 
            dop->verrel= dvr_none;
389
 
          } else {
390
 
            parse_warn(filename, lno, warnto, warncount, pigp,
391
 
                       _("`%s' field, reference to `%.255s':\n"
392
 
                         " `%c' is obsolete, use `%c=' or `%c%c' instead"),
393
 
                       fip->name, depname, c1, c1, c1, c1);
394
 
            dop->verrel |= (dvrf_orequal | dvrf_builtup);
395
 
          }
396
 
        } else if (c1 == '=') {
397
 
          dop->verrel= dvr_exact;
398
 
          p++;
399
 
        } else {
400
 
          parse_warn(filename, lno, warnto, warncount, pigp,
401
 
                     _("`%s' field, reference to `%.255s':\n"
402
 
                       " implicit exact match on version number, "
403
 
                       "suggest using `=' instead"),
404
 
                     fip->name, depname);
405
 
          dop->verrel= dvr_exact;
406
 
        }
407
 
        if ((dop->verrel!=dvr_exact) && (fip->integer==dep_provides))
408
 
          parse_warn(filename, lno, warnto, warncount, pigp,
409
 
                     _("Only exact versions may be used for Provides"));
410
 
 
411
 
        if (!isspace(*p) && !isalnum(*p)) {
412
 
          parse_warn(filename, lno, warnto, warncount, pigp,
413
 
                     _("`%s' field, reference to `%.255s':\n"
414
 
                       " version value starts with non-alphanumeric, "
415
 
                       "suggest adding a space"),
416
 
                     fip->name, depname);
417
 
        }
418
 
/* skip spaces between the relation and the version */
419
 
        while (isspace(*p)) p++;
420
 
 
421
 
        versionstart= p;
422
 
        while (*p && *p != ')' && *p != '(') {
423
 
          if (isspace(*p)) break;
424
 
          p++;
425
 
        }
426
 
        versionlength= p - versionstart;
427
 
        while (isspace(*p)) p++;
428
 
        if (*p == '(')
429
 
          parse_error(filename, lno, pigp,
430
 
                      _("`%s' field, reference to `%.255s': "
431
 
                        "version contains `%c'"), fip->name,depname, ')');
432
 
        else if (*p != ')')
433
 
          parse_error(filename, lno, pigp,
434
 
                      _("`%s' field, reference to `%.255s': "
435
 
                        "version contains `%c'"), fip->name,depname, ' ');
436
 
        else if (*p == '\0')
437
 
          parse_error(filename, lno, pigp,
438
 
                      _("`%s' field, reference to `%.255s': "
439
 
                        "version unterminated"), fip->name, depname);
440
 
        if (versionlength >=  versionused) {
441
 
          versionused= versionlength;
442
 
          version = m_realloc(version, versionlength + 1);
443
 
        }
444
 
        strncpy(version,  versionstart, versionlength);
445
 
        *(version + versionlength) = '\0';
446
 
        emsg= parseversion(&dop->version,version);
447
 
        if (emsg)
448
 
          parse_error(filename, lno, pigp,
449
 
                      _("`%s' field, reference to `%.255s': "
450
 
                        "error in version: %.255s"), fip->name, depname, emsg);
451
 
        p++; while (isspace(*p)) p++;
452
 
      } else {
453
 
        dop->verrel= dvr_none;
454
 
        blankversion(&dop->version);
455
 
      }
456
 
      if (!*p || *p == ',') break;
457
 
      if (*p != '|')
458
 
        parse_error(filename, lno, pigp,
459
 
                    _("`%s' field, syntax error after reference to package `%.255s'"),
460
 
                    fip->name, dop->ed->name);
461
 
      if (fip->integer == dep_conflicts ||
462
 
          fip->integer == dep_breaks ||
463
 
          fip->integer == dep_provides ||
464
 
          fip->integer == dep_replaces)
465
 
        parse_error(filename, lno, pigp,
466
 
                    _("alternatives (`|') not allowed in %s field"), fip->name);
467
 
      p++; while (isspace(*p)) p++;
468
 
    }
469
 
    if (!*p) break;
470
 
    p++; while (isspace(*p)) p++;
471
 
  }
472
 
}
473
 
 
474
 
static const char *
475
 
scan_word(const char **valp)
476
 
{
477
 
  static char *buf;
478
 
  static int avail;
479
 
 
480
 
  int l;
481
 
  const char *p, *start, *end;
482
 
 
483
 
  p = *valp;
484
 
  for (;;) {
485
 
    if (!*p) {
486
 
      *valp = p;
487
 
      return NULL;
488
 
    }
489
 
    if (cisspace(*p)) {
490
 
      p++;
491
 
      continue;
492
 
    }
493
 
    start = p;
494
 
    break;
495
 
  }
496
 
  for (;;) {
497
 
    if (*p && !cisspace(*p)) {
498
 
      p++;
499
 
      continue;
500
 
    }
501
 
    end = p;
502
 
    break;
503
 
  }
504
 
  l = end - start;
505
 
  if (l >= avail) {
506
 
    avail = l * 2 + 4;
507
 
    buf = m_realloc(buf, avail);
508
 
  }
509
 
  memcpy(buf, start, l);
510
 
  buf[l] = '\0';
511
 
  *valp = p;
512
 
 
513
 
  return buf;
514
 
}
515
 
 
516
 
void
517
 
f_trigpend(struct pkginfo *pend, struct pkginfoperfile *pifp,
518
 
           enum parsedbflags flags,
519
 
           const char *filename, int lno, FILE *warnto, int *warncount,
520
 
           const char *value, const struct fieldinfo *fip)
521
 
{
522
 
  const char *word, *emsg;
523
 
 
524
 
  if (flags & pdb_rejectstatus)
525
 
    parse_error(filename, lno, pend,
526
 
                _("value for `triggers-pending' field not allowed in "
527
 
                  "this context"));
528
 
 
529
 
  while ((word = scan_word(&value))) {
530
 
    emsg = illegal_triggername(word);
531
 
    if (emsg)
532
 
      parse_error(filename, lno, pend,
533
 
                  _("illegal pending trigger name `%.255s': %s"), word, emsg);
534
 
 
535
 
    if (!trig_note_pend_core(pend, nfstrsave(word)))
536
 
      parse_error(filename, lno, pend,
537
 
                  _("duplicate pending trigger `%.255s'"), word);
538
 
  }
539
 
}
540
 
 
541
 
void
542
 
f_trigaw(struct pkginfo *aw, struct pkginfoperfile *pifp,
543
 
         enum parsedbflags flags,
544
 
         const char *filename, int lno, FILE *warnto, int *warncount,
545
 
         const char *value, const struct fieldinfo *fip)
546
 
{
547
 
  const char *word, *emsg;
548
 
  struct pkginfo *pend;
549
 
 
550
 
  if (flags & pdb_rejectstatus)
551
 
    parse_error(filename, lno, aw,
552
 
                _("value for `triggers-awaited' field not allowed in "
553
 
                  "this context"));
554
 
 
555
 
  while ((word = scan_word(&value))) {
556
 
    emsg = illegal_packagename(word, NULL);
557
 
    if (emsg)
558
 
      parse_error(filename, lno, aw,
559
 
                  _("illegal package name in awaited trigger `%.255s': %s"),
560
 
                  word, emsg);
561
 
    pend = findpackage(word);
562
 
 
563
 
    if (!trig_note_aw(pend, aw))
564
 
      parse_error(filename, lno, aw,
565
 
                  _("duplicate awaited trigger package `%.255s'"), word);
566
 
 
567
 
    trig_enqueue_awaited_pend(pend);
568
 
  }
569
 
}
570