~ubuntu-branches/debian/wheezy/dpkg/wheezy

« back to all changes in this revision

Viewing changes to dselect/pkgdepcon.cc

  • Committer: Bazaar Package Importer
  • Author(s): Guillem Jover, Guillem Jover, Raphaël Hertzog, Jonathan Nieder, Steve Langasek, Mark Hymers, Updated programs translations, Updated man page translations, Updated scripts translations, Updated dselect translations
  • Date: 2011-04-01 23:56:54 UTC
  • Revision ID: james.westby@ubuntu.com-20110401235654-8y800dtb75skfrh7
Tags: 1.16.0
[ Guillem Jover ]
* Use DPKG_MAINTSCRIPT_PACKAGE environment variable as package name on
  dpkg-divert when no --package or --local options have been specified.
* Do not allow versions starting with non-digit when doing strict parsing,
  warn otherwise.
* Update dpkg(1) to note that --status-fd output does not contain newlines
  in error messages anymore (this was fixed in 1.15.0).
* Add a new --status-logger option to dpkg, similar to --status-fd but
  instead invoke the command ourselves and feed the status information
  to its standard input. Suggested by Raphaël Hertzog.
* Add missing space in update-alternative --set-selections output.
* Add missing options to update-alternative --help output.
* Count “conffile name is duplicated” for dpkg-deb warning count summary.
* Improve and clarify strings for translation. Closes: #604914
* Prefix all fatal error messages with “error: ”.
* Do not check presence of update-rc.d in the PATH in dpkg, as it's not
  a program needed for dpkg correct operation.
* Fix dpkg -GEO options on multiple versions of the same packages.
  Closes: #31141
* Propagate --admindir to programs run from maintainer scritpts.
  Closes: #97076
* Do not fail when trying to remove the root directory. This will only
  happen either on distributions where dpkg is a foreign package manager,
  or on artificial dpkg databases.
* Always warn when parsing any package control data which does not have
  an Architecture field except for status and status log files when
  packages are not-installed or half-installed.
* By default reject installing packages w/o an Architecture field. They
  now need --force-architecture, dpkg will still warn about them though.
* Fix build failure when passing --disable-nls to configure.
* Do not segfault on “dpkg -i --no-act”.
* Add missing semicolon to the vsnprintf() compat declaration.
  Thanks to Robert Millan. Closes: #612203
* On install for Ubuntu adjust the i386 GNU cpu name in cputable.
  Thanks to Colin Watson <cjwatson@ubuntu.com>. Closes: #611741
* Sync the info database directory on unpack instead of the temporary
  control information directory, and print the correct pathname on error
  instead of the last file acted on that directory.
* Document in dpkg-query --help output and man page that --list and --show
  arguments are optional.
* Do not read and write the available file unnecessarily.
  Thanks to Michel Lespinasse <walken@zoy.org>. Closes: #397121
* Fix typo in «dpkg-name --overwrite» argument parsing so that it actually
  works at all. Thanks to Ivan Gagis <igagis@gmail.com>. LP: #728708
* Add armhf support to ostable and triplettable. Closes: #594179
* Set the modification time for unpacked symlinks on supported systems.
* Fix undefined value useage in dpkg-genchanges when adding files w/o a
  matching architecture, because they are not present in debian/control,
  this is most commonly the case due to dpkg-distaddfile.
* Terminate immediately on dpkg-divert rename errors instead of propagating
  up the error codes, this improves error reporting and avoids triggering
  leak detectors. Closes: #620380
* When moving a diverted file across filesystems in dpkg-divert, remove
  the source file.

[ Raphaël Hertzog ]
* Fail properly when debian/source/format is empty. Closes: #600854
* Add new deb-src-control(5) manual page documenting the debian/control
  file contained in source packages.
  - it documents the X[SBC]- prefix. Closes: #476335
  - it documents the VCS-* fields too. Closes: #483119
  Thanks to Oxan van Leeuwen <oxan@oxanvanleeuwen.nl> who wrote it
  as part of the Google Code In program.
