-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add :tar
option for releases to create a tarball
#9290
Conversation
17c0141
to
dffd9ac
Compare
lib/mix/lib/mix/tasks/release.ex
Outdated
out_path = Path.join(release.path, tar_filename) | ||
|
||
dirs = | ||
["bin", "lib", Path.join("releases", release.version), "erts-#{release.erts_version}"] ++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to use systools:make_tar
or duplicate its functionality because simply including lib
in the tarball will include the libs used by other versions of the release that may have been built.
i wouldn't worry about it for now, we can always add it later. @Gazler can you look into using sys_tools? If that works, we don't need the |
You probably will need to copy the |
Does it copy only the relname.boot file though? Because we have more than one... then it may be best to not use sys_tools and add a clean up task. |
dffd9ac
to
20f206c
Compare
Can we walk the runtime dependencies of each application in the struct and only include those directories from within the |
@josevalim yea, it copies that file into the archive as start.boot https://github.com/erlang/otp/blob/master/lib/sasl/src/systools_make.erl#L1770 @Gazler you can, that is what systools does. |
Thanks @tsloughter. @josevalim What do you suggest? Should we go the systools route? Or are Elixir releases different enough that it'd be valuable to do it outside of systools? |
Patching systools to allow copying the start.boot would be nice too :). You'd still need the hack to copy back to relname.boot when run on earlier OTPs but it would be a nice change. |
I am not confident systools would copy everything we need:
So I am afraid we may need to perform a bunch of workarounds and rolling our own should be less lines of code (as we already have all applications and their versions listed in the |
2c4b4ec
to
92e393a
Compare
Some of the directories inside of lib may be from previous builds. This commit walks the included apps and ensures that only they are include in the build. The test explicitly creates an old application and ensures that it is not included in the build. All of the files (not directories) inside of the releases dir are also included in the tar, the specific directory for the version of erts is explicitly added.
92e393a
to
5d94051
Compare
I've pushed the code that limits the directories added for |
lib/mix/lib/mix/tasks/release.ex
Outdated
Enum.map(dirs, &{String.to_charlist(&1), String.to_charlist(Path.join(release.path, &1))}) | ||
|
||
:ok = :erl_tar.create(String.to_charlist(out_path), files, [:dereference, :compressed]) | ||
:ok = File.rename(out_path, Path.join(release.version_path, tar_filename)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using the path I proposed above, we don't need the rename anymore, but we will need to call File.rm
before :erl_tar.create
.
@josevalim relx uses Another thing that would be nice to have added to systools itself :) |
720becb
to
12c718c
Compare
Something I expect will come up is it doesn't look like you can include other files in the release. It is often useful for the user to be able to bundle any files they want along with the release. |
@tsloughter agreed. Any suggestions? Should we always include everything else at the root? Or should we allow them to list extra directories? |
In any case, I would merge this as is and add extra directories support next. |
Thank you @Gazler! 💜 |
@josevalim I suggest requiring an explicit list of additional files/directories to include. Otherwise you risk including shit like logs if they ran the release from the |
Closes #9289
There are a couple of points worth discussing.
@ericmj mentioned using :systools, even if we want to change that, the tests, docs and validations in this PR should still be valid.
Currently the step is simply called
:tar
. Not sure if we want to use a different name, or allow users to build the tar in a different location (something like{:tar, "some/path/for/myapp.tar.gz"}