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

« back to all changes in this revision

Viewing changes to dpkg-split/info.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:
23
23
 
24
24
#include <sys/stat.h>
25
25
 
26
 
#include <assert.h>
27
26
#include <limits.h>
28
27
#include <ctype.h>
29
28
#include <string.h>
30
29
#include <unistd.h>
31
30
#include <ar.h>
 
31
#include <inttypes.h>
 
32
#include <stdint.h>
32
33
#include <stdlib.h>
33
34
#include <stdio.h>
34
35
 
40
41
 
41
42
#include "dpkg-split.h"
42
43
 
43
 
static unsigned long unsignedlong(const char *value, const char *fn, const char *what) {
44
 
  unsigned long r;
 
44
static intmax_t
 
45
parse_intmax(const char *value, const char *fn, const char *what)
 
46
{
 
47
  intmax_t r;
45
48
  char *endp;
46
49
 
47
 
  r= strtoul(value,&endp,10);
 
50
  r = strtoimax(value, &endp, 10);
48
51
  if (value == endp || *endp)
49
52
    ohshit(_("file `%.250s' is corrupt - bad digit (code %d) in %s"),fn,*endp,what);
50
53
  return r;
51
54
}
52
55
 
53
 
static unsigned long parseheaderlength(const char *inh, size_t len,
54
 
                                       const char *fn, const char *what) {
55
 
  char lintbuf[15];
56
 
 
57
 
  if (memchr(inh,0,len))
58
 
    ohshit(_("file `%.250s' is corrupt - %.250s length contains nulls"),fn,what);
59
 
  assert(sizeof(lintbuf) > len);
60
 
  memcpy(lintbuf,inh,len);
61
 
  lintbuf[len]= ' ';
62
 
  *strchr(lintbuf, ' ') = '\0';
63
 
  return unsignedlong(lintbuf,fn,what);
64
 
}
65
 
 
66
56
static char *nextline(char **ripp, const char *fn, const char *what) {
67
57
  char *newline, *rip;
68
58
 
77
67
  return rip;
78
68
}
79
69
 
 
70
/**
 
71
 * Read a deb-split part archive.
 
72
 *
 
73
 * @return Part info (nfmalloc'd) if was an archive part and we read it,
 
74
 *         NULL if it wasn't.
 
75
 */
80
76
struct partinfo *read_info(FILE *partfile, const char *fn, struct partinfo *ir) {
81
 
  /* returns info (nfmalloc'd) if was an archive part and we read it, 0 if it wasn't */
82
77
  static char *readinfobuf= NULL;
83
78
  static size_t readinfobuflen= 0;
84
79
 
85
80
  size_t thisilen;
86
 
  unsigned int templong;
87
 
  char magicbuf[strlen(DPKG_AR_MAGIC)], *rip, *partnums, *slash;
 
81
  intmax_t templong;
 
82
  char magicbuf[sizeof(DPKG_AR_MAGIC) - 1], *rip, *partnums, *slash;
88
83
  struct ar_hdr arh;
89
84
  int c;
90
85
  struct stat stab;
91
 
  
 
86
 
92
87
  if (fread(magicbuf, 1, sizeof(magicbuf), partfile) != sizeof(magicbuf)) {
93
 
    if (ferror(partfile)) rerr(fn); else return NULL;
 
88
    if (ferror(partfile))
 
89
      ohshite(_("error reading %.250s"), fn);
 
90
    else
 
91
      return NULL;
94
92
  }
95
93
  if (memcmp(magicbuf, DPKG_AR_MAGIC, sizeof(magicbuf)))
96
94
    return NULL;
97
 
  
 
95
 
98
96
  if (fread(&arh,1,sizeof(arh),partfile) != sizeof(arh)) rerreof(partfile,fn);
99
97
 
100
98
  dpkg_ar_normalize_name(&arh);
103
101
    return NULL;
104
102
  if (memcmp(arh.ar_fmag,ARFMAG,sizeof(arh.ar_fmag)))
105
103
    ohshit(_("file `%.250s' is corrupt - bad magic at end of first header"),fn);
106
 
  thisilen = parseheaderlength(arh.ar_size, sizeof(arh.ar_size), fn,
107
 
                               _("info length"));
 
104
  thisilen = dpkg_ar_member_get_size(fn, &arh);
108
105
  if (thisilen >= readinfobuflen) {
109
106
    readinfobuflen= thisilen+1;
110
107
    readinfobuf= m_realloc(readinfobuf,readinfobuflen);
134
131
      strspn(ir->md5sum, "0123456789abcdef") != MD5HASHLEN)
135
132
    ohshit(_("file `%.250s' is corrupt - bad MD5 checksum `%.250s'"),fn,ir->md5sum);
136
133
 
137
 
  ir->orglength = unsignedlong(nextline(&rip, fn, _("total length")), fn,
138
 
                               _("total length"));
139
 
  ir->maxpartlen = unsignedlong(nextline(&rip, fn, _("part offset")), fn,
140
 
                                _("part offset"));
141
 
  
142
 
  partnums = nextline(&rip, fn, _("part numbers"));
 
134
  ir->orglength = parse_intmax(nextline(&rip, fn, _("archive total size")),
 
135
                               fn, _("archive total size"));
 
136
  ir->maxpartlen = parse_intmax(nextline(&rip, fn, _("archive part offset")),
 
137
                                fn, _("archive part offset"));
 
138
 
 
139
  partnums = nextline(&rip, fn, _("archive part numbers"));
143
140
  slash= strchr(partnums,'/');
144
 
  if (!slash) ohshit(_("file `%.250s' is corrupt - no slash between part numbers"),fn);
 
141
  if (!slash)
 
142
    ohshit(_("file '%.250s' is corrupt - no slash between archive part numbers"), fn);
145
143
  *slash++ = '\0';
146
144
 
147
 
  templong = unsignedlong(slash, fn, _("number of parts"));
 
145
  templong = parse_intmax(slash, fn, _("number of archive parts"));
148
146
  if (templong <= 0 || templong > INT_MAX)
149
 
    ohshit(_("file '%.250s' is corrupt - bad number of parts"), fn);
 
147
    ohshit(_("file '%.250s' is corrupt - bad number of archive parts"), fn);
150
148
  ir->maxpartn= templong;
151
 
  templong = unsignedlong(partnums, fn, _("parts number"));
 
149
  templong = parse_intmax(partnums, fn, _("archive parts number"));
152
150
  if (templong <= 0 || templong > ir->maxpartn)
153
 
    ohshit(_("file `%.250s' is corrupt - bad part number"),fn);
 
151
    ohshit(_("file '%.250s' is corrupt - bad archive part number"),fn);
154
152
  ir->thispartn= templong;
155
153
 
156
154
  if (fread(&arh,1,sizeof(arh),partfile) != sizeof(arh)) rerreof(partfile,fn);
162
160
  if (strncmp(arh.ar_name,"data",4))
163
161
    ohshit(_("file `%.250s' is corrupt - second member is not data member"),fn);
164
162
 
165
 
  ir->thispartlen = parseheaderlength(arh.ar_size, sizeof(arh.ar_size), fn,
166
 
                                      _("data length"));
 
163
  ir->thispartlen = dpkg_ar_member_get_size(fn, &arh);
167
164
  ir->thispartoffset= (ir->thispartn-1)*ir->maxpartlen;
168
165
 
169
166
  if (ir->maxpartn != (ir->orglength+ir->maxpartlen-1)/ir->maxpartlen)
180
177
  if (fstat(fileno(partfile),&stab)) ohshite(_("unable to fstat part file `%.250s'"),fn);
181
178
  if (S_ISREG(stab.st_mode)) {
182
179
    /* Don't do this check if it's coming from a pipe or something.  It's
183
 
     * only an extra sanity check anyway.
184
 
     */
 
180
     * only an extra sanity check anyway. */
185
181
    if (stab.st_size < ir->filesize)
186
182
      ohshit(_("file `%.250s' is corrupt - too short"),fn);
187
183
  }
188
184
 
189
185
  ir->headerlen = strlen(DPKG_AR_MAGIC) +
190
186
                  sizeof(arh) + thisilen + (thisilen & 1) + sizeof(arh);
191
 
    
 
187
 
192
188
  return ir;
193
 
}  
 
189
}
194
190
 