* Enhance dpkg-shlibdeps to not fail immediatly when a library is not found.
  Instead continue and fail after all problems have been reported. Thanks
  to Chris Baines <cbaines8@gmail.com> for the patch. Closes: #596841
* Fix dpkg-source to not list Debian packaging files as modified
  upstream files in Format "1.0" when unpacking to a non-standard
  directory.
* Apply patch from Colin Watson to let dpkg-buildflags return -O3
  instead of -O2 when building ppc64 packages on Ubuntu. Closes: #612472
* Add new function get_control_path() to Dpkg::Path, it wraps dpkg-query
  --control-path.
* Update dpkg-shlibdeps to be multiarch-ready:
  - use get_control_path() to find symbols/shlibs files
  - parse correctly the output of dpkg --search
* Small fix to support files >2GB in .deb on 64-bit systems. Closes: #616502
  Thanks to Martin Dorey <mdorey@bluearc.com> for the patch.
* dpkg-source now keeps the file ordering in the autogenerated patch when
  regenerating it. Closes: #606080
  Thanks to Colin Watson for the patch.
* dpkg-source now uses a timestamp retrieved from the filesystem when
  resetting the timestamp of patched files so that a time skew when using
  NFS doesn't introduce any inconsistency. Closes: #613023
  Thanks to Jonathan Nieder <jrnieder@gmail.com> for the patch and the
  diagnosis.
* dpkg-source will now remove quilt's .pc directory when --unapply-patches
  is in use. Closes: #591858
* dpkg-source is now a bit less strict when parsing patches:
  - it accepts seeing the same file twice; Closes: #608829
  - it doesn't match on the English text "No newline at end of file" as it
    might be translated in some cases. Closes: #612465
* Improve parser in Dpkg::Control::Hash to not require an empty line
  before the PGP signature. Closes: #617923
  Thanks to Roger Leigh for the initial patch.
* Fix a regression in dpkg-divert where using --rename led to a failure when
  the rename implies crossing file systems. Thanks to Durk Strooisma for
  spotting it.
* Use the correct mtime when installing a file with statoverrides.
  Regression introduced in 1.16.0. LP: #739179
* Remove duplicate word in german translation of dpkg(1). Closes: #616096
* Strip repeated non-significant spaces before and after newlines
  in Uploaders. Closes: #598922
* Ignore whitespaces after options in headers of changelog entries.
  Closes: #605719
* Fix dpkg-source's regression with empty patches (introduced while fixing
  #613023). Closes: #619541

[ Jonathan Nieder ]
* Remove support for use of synchronous sync(2), due to its pernicious
  side-effects and to ease maintenance.
* Clarify that an up-to-date dpkg only needs to be unpacked for
  dpkg-maintscript-helper to work.

[ Steve Langasek ]
* Add new variables to dpkg-architecture, DEB_HOST_MULTIARCH and
  DEB_BUILD_MULTIARCH, that return the "ideal" GNU triplet for each
  architecture which should be used as the path component for library
  installation.

[ Mark Hymers ]
* Add support for Built-Using field. Closes: #619311

[ Updated programs translations ]
* German (Sven Joachim).
* Portuguese (Miguel Figueiredo).
* Spanish (Javier Fernandez-Sanguino).
* Swedish (Peter Krefting).

[ Updated man page translations ]
* German (Helge Kreutzmann).
* Swedish (Peter Krefting).

[ Updated scripts translations ]
* German (Helge Kreutzmann).
* Swedish (Peter Krefting).

[ Updated dselect translations ]
* Spanish (Javier Fernandez-Sanguino).

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "dselect.h"
32
32
#include "pkglist.h"
33
33
 
34
 
