Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Fix when using rpm -ivh on installation #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

djnym
Copy link
Contributor

@djnym djnym commented May 3, 2017

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
Copy link
Contributor Author

djnym commented May 23, 2017

ping @maxlapshin are these pull requests acceptable?

@maxlapshin
Copy link
Contributor

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 =(

@djnym
Copy link
Contributor Author

djnym commented May 23, 2017

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
Copy link
Contributor Author

djnym commented May 24, 2017

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
Copy link
Contributor Author

djnym commented Jun 8, 2017

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants