epm icon indicating copy to clipboard operation
epm copied to clipboard

Fix when using rpm -ivh on installation

Open djnym opened this issue 8 years ago • 5 comments

When I install rpm's I'm in the habit of using 'rpm -ivh file.rpm' but noticed that with rpms created with this tool, I got unexpected output. Here's an example

> mkdir foo && cd foo && mkdir tmp && mkdir -p etc/init.d && echo "stuff" > tmp/foo && echo '#!/bin/sh' > etc/init.d/foo && echo 'echo "hello world"' >> etc/init.d/foo
> ../epm.erl -f -t rpm -n test -v 1.1.0 -a x86_64 tmp etc
> > sudo rpm -ivh test-1.1.0-1.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:test-1.1.0-1                     #################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################%

After looking at the rpm source code and seeing it was size related I looked into how internal sizes were calculated and figured out they were not being done correctly. I found a good description here http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/pkgformat.html which had

RPMTAG_SIZE This tag specifies the sum of the sizes of the regular files in the archive.

RPMTAG_ARCHIVESIZE This tag specifies the uncompressed size of the Payload archive, including the cpio headers.

Once I switched to these for the sizes, I got the expected output

> sudo rpm -ivh test-1.1.0-1.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:test-1.1.0-1                     ################################# [100%]

I figure others might have similar issues.

djnym avatar May 03 '17 22:05 djnym

ping @maxlapshin are these pull requests acceptable?

djnym avatar May 23 '17 16:05 djnym

Hi.

All these requests must be very carefully checked. We are fighting with this rpm, because some ways of packing work on centos, other are working on suse and all this is not easy =(

maxlapshin avatar May 23 '17 18:05 maxlapshin

Well, this particular change should work on either if they use the same rpm base. It's an odd one because it only happens if you use -ivh (or -ih, or -Uvh, or -Uh), because that's the only place as far as I can tell where the size of the extracted rpm is checked. I can try to get a suse VM going to test if these work or not. Is there a particular version of suse you normally use?

djnym avatar May 23 '17 23:05 djnym

Okay, I setup a SUSE box,

> cat /etc/os-release
NAME="openSUSE Leap"
VERSION="42.2"
ID=opensuse
ID_LIKE="suse"
VERSION_ID="42.2"
PRETTY_NAME="openSUSE Leap 42.2"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:42.2"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"

and reran the above test

> mkdir foo && cd foo && mkdir tmp && mkdir -p etc/init.d &&
 echo "stuff" > tmp/foo && echo '#!/bin/sh' > etc/init.d/foo && echo 'echo "hello
world"' >> etc/init.d/foo
> ../epm.erl -f -t rpm -n test -v 1.1.0 -a x86_64 tmp etc
> sudo rpm -ivh test-1.1.0-1.x86_64.rpm
root's password:
Preparing...                          ################################# [100%]
Updating / installing...
   1:test-1.1.0-1                     #################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################

Then using this branch

> mkdir foo && cd foo && mkdir tmp && mkdir -p etc/init.d && echo "stuff" > tmp/foo && echo '#!/bin/sh' > etc/init.d/foo && echo 'echo "hello world"' >> etc/init.d/foo
> ../epm.erl -f -t rpm -n test -v 1.1.0 -a x86_64 tmp etc
> sudo rpm -ivh test-1.1.0-1.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:test-1.1.0-1                     ################################# [100%]

djnym avatar May 24 '17 21:05 djnym

@maxlapshin just a quick ping on these as I did test them all on SUSE and was thinking of adding a few more things, so wondering if you would consider merging, otherwise I'll probably merge on my fork and make a few more changes on top of these.

djnym avatar Jun 08 '17 23:06 djnym