static const int depdebug= 1;
35
 
 
36
34
bool
37
35
packagelist::useavailable(pkginfo *pkg)
38
36
{
39
37
  if (pkg->clientdata &&
40
38
      pkg->clientdata->selected == pkginfo::want_install &&
41
 
      informative(pkg,&pkg->available) &&
 
39
      pkg_is_informative(pkg, &pkg->available) &&
42
40
      (!(pkg->status == pkginfo::stat_installed ||
43
41
         pkg->status == pkginfo::stat_triggersawaited ||
44
42
         pkg->status == pkginfo::stat_triggerspending) ||
48
46
    return false;
49
47
}
50
48
 
51
 
pkginfoperfile *packagelist::findinfo(pkginfo *pkg) {
52
 
  pkginfoperfile *r;
 
49
pkgbin *
 
50
packagelist::find_pkgbin(pkginfo *pkg)
 
51
{
 
52
  pkgbin *r;
53
53
  r= useavailable(pkg) ? &pkg->available : &pkg->installed;
54
 
  if (debug)
55
 
    fprintf(debug,"packagelist[%p]::findinfo(%s) useavailable=%d\n",this,pkg->name,useavailable(pkg));
 
54
  debug(dbg_general, "packagelist[%p]::find_pkgbin(%s) useavailable=%d",
 
55
        this, pkg->name, useavailable(pkg));
56
56
 
57
57
  return r;
58
58
}
59
 
  
 
59
 
60
60
int packagelist::checkdependers(pkginfo *pkg, int changemade) {
61
61
  struct deppossi *possi;
62
 
  
 
62
 
63
63
  for (possi = pkg->available.depended; possi; possi = possi->rev_next) {
64
64
    if (!useavailable(possi->up->up))
65
65
      continue;
78
78
  // only change the `suggested' value if we also increase the `priority'
79
79
  // Return 2 if we made a change due to a Recommended, Depends or Conficts,
80
80
  // or 1 if we offered or made a change because of an Optional line.
81
 
  if (debug)
82
 
    fprintf(debug,"packagelist[%p]::resolvesuggest()\n",this);
 
81
  debug(dbg_general, "packagelist[%p]::resolvesuggest()", this);
83
82
  int changemade, maxchangemade;
84
83
  maxchangemade= 0;
85
84
  for (;;) {
87
86
    int index;
88
87
    for (index=0; index<nitems; index++) {
89
88
      if (!table[index]->pkg->name) continue;
90
 
      if (depdebug && debug)
91
 
        fprintf(debug,"packagelist[%p]::resolvesuggest() loop[%i] %s / %d\n",
92
 
                this, index, table[index]->pkg->name, changemade);
 
89
      debug(dbg_depcon, "packagelist[%p]::resolvesuggest() loop[%i] %s / %d",
 
90
            this, index, table[index]->pkg->name, changemade);
93
91
      dependency *depends;
94
 
      for (depends= findinfo(table[index]->pkg)->depends;
 
92
      for (depends = find_pkgbin(table[index]->pkg)->depends;
95
93
           depends;
96
94
           depends= depends->next) {
97
95
        changemade = max(changemade, resolvedepcon(depends));
98
96
      }
99
97
      changemade= checkdependers(table[index]->pkg,changemade);
100
 
      for (depends= findinfo(table[index]->pkg)->depends;
 
98
      for (depends = find_pkgbin(table[index]->pkg)->depends;
101
99
           depends;
102
100
           depends= depends->next) {
103
101
        if (depends->type != dep_provides) continue;
104
102
        changemade= checkdependers(depends->list->ed,changemade);
105
103
      }
106
 
      if (depdebug && debug)
107
 
        fprintf(debug,"packagelist[%p]::resolvesuggest() loop[%i] %s / -> %d\n",
108
 
                this, index, table[index]->pkg->name, changemade);
 
104
      debug(dbg_depcon, "packagelist[%p]::resolvesuggest() loop[%i] %s / -> %d",
 
105
            this, index, table[index]->pkg->name, changemade);
109
106
    }
110
107
    if (!changemade) break;
111
108
    maxchangemade = max(maxchangemade, changemade);
112
109
  }
113
 
  if (debug)
114
 
    fprintf(debug,"packagelist[%p]::resolvesuggest() done; maxchangemade=%d\n",
115
 
            this,maxchangemade);
 
110
  debug(dbg_general, "packagelist[%p]::resolvesuggest() done; maxchangemade=%d",
 
111
        this, maxchangemade);
116
112
  return maxchangemade;
117
113
}
118
114
 
119
115
static int dep_update_best_to_change_stop(perpackagestate *& best, pkginfo *trythis) {
120
116
  // There's no point trying to select a pure virtual package.
121
117
  if (!trythis->clientdata) return 0;
122
 
  
123
 
  if (depdebug && debug)
124
 
    fprintf(debug,"update_best_to_change(best=%s{%d}, test=%s{%d});\n",
125
 
            best ? best->pkg->name : "", best ? (int)best->spriority : -1,
126
 
            trythis->name, trythis->clientdata->spriority);
 
118
 
 
119
  debug(dbg_depcon, "update_best_to_change(best=%s{%d}, test=%s{%d});",
 
120
        best ? best->pkg->name : "", best ? (int)best->spriority : -1,
 
121
        trythis->name, trythis->clientdata->spriority);
127
122
 
128
123
  // If the problem is caused by us deselecting one of these packages
129
124
  // we should not try to select another one instead.
133
128
  if (!best) goto yes;
134
129
 
135
130
  // If only one of the packages is available, use that one
136
 
  if (!informative(trythis,&trythis->available) &&
137
 
      informative(best->pkg,&best->pkg->available)) return 0;
138
 
  if (informative(trythis,&trythis->available) &&
139
 
      !informative(best->pkg,&best->pkg->available)) goto yes;
140
 
  
 
131
  if (!pkg_is_informative(trythis, &trythis->available) &&
 
132
      pkg_is_informative(best->pkg, &best->pkg->available))
 
133
    return 0;
 
134
  if (pkg_is_informative(trythis, &trythis->available) &&
 
135
      !pkg_is_informative(best->pkg, &best->pkg->available))
 
136
    goto yes;
 
137
 
141
138
  // Select the package with the lowest priority (ie, the one of whom
142
139
  // we were least sure we wanted it deselected).
143
140
  if (trythis->clientdata->spriority > best->spriority) return 0;
149
146
 
150
147
  // If we're still unsure we'll change the first one in the list.
151
148
  return 0;
152
 
  
 
149
 
153
150
 yes:
154
 
  if (depdebug && debug) fprintf(debug,"update_best_to_change(); yes\n");
 
151
  debug(dbg_depcon, "update_best_to_change(); yes");
155
152
 
156
153
  best=trythis->clientdata; return 0;
157
154
}
164
161
 
165
162
  if (!er || !would_like_to_install(er->selected,per) ||
166
163
      !ed || !would_like_to_install(ed->selected,ped)) return 0;
167
 
  
 
164
 
168
165
  add(dep, dp_must);
169
166
 
170
167
  er= per->clientdata;  // these can be changed by add
171
168
  ed= ped->clientdata;
172
 
  
173
 
  if (depdebug && debug)
174
 
    fprintf(debug,"packagelist[%p]::deselect_one_of(): er %s{%d} ed %s{%d} [%p]\n",
175
 
            this, er->pkg->name, er->spriority, ed->pkg->name, ed->spriority, dep);
176
 
  
 
169
 
 
170
  debug(dbg_depcon,
 
171
        "packagelist[%p]::deselect_one_of(): er %s{%d} ed %s{%d} [%p]",
 
172
        this, er->pkg->name, er->spriority, ed->pkg->name, ed->spriority, dep);
 
173
 
177
174
  perpackagestate *best;
178
175
 
179
176
  // Try not keep packages needing reinstallation.
190
187
    best = ed;
191
188
  else best= ed;                                      // ... failing that, the second
192
189
 
193
 
  if (depdebug && debug)
194
 
    fprintf(debug,"packagelist[%p]::deselect_one_of(): best %s{%d}\n",
195
 
            this, best->pkg->name, best->spriority);
 
190
  debug(dbg_depcon, "packagelist[%p]::deselect_one_of(): best %s{%d}",
 
191
        this, best->pkg->name, best->spriority);
196
192
 
197
193
  if (best->spriority >= sp_deselecting) return 0;
198
194
  best->suggested=
209
205
  deppossi *possi, *provider;
210
206
  int r, foundany;
211
207
 
212
 
  if (depdebug && debug) {
213
 
    fprintf(debug,"packagelist[%p]::resolvedepcon([%p] %s --%s-->",
214
 
            this, depends, depends->up->name, relatestrings[depends->type]);
215
 
    for (possi=depends->list; possi; possi=possi->next)
216
 
      fprintf(debug," %s",possi->ed->name);
217
 
    fprintf(debug,"); (ing)->want=%s\n",
218
 
            depends->up->clientdata
219
 
            ? wantstrings[depends->up->clientdata->suggested]
220
 
            : "(no clientdata)");
 
208
  if (debug_has_flag(dbg_depcon)) {
 
209
    varbuf pkg_names;
 
210
 
 
211
    for (possi = depends->list; possi; possi = possi->next) {
 
212
      pkg_names(' ');
 
213
      pkg_names(possi->ed->name);
 
214
    }
 
215
 
 
216
    debug(dbg_depcon,
 
217
          "packagelist[%p]::resolvedepcon([%p] %s --%s-->%s); (ing)->want=%s",
 
218
          this, depends, depends->up->name, relatestrings[depends->type],
 
219
          pkg_names.string(), depends->up->clientdata ?
 
220
          wantstrings[depends->up->clientdata->suggested] : "(no clientdata)");
221
221
  }
222
 
  
 
222
 
223
223
  if (!depends->up->clientdata) return 0;
224
224
 
225
225
  switch (depends->type) {
237
237
      return 0;
238
238
 
239
239
    fixbyupgrade= 0;
240
 
    
 
240
 
241
241
    possi = depends->list;
242
242
    while (possi && !deppossatisfied(possi, &fixbyupgrade))
243
243
      possi = possi->next;
244
 
    if (depdebug && debug)
245
 
      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): depends found %s\n",
246
 
              this,depends,
247
 
              possi ? possi->ed->name : "[none]");
 
244
    debug(dbg_depcon, "packagelist[%p]::resolvedepcon([%p]): depends found %s",
 
245
          this, depends, possi ? possi->ed->name : "[none]");
248
246
    if (possi) return 0;
249
247
 
250
248
    // Ensures all in the recursive list; adds info strings; ups priorities
253
251
    case dep_suggests:
254
252
        r= add(depends, dp_may);
255
253
        return r;
256
 
    case dep_recommends: 
 
254
    case dep_recommends:
257
255
        r= add(depends, dp_should);
258
256
        break;
259
257
    default:
261
259
    }
262
260
 
263
261
    if (fixbyupgrade) {
264
 
      if (depdebug && debug) fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): "
265
 
                            "fixbyupgrade %s\n", this,depends,fixbyupgrade->pkg->name);
 
262
      debug(dbg_depcon,
 
263
            "packagelist[%p]::resolvedepcon([%p]): fixbyupgrade %s",
 
264
            this, depends, fixbyupgrade->pkg->name);
266
265
      best= fixbyupgrade;
267
266
    } else {
268
267
      best= 0;
282
281
        if (!foundany) addunavailable(possi);
283
282
      }
284
283
      if (!best) {
285
 
        if (depdebug && debug) fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): "
286
 
                              "mustdeselect nobest\n", this,depends);
 
284
        debug(dbg_depcon,
 
285
              "packagelist[%p]::resolvedepcon([%p]): mustdeselect nobest",
 
286
              this, depends);
287
287
        return r;
288
288
      }
289
289
    }
