Only insert 64bit filesizes on build if required
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 26 Jun 2008 13:10:49 +0000 (16:10 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 26 Jun 2008 13:10:49 +0000 (16:10 +0300)
- older rpm's get pretty upset on encounter with 64bit integers, avoid
  unnecessary breakage as very few packages actually need large file sizes
- Add per-filelist flag for large files, enabled from addFile() as we
  check sizes. It's basically a no-op for now as we error out if any
  single file exceeds cpio per file limit.

build/files.c

index 5b439b4..7cd016e 100644 (file)
@@ -122,6 +122,7 @@ typedef struct FileList_s {
     FileListRec fileList;
     int fileListRecsAlloced;
     int fileListRecsUsed;
+    int largeFiles;
 } * FileList;
 
 /**
@@ -1072,18 +1073,24 @@ static void genCpioListAndHeader(FileList fl,
        headerPutString(h, RPMTAG_FILEGROUPNAME, flp->gname);
 
        /*
-        * For items whose size varies between systems, always explicitly 
-        * cast to the header type before inserting.
-        * TODO: check and warn if header type overflows for each case.
+        * Only use 64bit filesizes if file sizes require it. 
+        * This is basically no-op for now as we error out in addFile() if 
+        * any individual file size exceeds the cpio limit.
         */
-       {   rpm_off_t rsize32 = (rpm_off_t)flp->fl_size;
-           headerPutUint32(h, RPMTAG_FILESIZES, &rsize32, 1);
-       }
-
-       {   rpm_loff_t rsize64 = (rpm_loff_t)flp->fl_size;
+       if (fl->largeFiles) {
+           rpm_loff_t rsize64 = (rpm_loff_t)flp->fl_size;
            headerPutUint64(h, RPMTAG_LONGFILESIZES, &rsize64, 1);
+           /* XXX TODO: add rpmlib() dependency for large files */
+       } else {
+           rpm_off_t rsize32 = (rpm_off_t)flp->fl_size;
+           headerPutUint32(h, RPMTAG_FILESIZES, &rsize32, 1);
        }
        
+       /*
+        * For items whose size varies between systems, always explicitly 
+        * cast to the header type before inserting.
+        * TODO: check and warn if header type overflows for each case.
+        */
        {   rpm_time_t rtime = (rpm_time_t) flp->fl_mtime;
            headerPutUint32(h, RPMTAG_FILEMTIMES, &rtime, 1);
        }
@@ -1411,7 +1418,12 @@ static rpmRC addFile(FileList fl, const char * diskPath,
        flp->uname = fileUname;
        flp->gname = fileGname;
 
+       /*
+        * XXX Simple and stupid check for now, this needs to be per-payload
+        * format check once we have other payloads than good 'ole cpio.
+        */
        if ((rpm_loff_t) flp->fl_size >= CPIO_FILESIZE_MAX) {
+           fl->largeFiles = 1;
            rpmlog(RPMLOG_ERR, _("File %s too large for payload\n"),
                   flp->diskPath);
            return RPMRC_FAIL;
@@ -1757,6 +1769,8 @@ static rpmRC processPackageFiles(rpmSpec spec, Package pkg,
     fl.currentSpecdFlags = 0;
     fl.defSpecdFlags = 0;
 
+    fl.largeFiles = 0;
+
     fl.docDirs = NULL;
     {  char *docs = rpmGetPath("%{?__docdir_path}", NULL);
        argvSplit(&fl.docDirs, docs, ":");