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

« back to all changes in this revision

Viewing changes to dpkg-split/queue.c

  • 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:
18
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
19
 */
20
20
 
21
 
/*
22
 
 * Queue, in /var/lib/dpkg/parts, is a plain directory with one
23
 
 * file per part.
24
 
 *
25
 
 * parts are named
26
 
 *  <md5sum>.<maxpartlen>.<thispartn>.<maxpartn>
27
 
 * all numbers in hex
28
 
 */
29
 
 
30
21
#include <config.h>
31
22
#include <compat.h>
32
23
 
34
25
 
35
26
#include <assert.h>
36
27
#include <limits.h>
 
28
#include <inttypes.h>
37
29
#include <string.h>
38
30
#include <fcntl.h>
39
31
#include <dirent.h>
40
32
#include <unistd.h>
 
33
#include <stdint.h>
41
34
#include <stdlib.h>
42
35
#include <stdio.h>
43
36
 
45
38
#include <dpkg/dpkg.h>
46
39
#include <dpkg/dpkg-db.h>
47
40
#include <dpkg/dir.h>
 
41
#include <dpkg/buffer.h>
48
42
#include <dpkg/myopt.h>
49
43
 
50
44
#include "dpkg-split.h"
51
45
 
 
46
/*
 
47
 * The queue, by default located in /var/lib/dpkg/parts/, is a plain
 
48
 * directory with one file per part.
 
49
 *
 
50
 * Each part is named “<md5sum>.<maxpartlen>.<thispartn>.<maxpartn>”,
 
51
 * with all numbers in hex.
 
52
 */
 
53
 
 
54
 
