Skip to content

Instantly share code, notes, and snippets.

@kbridge
Created March 26, 2022 17:50
Show Gist options
  • Save kbridge/d98b0c1df06d2cbc256bfaf64b63ffb1 to your computer and use it in GitHub Desktop.
Save kbridge/d98b0c1df06d2cbc256bfaf64b63ffb1 to your computer and use it in GitHub Desktop.
erl help workaround for Fedora35/Erlang24.2.2-1
#!/usr/bin/env escript
%% Before
%% erl> h(maps). => There is no documentation for maps
%% After
%% erl> h(maps). => This module contains functions for maps processing...
%% Usage:
%%
%% 1. Install the documentation
%% sudo dnf install erlang-doc
%% 2. Run
%% chmod u+x fix_docs.escript
%% ./fix_docs.escript link
-include_lib("kernel/include/file.hrl").
-define(DOC_DIR, "/usr/share/doc/erlang-24.2.2/lib").
-define(LIB_DIR, "/usr/lib64/erlang/lib").
-define(LIB_NAME_WIDTH, 24).
main(["link"]) ->
{ok, Files} = file:list_dir(?DOC_DIR),
Plan = [{Lib,
filename:join([?DOC_DIR, Lib]),
filename:join([?LIB_DIR, Lib, "doc"])
}
||
Lib <- lists:sort(Files),
filelib:is_dir(filename:join([?DOC_DIR, Lib, "chunks"])),
filelib:is_dir(filename:join([?LIB_DIR, Lib]))
],
lists:foreach(
fun({Lib, SourcePath, DestinationPath}) ->
Result = file:make_symlink(SourcePath, DestinationPath),
io:format("LINK ~*s~p~n", [-?LIB_NAME_WIDTH, Lib, Result])
end,
Plan);
main(["unlink"]) ->
{ok, Files} = file:list_dir(?LIB_DIR),
Plan1 = [{Lib, filename:join([?LIB_DIR, Lib, "doc"])} || Lib <- lists:sort(Files)],
Plan2 = [Item ||
{_, Path} = Item <- Plan1,
case file:read_link_info(Path) of
{ok, #file_info{type = symlink}} -> true;
_ -> false
end
],
lists:foreach(
fun({Lib, Path}) ->
Result = file:delete(Path),
io:format("UNLINK ~*s~p~n", [-?LIB_NAME_WIDTH, Lib, Result])
end,
Plan2);
main(_) ->
io:format("usage: ~s link|unlink~n", [escript:script_name()]).
@kbridge
Copy link
Author

kbridge commented Apr 30, 2022

You don't need this anymore because the Fedora guys had already fixed it 😏

Bug Ticket: https://bugzilla.redhat.com/show_bug.cgi?id=2068758

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment