fields.c 20 KB

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