For 4.1.4: Changes required to use zip instead of 7z (backport #14301)
#14303
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
erlang.mkdocs state that you can drop-inzipon systems that don't have, or can't install, thep7zippackage. Unfortunately, this doesn't quite work with the RabbitMQ build due to a difference in howzipadds a directory passed to it as an argument vs how7zdoes.When
7zis passed a directory as an argument, it uses the basename of the directory when adding it to the archive. This is important during the CLI tools build, because several Elixir applications are added to the final archive. Here is the command and relevant output lines showing this behavior:Notice that absolute paths to Elixir app dirs are passed to
7z, yet the basename of those paths are added to the archive:Here is what is archived in
.erlang.mk/escript.zip:zip file contents
$ unzip -t .erlang.mk/escript.zip Archive: .erlang.mk/escript.zip testing: csv/ebin/Elixir.CSV.Decoding.Decoder.beam OK testing: csv/ebin/Elixir.CSV.Decoding.Parser.beam OK testing: csv/ebin/Elixir.CSV.Defaults.beam OK testing: csv/ebin/Elixir.CSV.Encode.Any.beam OK testing: csv/ebin/Elixir.CSV.Encode.BitString.beam OK testing: csv/ebin/Elixir.CSV.Encode.beam OK testing: csv/ebin/Elixir.CSV.Encoding.Encoder.beam OK testing: csv/ebin/Elixir.CSV.EscapeSequenceError.beam OK testing: csv/ebin/Elixir.CSV.RowLengthError.beam OK testing: csv/ebin/Elixir.CSV.StrayEscapeCharacterError.beam OK testing: csv/ebin/Elixir.CSV.beam OK testing: csv/ebin/csv.app OK testing: csv/ebin/dep_built OK testing: eex/ OK testing: eex/ebin/ OK testing: eex/ebin/Elixir.EEx.Compiler.beam OK testing: eex/ebin/Elixir.EEx.Engine.beam OK testing: eex/ebin/Elixir.EEx.SmartEngine.beam OK testing: eex/ebin/Elixir.EEx.SyntaxError.beam OK testing: eex/ebin/Elixir.EEx.beam OK testing: eex/ebin/eex.app OK testing: eex/lib/ OK testing: eex/lib/eex/ OK testing: eex/lib/eex/compiler.ex OK testing: eex/lib/eex/engine.ex OK testing: eex/lib/eex/smart_engine.ex OK testing: eex/lib/eex.ex OK testing: elixir/ OK testing: elixir/ebin/ OK testing: elixir/ebin/Elixir.Access.beam OK testing: elixir/ebin/Elixir.Agent.Server.beam OK testing: elixir/ebin/Elixir.Agent.beam OKWhen
zipis passed a directory as an argument, the full path to that directory is re-created within the archive, which breaks the expectation ofescriptand the BEAM when it runs. Here is the command and relevant output lines showing this behavior. Note that you must use the-rargument orzipwon't descend into directories passed to it.verbose output when zip is non-recursive
From the
/tmp/make-zip-bad.txtoutput file:From the
.erlang.mk/escript.ziparchive itself:$ unzip -t .erlang.mk/escript.zip Archive: .erlang.mk/escript.zip testing: rabbitmq_cli/ebin/Elixir.CSV.Encode.List.beam OK testing: rabbitmq_cli/ebin/Elixir.CSV.Encode.Map.beam OK testing: rabbitmq_cli/ebin/Elixir.CSV.Encode.PID.beam OK testing: rabbitmq_cli/ebin/Elixir.CSV.Encode.Tuple.beam OK testing: rabbitmq_cli/ebin/Elixir.RabbitCommon.Records.beam OK ... ... ... testing: stdout_formatter/ebin/stdout_formatter_table.beam OK testing: stdout_formatter/ebin/stdout_formatter_utils.beam OK testing: home/lrbakken/opt/elixir/1.18.4-otp-27/lib/eex/ OK testing: home/lrbakken/opt/elixir/1.18.4-otp-27/lib/eex/ebin/ OK testing: home/lrbakken/opt/elixir/1.18.4-otp-27/lib/eex/ebin/Elixir.EEx.SyntaxError.beam OK ... ... ...With this patch, everything works correctly. Here's the command I used to test this patch and capture output. Since we're directly globbing the
ebindirs for Elixir libraries, as well as other Elixir deps, the-rargument is no longer necessary to use withzip:Relevant lines from the
make-zip-with-patch.txtfile. Notice that the existing code inerlang.mkto add Elixir deps does add them in anAPP/ebin/*format, which works with both7zandzip. This is why I structured this patch in the same manner:Finally, here's the full output of
unzip -ton.erlang.mk/escript.zip, using this patch:escript.zip-content.txt
This is an automatic backport of pull request #14301 done by [Mergify](https://mergify.com).