52
55
static bool
53
56
decompose_filename(const char *filename, struct partqueue *pq)
54
57
{
63
66
  q[MD5HASHLEN] = '\0';
64
67
  pq->info.md5sum= q;
65
68
  p = filename + MD5HASHLEN + 1;
66
 
  pq->info.maxpartlen = strtol(p, &q, 16);
 
69
  pq->info.maxpartlen = strtoimax(p, &q, 16);
67
70
  if (q == p || *q++ != '.')
68
71
    return false;
69
72
  p = q;
80
83
void scandepot(void) {
81
84
  DIR *depot;
82
85
  struct dirent *de;
83
 
  struct partqueue *pq;
84
 
  char *p;
85
86
 
86
87
  assert(!queue);
87
88
  depot = opendir(opt_depotdir);
88
89
  if (!depot)
89
90
    ohshite(_("unable to read depot directory `%.250s'"), opt_depotdir);
90
91
  while ((de= readdir(depot))) {
 
92
    struct partqueue *pq;
 
93
    char *p;
 
94
 
91
95
    if (de->d_name[0] == '.') continue;
92
96
    pq= nfmalloc(sizeof(struct partqueue));
93
97
    pq->info.fmtversion= pq->info.package= pq->info.version= NULL;
116
120
          pi->maxpartlen == refi->maxpartlen);
117
121
}
118
122
 
119
 
void do_auto(const char *const *argv) {
 
123
int
 
124
do_auto(const char *const *argv)
 
125
{
120
126
  const char *partfile;
121
 
  struct partinfo *pi, *refi, *npi, **partlist, *otherthispart;
 
127
  struct partinfo *refi, **partlist, *otherthispart;
122
128
  struct partqueue *pq;
123
129
  unsigned int i;
124
 
  int j, ap;
125
 
  long nr;
 
130
  int j;
126
131
  FILE *part;
127
 
  void *buffer;
128
 
  char *p, *q;
129
132
 
130
133
  if (!opt_outputfile)
131
134
    badusage(_("--auto requires the use of the --output option"));
139
142
    if (!opt_npquiet)
140
143
      printf(_("File `%.250s' is not part of a multipart archive.\n"),partfile);
141
144
    m_output(stdout, _("<standard output>"));
142
 
    exit(1);
 
145
    return 1;
143
146
  }
144
147
  fclose(part);
145
148
  scandepot();
147
150
  for (i = 0; i < refi->maxpartn; i++)
148
151
    partlist[i] = NULL;
149
152
  for (pq= queue; pq; pq= pq->nextinqueue) {
150
 
    pi= &pq->info;
 
153
    struct partinfo *npi, *pi = &pq->info;
 
154
 
151
155
    if (!partmatches(pi,refi)) continue;
152
156
    npi= nfmalloc(sizeof(struct partinfo));
153
157
    mustgetpartinfo(pi->filename,npi);
155
159
  }
156
160
  /* If we already have a copy of this version we ignore it and prefer the
157
161
   * new one, but we still want to delete the one in the depot, so we
158
 
   * save its partinfo (with the filename) for later.  This also prevents
159
 
   * us from accidentally deleting the source file.
160
 
   */
 
162
   * save its partinfo (with the filename) for later. This also prevents
 
163
   * us from accidentally deleting the source file. */
161
164
  otherthispart= partlist[refi->thispartn-1];
162
165
  partlist[refi->thispartn-1]= refi;
163
166
  for (j=refi->maxpartn-1; j>=0 && partlist[j]; j--);
164
167
 
165
168
  if (j>=0) {
166
 
 
167
 
    part= fopen(partfile,"r");
168
 
    if (!part) ohshite(_("unable to reopen part file `%.250s'"),partfile);
169
 
    buffer= nfmalloc(refi->filesize);
170
 
    nr= fread(buffer,1,refi->filesize,part);
171
 
    if (nr != refi->filesize) rerreof(part,partfile);
172
 
    if (getc(part) != EOF) ohshit(_("part file `%.250s' has trailing garbage"),partfile);
173
 
    if (ferror(part)) rerr(partfile);
174
 
    fclose(part);
175
 
    p = nfmalloc(strlen(opt_depotdir) + 50);
176
 
    q = nfmalloc(strlen(opt_depotdir) + 200);
177
 
    sprintf(p, "%st.%lx", opt_depotdir, (long)getpid());
178
 
    sprintf(q, "%s%s.%lx.%x.%x", opt_depotdir, refi->md5sum,
179
 
            refi->maxpartlen,refi->thispartn,refi->maxpartn);
180
 
    part= fopen(p,"w");
181
 
    if (!part) ohshite(_("unable to open new depot file `%.250s'"),p);
182
 
    nr= fwrite(buffer,1,refi->filesize,part);
183
 
    if (nr != refi->filesize) werr(p);
184
 
    if (fflush(part))
185
 
      ohshite(_("unable to flush file '%s'"), p);
186
 
    if (fsync(fileno(part)))
 
169
    int fd_src, fd_dst;
 
170
    int ap;
 
171
    char *p, *q;
 
172
 
 
173
    m_asprintf(&p, "%st.%lx", opt_depotdir, (long)getpid());
 
174
    m_asprintf(&q, "%s%s.%jx.%x.%x", opt_depotdir, refi->md5sum,
 
175
               (intmax_t)refi->maxpartlen, refi->thispartn, refi->maxpartn);
 
176
 
 
177
    fd_src = open(partfile, O_RDONLY);
 
178
    if (fd_src < 0)
 
179
      ohshite(_("unable to reopen part file `%.250s'"), partfile);
 
180
    fd_dst = creat(p, 0644);
 
181
    if (fd_dst)
 
182
      ohshite(_("unable to open new depot file `%.250s'"), p);
 
183
 
 
184
    fd_fd_copy(fd_src, fd_dst, refi->filesize, _("extracting split part"));
 
185
 
 
186
    if (fsync(fd_dst))
187
187
      ohshite(_("unable to sync file '%s'"), p);
188
 
    if (fclose(part)) werr(p);
 
188
    if (close(fd_dst))
 
189
      ohshite(_("unable to close file '%s'"), p);
 
190
    close(fd_src);
 
191
 
189
192
    if (rename(p,q)) ohshite(_("unable to rename new depot file `%.250s' to `%.250s'"),p,q);
 
193
    free(q);
 
194
    free(p);
190
195
 
191
196
    printf(_("Part %d of package %s filed (still want "),refi->thispartn,refi->package);
192
197
    /* There are still some parts missing. */
211
216
  }
212
217
 
213
218
  m_output(stderr, _("<standard error>"));
 
219
 
 
220
  return 0;
214
221
}
215
222
 
216
 
void do_queue(const char *const *argv) {
217
 
  struct partqueue *pq, *qq;
218
 
  struct partinfo ti;
 
223
int
 
224
do_queue(const char *const *argv)
 
225
{
 
226
  struct partqueue *pq;
219
227
  const char *head;
220
228
  struct stat stab;
221
 
  unsigned long bytes;
222
 
  unsigned int i;
 
229
  off_t bytes;
223
230
 
224
231
  if (*argv)
225
232
    badusage(_("--%s takes no arguments"), cipaction->olong);
233
240
      ohshit(_("unable to stat `%.250s'"),pq->info.filename);
234
241
    if (S_ISREG(stab.st_mode)) {
235
242
      bytes= stab.st_size;
236
 
      printf(_(" %s (%lu bytes)\n"),pq->info.filename,bytes);
 
243
      printf(_(" %s (%jd bytes)\n"), pq->info.filename, (intmax_t)bytes);
237
244
    } else {
238
245
      printf(_(" %s (not a plain file)\n"),pq->info.filename);
239
246
    }
240
247
  }
241
248
  if (!*head) putchar('\n');
242
 
  
 
249
 
243
250
  head= N_("Packages not yet reassembled:\n");
244
251
  for (pq= queue; pq; pq= pq->nextinqueue) {
 
252
    struct partinfo ti;
 
253
    unsigned int i;
 
254
 
245
255
    if (!pq->info.md5sum) continue;
246
256
    mustgetpartinfo(pq->info.filename,&ti);
247
257
    fputs(gettext(head),stdout); head= "";
248
258
    printf(_(" Package %s: part(s) "), ti.package);
249
259
    bytes= 0;
250
260
    for (i=0; i<ti.maxpartn; i++) {
 
261
      struct partqueue *qq;
 
262
 
251
263
      for (qq= pq;
252
264
           qq && !(partmatches(&qq->info,&ti) && qq->info.thispartn == i+1);
253
265
           qq= qq->nextinqueue);
258
270
        if (!S_ISREG(stab.st_mode))
259
271
          ohshit(_("part file `%.250s' is not a plain file"),qq->info.filename);
260
272
        bytes+= stab.st_size;
261
 
        qq->info.md5sum= NULL; /* don't find this package again */
 
273
 
 
274
        /* Don't find this package again. */
 
275
        qq->info.md5sum = NULL;
262
276
      }
263
277
    }
264
 
    printf(_("(total %lu bytes)\n"),bytes);
 
278
    printf(_("(total %jd bytes)\n"), (intmax_t)bytes);
265
279
  }
266
280
  m_output(stdout, _("<standard output>"));
 
281
 
 
282
  return 0;
267
283
}
268
284
 
269
285
enum discardwhich { ds_junk, ds_package, ds_all };
290
306
  }
291
307
}
292
308
 
293
 
void do_discard(const char *const *argv) {
 
309
int
 
310
do_discard(const char *const *argv)
 
311
{
294
312
  const char *thisarg;
295
313
  struct partqueue *pq;
296
314
 
304
322
  } else {
305
323
    discardsome(ds_all,NULL);
306
324
  }
 
325
 
 
326
  return 0;
307
327
}