Skip to content
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

Plugin uses GNU-specific options with 'cp', 'rm' and 'rmdir' #17

Open
rlipscombe opened this issue Oct 13, 2022 · 7 comments
Open

Plugin uses GNU-specific options with 'cp', 'rm' and 'rmdir' #17

rlipscombe opened this issue Oct 13, 2022 · 7 comments

Comments

@rlipscombe
Copy link
Contributor

rlipscombe commented Oct 13, 2022

This means that it fails on macOS unless you have GNU cp/rm/rmdir ahead of the BSD ones in $PATH. For example:

cp: illegal option -- -
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file ... target_directory
make: *** [foo/deps/elvis_mk/plugins.mk:39: foo/elvis] Error 64
@rlipscombe rlipscombe changed the title Plugin uses GNU-specific options with 'cp' and 'rm' Plugin uses GNU-specific options with 'cp', 'rm' and 'rmdir' Oct 13, 2022
@rlipscombe
Copy link
Contributor Author

Maybe this?

diff --git a/plugins.mk b/plugins.mk
index 33d4aca..3b27fba 100644
--- a/plugins.mk
+++ b/plugins.mk
@@ -46,12 +46,12 @@ endif
                cd elvis-$(ELVIS_VERSION) && \
                $(ELVIS_REBAR3) escriptize
        $(gen_verbose) cp $(ELVIS_BUILD_DIR)/elvis-$(ELVIS_VERSION)/_build/default/bin/elvis $(ELVIS)
-       $(gen_verbose) cp --no-clobber $(ELVIS_BUILD_DIR)/elvis-$(ELVIS_VERSION)/elvis.config $(ELVIS_CONFIG)
+       $(gen_verbose) -cp -n $(ELVIS_BUILD_DIR)/elvis-$(ELVIS_VERSION)/elvis.config $(ELVIS_CONFIG)
        $(verbose) chmod +x $(ELVIS)
        $(verbose) rm -rf $(ELVIS_BUILD_DIR)/elvis-$(ELVIS_VERSION)
        $(verbose) rm $(ELVIS_BUILD_DIR)/$(ELVIS_CODE_ARCHIVE)
-       $(verbose) rm --force $(ELVIS_BUILD_DIR)/rebar3
-       $(verbose) rmdir --ignore-fail-on-non-empty $(ELVIS_BUILD_DIR)
+       $(verbose) rm -f $(ELVIS_BUILD_DIR)/rebar3
+       $(verbose) -rmdir $(ELVIS_BUILD_DIR)

 elvis: $(ELVIS)
        $(verbose) $(ELVIS) rock -c $(ELVIS_CONFIG) $(ELVIS_OPTS)

@rlipscombe
Copy link
Contributor Author

Hmmm. Breaks with V=2.

@rlipscombe
Copy link
Contributor Author

rlipscombe commented Oct 13, 2022

This seems to work:

diff --git a/plugins.mk b/plugins.mk
index 33d4aca..e8f826c 100644
--- a/plugins.mk
+++ b/plugins.mk
@@ -46,12 +46,12 @@ endif
                cd elvis-$(ELVIS_VERSION) && \
                $(ELVIS_REBAR3) escriptize
        $(gen_verbose) cp $(ELVIS_BUILD_DIR)/elvis-$(ELVIS_VERSION)/_build/default/bin/elvis $(ELVIS)
-       $(gen_verbose) cp --no-clobber $(ELVIS_BUILD_DIR)/elvis-$(ELVIS_VERSION)/elvis.config $(ELVIS_CONFIG)
+       $(gen_verbose) if [ ! -f $(ELVIS_CONFIG) ]; then cp $(ELVIS_BUILD_DIR)/elvis-$(ELVIS_VERSION)/elvis.config $(ELVIS_CONFIG); fi
        $(verbose) chmod +x $(ELVIS)
        $(verbose) rm -rf $(ELVIS_BUILD_DIR)/elvis-$(ELVIS_VERSION)
        $(verbose) rm $(ELVIS_BUILD_DIR)/$(ELVIS_CODE_ARCHIVE)
-       $(verbose) rm --force $(ELVIS_BUILD_DIR)/rebar3
-       $(verbose) rmdir --ignore-fail-on-non-empty $(ELVIS_BUILD_DIR)
+       $(verbose) rm -f $(ELVIS_BUILD_DIR)/rebar3
+       -$(verbose) rmdir $(ELVIS_BUILD_DIR)

 elvis: $(ELVIS)
        $(verbose) $(ELVIS) rock -c $(ELVIS_CONFIG) $(ELVIS_OPTS)

andrei-mihaila added a commit to andrei-mihaila/elvis.mk that referenced this issue Oct 13, 2022
andrei-mihaila added a commit to andrei-mihaila/elvis.mk that referenced this issue Oct 13, 2022
@elbrujohalcon
Copy link
Member

Thanks, @rlipscombe!
Do you mind submitting a pull request with the changes?

@andrei-mihaila
Copy link
Contributor

@rlipscombe, I added your changes and made some performance improvements. Can you please test?

You can update your Makefile with:

dep_elvis_mk = git https://github.com/andrei-mihaila/elvis.mk.git
dep_elvis_mk_commit = master

And, if possible, clone my repo and run test/run.sh.

Thanks!

rlipscombe pushed a commit to rlipscombe/elvis.mk that referenced this issue Oct 19, 2022
rlipscombe added a commit to rlipscombe/elvis.mk that referenced this issue Oct 19, 2022
Change the test for empty directory to match one that erlang.mk uses
itself, for consistency.

refs inaka#17
@rlipscombe
Copy link
Contributor Author

Minor tweak for consistency with erlang.mk, but lgtm.

@andrei-mihaila
Copy link
Contributor

andrei-mihaila commented Oct 19, 2022

Minor tweak for consistency with erlang.mk, but lgtm.

I used that initially and then decided against it because it shows a warning when the build directory doesn't exist.

ls: cannot access '/[...]/elvis.mk/test/_build/': No such file or directory

But we can live with that.

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

No branches or pull requests

3 participants