Procházet zdrojové kódy

dpkg-split: Generate filenames following current conventions on --join

Keep the architecture in the debian-split member of the part file so
that we can reuse it when putting back together the joined binary
package. Use underscores to separate each filename part.
Guillem Jover před 15 roky
rodič
revize
e71ae2eac5

+ 3 - 0
debian/changelog

@@ -26,6 +26,9 @@ dpkg (1.16.1) UNRELEASED; urgency=low
   * Switch to debhelper compatibility level 7.
     - Use dh_prep instead of deprecated “dh_clean -k”.
   * Bump Standards-Version to 3.9.2 (no changes needed).
+  * Generate filenames following current conventions on “dpkg-split --join”,
+    by including the architecture in the debian-split member of a split
+    package and using underscores to separate filename parts.
 
   [ Updated man page translations ]
   * German (Helge Kreutzmann).

+ 1 - 0
dpkg-split/dpkg-split.h

@@ -33,6 +33,7 @@ struct partinfo {
   const char *fmtversion;
   const char *package;
   const char *version;
+  const char *arch;
   const char *md5sum;
   off_t orglength;
   unsigned int thispartn, maxpartn;

+ 9 - 0
dpkg-split/info.c

@@ -151,6 +151,13 @@ struct partinfo *read_info(FILE *partfile, const char *fn, struct partinfo *ir)
     ohshit(_("file '%.250s' is corrupt - bad archive part number"),fn);
   ir->thispartn= templong;
 
+  /* If the package was created with dpkg 1.16.1 or later it will include
+   * the architecture. */
+  if (*rip != '\0')
+    ir->arch = nfstrsave(nextline(&rip, fn, _("package architecture")));
+  else
+    ir->arch = NULL;
+
   if (fread(&arh,1,sizeof(arh),partfile) != sizeof(arh)) rerreof(partfile,fn);
 
   dpkg_ar_normalize_name(&arh);
@@ -203,6 +210,7 @@ void print_info(const struct partinfo *pi) {
          "    Part format version:            %s\n"
          "    Part of package:                %s\n"
          "        ... version:                %s\n"
+         "        ... architecture:           %s\n"
          "        ... MD5 checksum:           %s\n"
          "        ... length:                 %jd bytes\n"
          "        ... split every:            %jd bytes\n"
@@ -214,6 +222,7 @@ void print_info(const struct partinfo *pi) {
          pi->fmtversion,
          pi->package,
          pi->version,
+         pi->arch ? pi->arch : C_("architecture", "<unknown>"),
          pi->md5sum,
          (intmax_t)pi->orglength,
          (intmax_t)pi->maxpartlen,

+ 3 - 1
dpkg-split/join.c

@@ -132,8 +132,10 @@ do_join(const char *const *argv)
 
     p= nfmalloc(strlen(refi->package)+1+strlen(refi->version)+sizeof(DEBEXT));
     strcpy(p,refi->package);
-    strcat(p,"-");
+    strcat(p, "_");
     strcat(p,refi->version);
+    strcat(p, "_");
+    strcat(p, refi->arch ? refi->arch : "unknown");
     strcat(p,DEBEXT);
     opt_outputfile = p;
   }

+ 2 - 1
dpkg-split/main.c

@@ -82,7 +82,8 @@ usage(const struct cmdinfo *cip, const char *value)
 "Options:\n"
 "  --depotdir <directory>           Use <directory> instead of %s/%s.\n"
 "  -S|--partsize <size>             In KiB, for -s (default is 450).\n"
-"  -o|--output <file>               For -j (default is <package>-<version>.deb).\n"
+"  -o|--output <file>               Filename, for -j (default is\n"
+"                                     <package>_<version>_<arch>.deb).\n"
 "  -Q|--npquiet                     Be quiet when -a is not a part.\n"
 "  --msdos                          Generate 8.3 filenames.\n"
 "\n"

+ 1 - 0
dpkg-split/queue.c

@@ -95,6 +95,7 @@ void scandepot(void) {
     if (de->d_name[0] == '.') continue;
     pq= nfmalloc(sizeof(struct partqueue));
     pq->info.fmtversion= pq->info.package= pq->info.version= NULL;
+    pq->info.arch = NULL;
     pq->info.orglength= pq->info.thispartoffset= pq->info.thispartlen= 0;
     pq->info.headerlen= 0;
     p = nfmalloc(strlen(opt_depotdir) + strlen(de->d_name) + 1);

+ 5 - 3
dpkg-split/split.c

@@ -116,7 +116,7 @@ mksplit(const char *file_src, const char *prefix, off_t maxpartsize,
 	int fd_src;
 	struct stat st;
 	char hash[MD5HASHLEN + 1];
-	char *package, *version;
+	char *package, *version, *arch;
 	int nparts, curpart;
 	off_t partsize;
 	off_t cur_partsize, last_partsize;
@@ -139,6 +139,7 @@ mksplit(const char *file_src, const char *prefix, off_t maxpartsize,
 	/* FIXME: Use libdpkg-deb. */
 	package = deb_field(file_src, "Package");
 	version = deb_field(file_src, "Version");
+	arch = deb_field(file_src, "Architecture");
 
 	partsize = maxpartsize - HEADERALLOWANCE;
 	last_partsize = st.st_size % partsize;
@@ -206,10 +207,11 @@ mksplit(const char *file_src, const char *prefix, off_t maxpartsize,
 		dpkg_ar_put_magic(file_dst.buf, fd_dst);
 
 		/* Write the debian-split part. */
-		varbuf_printf(&partmagic, "%s\n%s\n%s\n%s\n%jd\n%jd\n%d/%d\n",
+		varbuf_printf(&partmagic,
+		              "%s\n%s\n%s\n%s\n%jd\n%jd\n%d/%d\n%s\n",
 		              SPLITVERSION, package, version, hash,
 		              (intmax_t)st.st_size, (intmax_t)partsize,
-		              curpart, nparts);
+		              curpart, nparts, arch);
 		dpkg_ar_member_put_mem(file_dst.buf, fd_dst, PARTMAGIC,
 		                       partmagic.buf, partmagic.used);
 		varbuf_reset(&partmagic);

+ 3 - 1
man/deb-split.5

@@ -11,7 +11,7 @@ The file is an \fBar\fP archive with a magic value of \fB!<arch>\fP.
 The file names might contain a trailing slash (since dpkg 1.15.6).
 .PP
 The first member is named \fBdebian\-split\fP and contains a series
-of lines, separated by newlines. Currently seven lines are present:
+of lines, separated by newlines. Currently eight lines are present:
 .IP \(bu 4
 The format version number, \fB2.1\fP at the time this manual page was
 written.
@@ -28,6 +28,8 @@ The maximum part size.
 .IP \(bu
 The current part number, followed by a slash and the total amount of
 parts (as in \(oq1/10\(cq).
+.IP \(bu
+The package architecture (since dpkg 1.16.1).
 .PP
 Programs which read multi-part archives should be prepared for additional
 lines to be present, and should ignore these if this is the case.

+ 2 - 10
man/dpkg-split.1

@@ -1,5 +1,5 @@
 .\" Authors: Ian Jackson
-.TH dpkg\-split 1 "2009-06-26" "Debian Project" "dpkg utilities"
+.TH dpkg\-split 1 "2011-04-15" "Debian Project" "dpkg utilities"
 .SH NAME
 dpkg\-split \- Debian package archive split/join tool
 .
@@ -66,7 +66,7 @@ been generated by the same invocation of
 The parts' filenames are not significant for the reassembly process.
 
 By default the output file is called
-.IB package \- version .deb\fR.
+.IB package _ version _ arch .deb\fR.
 
 .TP
 .BR \-I ", " \-\-info " \fIpart\fP..."
@@ -195,19 +195,11 @@ call failure, a file that looked like a package part file but was
 corrupted, a usage error or some other problem.
 .
 .SH BUGS
-.B dpkg\-split
-uses some rather out-of-date conventions for the the filenames of
-Debian packages.
-
 Full details of the packages in the queue are impossible to get
 without digging into the queue directory yourself.
 
 There is no easy way to test whether a file that may be a binary
 package part is one.
-
-The architecture is not represented in the part files' header, only in
-the control information of the contained binary package file, and it
-is not present in the filenames generated.
 .
 .SH FILES
 .TP