fields.c 20 KB

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