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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions epm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@ rpm(#fpm{paths = Dirs0, output = OutPath, force = Force, name = Name0, version =

% Need to sort files because mapFind will make bsearch to find them
Files = rpm_load_file_list(Dirs),
CPIO = zlib:gzip(cpio(Files)),
FileSizes = file_sizes (Files),
UncompressedCPIO = cpio(Files),
UncompressedCPIOSize = iolist_size (UncompressedCPIO),
CPIO = zlib:gzip(UncompressedCPIO),
CPIOSize = iolist_size(CPIO),

Info1 = [
{summary, FPM#fpm.description},
Expand All @@ -486,7 +490,9 @@ rpm(#fpm{paths = Dirs0, output = OutPath, force = Force, name = Name0, version =
{requirename, [X || {X, _, _} <- Deps]},
{requireversion, [X || {_, _, X} <- Deps]},
{requireflags, [X || {_, X, _} <- Deps]},
{size, iolist_size(CPIO)}],
{size, FileSizes},
{archivesize, UncompressedCPIOSize}
],

#fpm{post_install=PostInst,pre_uninstall=PreRm,post_uninstall=PostRm}=FPM,
#fpm{epoch = Epoch}=FPM,
Expand Down Expand Up @@ -529,7 +535,7 @@ rpm(#fpm{paths = Dirs0, output = OutPath, force = Force, name = Name0, version =


Signature = [{sha1_header,hex(crypto:hash(sha, [Header]))}] ++ GPGSign++
[{signature_size,iolist_size(Header) + iolist_size(CPIO)},
[{signature_size,iolist_size(Header) + CPIOSize},
{md5_header,{bin,MD5}}],


Expand Down Expand Up @@ -591,6 +597,18 @@ rpm_pad(Data, N) ->
Pad.


file_sizes (Files) ->
lists:foldl (fun(Path,A) ->
{ok, #file_info{type = T, size = S}} =
file:read_file_info(Path),
case T of
regular -> A + S;
_ -> A
end
end,
0,
Files).

rpm_load_file_list(Dirs) ->
Files1 = lists:usort(lists:flatmap(fun(Dir) -> rpm_list(Dir) end, Dirs)),
Files2 = Files1 -- [<<"etc">>, <<"etc/init.d">>, <<"opt">>],
Expand Down