Subject: Re: RPM/Handling ARM /etc

From: Matthew Selby <[email-masked]>
Date: Mon, 16 Nov 1998 12:57:53 +0000 (GMT)

A while ago there were some posts about getting rpm to work. I have found 
that rpm-2.3 which came with the distribution (approx. September, with kernel
2.0.35) works, but doesn't understand recent .rpm files. One can compile 
rpm-2.5 from source, but it gives a broken binary. 

The problems in the source code to rpm-2.5 surface because the default 
armlinux version of gcc (for RPC) pads out the overall size of a structure 
to a multiple of 4 bytes. This touches on a wider discussion about structure
alignment, but in this particular case, it seems that only a small patch
is needed. The changes below (output of `diff -u cpio.c.orig cpio.c` from 
rpm-2.5/lib, extracted from rpm-2.5.tar) seem to work for extracting rpms
(untested on creation of rpms). Does this look ok?

Matthew

--- cpio.c.orig	Mon Nov 16 12:08:56 1998
+++ cpio.c	Mon Nov 16 12:12:03 1998
@@ -65,6 +65,8 @@
     char namesize[8];
     char checksum[8];			/* ignored !! */
 };
+#define FAKESIZEOF_PHYSHEADER 110
+/* 110 = 6 + 13*8 */
 
 struct cpioHeader {
     ino_t inode;
@@ -152,7 +154,7 @@
     char * end;
     int major, minor;
 
-    if (ourread(fd, &physHeader, sizeof(physHeader)) != sizeof(physHeader)) 
+    if (ourread(fd, &physHeader, FAKESIZEOF_PHYSHEADER) != FAKESIZEOF_PHYSHEADER) 
 	return CPIO_READ_FAILED;
 
     if (strncmp(CPIO_CRC_MAGIC, physHeader.magic, strlen(CPIO_CRC_MAGIC)) &&
@@ -692,11 +694,11 @@
     num = strlen(map->archivePath) + 1; SET_NUM_FIELD(hdr.namesize, num, buf);
     memcpy(hdr.checksum, "00000000", 8);
 
-    if ((rc = safewrite(fd, &hdr, sizeof(hdr))))
+    if ((rc = safewrite(fd, &hdr, FAKESIZEOF_PHYSHEADER)))
 	return rc;
     if ((rc = safewrite(fd, map->archivePath, num)))
 	return rc;
-    size = sizeof(hdr) + num;
+    size = FAKESIZEOF_PHYSHEADER + num;
     if ((rc = padoutfd(fd, &size, 4)))
 	return rc;
 	
@@ -875,15 +877,15 @@
 	totalsize += size;
     }
 
-    memset(&hdr, '0', sizeof(hdr));
+    memset(&hdr, '0', FAKESIZEOF_PHYSHEADER);
     memcpy(hdr.magic, CPIO_NEWC_MAGIC, sizeof(hdr.magic));
     memcpy(hdr.nlink, "00000001", 8);
     memcpy(hdr.namesize, "0000000b", 8);
-    if ((rc = safewrite(fd, &hdr, sizeof(hdr))))
+    if ((rc = safewrite(fd, &hdr, FAKESIZEOF_PHYSHEADER)))
 	return rc;
     if ((rc = safewrite(fd, "TRAILER!!!", 11)))
 	return rc;
-    totalsize += sizeof(hdr) + 11;
+    totalsize += FAKESIZEOF_PHYSHEADER + 11;
 
     /* GNU cpio pads to 512 bytes here, but we don't. I'm not sure if
        it matters or not */

-- 
Eidos Technologies Ltd                     Matthew Selby
[email-masked]                            0181 636 3413

unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Stefan Hanske <[email-masked]>
Date: Wed, 18 Nov 1998 19:09:05 +0100 (CET)

> (untested on creation of rpms). Does this look ok?

Yes, I've patched this version similar, but used sizeof(...)-2. But this
is not all that's to be done. rpm needs to know about the arm architecture
or otherwise it'll complain about some wrong architecture every time you
try to install a binary package.

----------------------------------------------------------
|mailto: Stefan Hanske ([email-masked] |
|WWW : http://www.rzuser.uni-heidelberg.de/~shanske      |
|phone: I'm not silly                                    |
|--------------------------------------------------------|
| And don't forget to remember what you remembered not   |
| to forget to remember...				 |
----------------------------------------------------------