195
191
void mustgetpartinfo(const char *filename, struct partinfo *ri) {
196
192
  FILE *part;
197
 
  
 
193
 
198
194
  part= fopen(filename,"r");
199
195
  if (!part) ohshite(_("cannot open archive part file `%.250s'"),filename);
200
196
  if (!read_info(part,filename,ri))
208
204
         "    Part of package:                %s\n"
209
205
         "        ... version:                %s\n"
210
206
         "        ... MD5 checksum:           %s\n"
211
 
         "        ... length:                 %lu bytes\n"
212
 
         "        ... split every:            %lu bytes\n"
 
207
         "        ... length:                 %jd bytes\n"
 
208
         "        ... split every:            %jd bytes\n"
213
209
         "    Part number:                    %d/%d\n"
214
 
         "    Part length:                    %zi bytes\n"
215
 
         "    Part offset:                    %lu bytes\n"
216
 
         "    Part file size (used portion):  %lu bytes\n\n"),
 
210
         "    Part length:                    %jd bytes\n"
 
211
         "    Part offset:                    %jd bytes\n"
 
212
         "    Part file size (used portion):  %jd bytes\n\n"),
217
213
         pi->filename,
218
214
         pi->fmtversion,
219
215
         pi->package,
220
216
         pi->version,
221
217
         pi->md5sum,
222
 
         pi->orglength,
223
 
         pi->maxpartlen,
 
218
         (intmax_t)pi->orglength,
 
219
         (intmax_t)pi->maxpartlen,
224
220
         pi->thispartn,
225
221
         pi->maxpartn,
226
 
         pi->thispartlen,
227
 
         pi->thispartoffset,
228
 
         (unsigned long)pi->filesize);
 
222
         (intmax_t)pi->thispartlen,
 
223
         (intmax_t)pi->thispartoffset,
 
224
         (intmax_t)pi->filesize);
229
225
}
230
226
 
231
 
void do_info(const char *const *argv) {
 
227
int
 
228
do_info(const char *const *argv)
 
229
{
232
230
  const char *thisarg;
233
231
  struct partinfo *pi, ps;
234
232
  FILE *part;
236
234
  if (!*argv)
237
235
    badusage(_("--%s requires one or more part file arguments"),
238
236
             cipaction->olong);
239
 
  
 
237
 
240
238
  while ((thisarg= *argv++)) {
241
239
    part= fopen(thisarg,"r");
242
240
    if (!part) ohshite(_("cannot open archive part file `%.250s'"),thisarg);
249
247
    }
250
248
    m_output(stdout, _("<standard output>"));
251
249
  }
 
250
 
 
251
  return 0;
252
252
}