290
 
    if (depdebug && debug)
291
 
      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): select best=%s{%d}\n",
292
 
              this,depends, best->pkg->name, best->spriority);
 
290
    debug(dbg_depcon,
 
291
          "packagelist[%p]::resolvedepcon([%p]): select best=%s{%d}",
 
292
          this, depends, best->pkg->name, best->spriority);
293
293
    if (best->spriority >= sp_selecting) return r;
294
294
    /* Always select depends. Only select recommends if we got here because
295
295
     * of a manually-initiated install request. */
298
298
      best->spriority= sp_selecting;
299
299
    }
300
300
    return r ? 2 : 0;
301
 
    
 
301
 
302
302
  mustdeselect:
303
303
    best= depends->up->clientdata;
304
 
    if (depdebug && debug)
305
 
      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): mustdeselect best=%s{%d}\n",
306
 
              this,depends, best->pkg->name, best->spriority);
 
304
    debug(dbg_depcon,
 
305
          "packagelist[%p]::resolvedepcon([%p]): mustdeselect best=%s{%d}",
 
306
          this, depends, best->pkg->name, best->spriority);
307
307
 
308
308
    if (best->spriority >= sp_deselecting) return r;
309
309
    /* Always remove depends, but never remove recommends. */
314
314
      best->spriority= sp_deselecting;
