kerl icon indicating copy to clipboard operation
kerl copied to clipboard

kerl cleanup doesn't seem to work as described

Open bmaupin opened this issue 8 years ago • 5 comments

I might be misunderstanding, but it looks like I should be able to use kerl cleanup on a specific version:

$ ./kerl cleanup
usage: ./kerl cleanup <build_name|all>

However when I run kerl cleanup 20.1, it looks like it removes the entire builds directory:

$ ls -1 .kerl/builds/
20.1
20.2

$ ./kerl cleanup 20.1
Cleaning up compilation products for
Cleaned up compilation products for  under /opt/erlang/.kerl/builds

$ ls .kerl/builds
ls: cannot access .kerl/builds: No such file or directory

$ ls .kerl/
archives  otp_builds  otp_installations  otp_releases

I'm using kerl 1.8.1 on CentOS 7.4

$ ./kerl version
1.8.1

$ lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.4.1708 (Core)
Release:        7.4.1708
Codename:       Core

Thanks!

bmaupin avatar Jan 19 '18 20:01 bmaupin

Yikes. Thanks for the note. Definitely need to figure out what's going on here.

jadeallenx avatar Jan 19 '18 21:01 jadeallenx

So it looks like a simple fix: https://github.com/bmaupin/kerl/commit/921744ea158734a9b7260781d7561746bc08189d

But now it creates 2 more issues:

  1. The build folder's deleted but the corresponding entry in the otp_builds file isn't removed. So this prevents that build from being rerun again after being cleaned up:

     $./kerl build 20.0 20.0
     ...
    
     $ ./kerl cleanup 20.0
     Cleaning up compilation products for 20.0
     Cleaned up compilation products for 20.0 under /opt/app/erlang/.kerl/builds
    
     $ ./kerl build 20.0 20.0
     There's already a build named 20.0
    
     $ cat .kerl/otp_builds
     20.0,20.0
    

    That's also a simple fix: https://github.com/bmaupin/kerl/commit/b91ccb7fbfe67e36eb38ce1050bf9666ee63c2a5

  2. kerl cleanup 20.0 doesn't do anything other than delete the build directory. Looking at the source for kerl cleanup all, it looks like it should also clean out the download/git folders, but this would require adding logic for the correct filename patterns to delete.

    I started working on the logic but it's messy and I wasn't able to finish because it looks like the Git URL would be needed for a proper full cleanup:

    if [ "$KERL_BUILD_BACKEND" = "git" ]; then
        rm "${KERL_DOWNLOAD_DIR:?}/$(make_filename "$rel")"
    else
        rm "${KERL_DOWNLOAD_DIR:?}/otp_src_$rel"
    fi
    GIT=$(echo -n <git_url> | $MD5SUM | cut -d ' ' -f $MD5SUM_FIELD)
    rm -rf "${KERL_GIT_DIR:?}/$GIT"
    

So to sum up: kerl cleanup all works fine, but kerl cleanup 20.0 does even less than kerl delete 20.0 and causes additional problems. I'm not sure what's the best way to move forward.

bmaupin avatar Jan 22 '18 20:01 bmaupin

So sorry about the ridiculous time lag here, but would you consider opening a PR for your modifications so far? I think we could work through a way forward and close this ticket and #263.

Thanks

jadeallenx avatar Apr 06 '18 20:04 jadeallenx

No worries! I just rebased my fork with the latest changes and created PR #272.

Thanks!

bmaupin avatar Apr 09 '18 15:04 bmaupin

Thank you!

jadeallenx avatar Apr 09 '18 16:04 jadeallenx