315
315
    }
316
316
    return r ? 2 : 0;
317
 
    
 
317
 
318
318
  case dep_conflicts:
319
319
  case dep_breaks:
 
320
    debug(dbg_depcon, "packagelist[%p]::resolvedepcon([%p]): conflict",
 
321
          this, depends);
320
322
 
321
 
    if (depdebug && debug)
322
 
      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): conflict\n",
323
 
              this,depends);
324
 
    
325
323
    if (would_like_to_install(depends->up->clientdata->selected,depends->up) == 0)
326
324
      return 0;
327
325
 
328
 
    if (depdebug && debug)
329
 
      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): conflict installing 1\n",
330
 
              this,depends);
 
326
    debug(dbg_depcon,
 
327
          "packagelist[%p]::resolvedepcon([%p]): conflict installing 1",
 
328
          this, depends);
331
329
 
332
330
    if (!deppossatisfied(depends->list,0)) return 0;
333
331
 
334
 
    if (depdebug && debug)
335
 
      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): conflict satisfied - ouch\n",
336
 
              this,depends);
 
332
    debug(dbg_depcon,
 
333
          "packagelist[%p]::resolvedepcon([%p]): conflict satisfied - ouch",
 
334
          this, depends);
337
335
 
338
336
    if (depends->up != depends->list->ed) {
339
337
      r= deselect_one_of(depends->up, depends->list->ed, depends);  if (r) return r;
345
343
      if (provider->up->up == depends->up) continue; // conflicts & provides same thing
346
344
      r= deselect_one_of(depends->up, provider->up->up, depends);  if (r) return r;
347
345
    }
348
 
    if (depdebug && debug)
349
 
      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): no desel\n", this,depends);
 
346
    debug(dbg_depcon, "packagelist[%p]::resolvedepcon([%p]): no desel",
 
347
          this, depends);
350
348
    return 0;
351
 
    
 
349
 
352
350
  default:
353
351
    internerr("unknown deptype");
354
352
  }
363
361
  //  restriction is violated ie that the target package is wanted
364
362
  int would;
365
363
  pkginfo::pkgwant want= pkginfo::want_purge;
366
 
  
 
364
 
367
365
  if (possi->ed->clientdata) {
368
366
    want= possi->ed->clientdata->selected;
369
367
    would= would_like_to_install(want,possi->ed);
370
368
  } else {
371
369
    would= 0;
372
370
  }
373
 
  
 
371
 
374
372
  if ((possi->up->type == dep_conflicts || possi->up->type == dep_breaks)
375
373
      ? possi->up->up != possi->ed && would != 0
376
374
      : would > 0) {