summaryrefslogtreecommitdiffstats
path: root/plugins/luarocks/luarocks.mk
diff options
context:
space:
mode:
authorBoris Nagaev <bnagaev@gmail.com>2015-12-05 21:45:23 (GMT)
committerBoris Nagaev <bnagaev@gmail.com>2015-12-06 02:38:24 (GMT)
commit51a6141cf9d6768d841d644bd760361443b3dd65 (patch)
tree4fcbfa9a04e6df49c8fa0d9dd689be6a06147cd7 /plugins/luarocks/luarocks.mk
parentab3635cbd57253dfd40d679f01ef2c4c60116e6b (diff)
downloadmxe-51a6141cf9d6768d841d644bd760361443b3dd65.zip
mxe-51a6141cf9d6768d841d644bd760361443b3dd65.tar.gz
mxe-51a6141cf9d6768d841d644bd760361443b3dd65.tar.bz2
luarocks wrapper prevents race condition
See https://github.com/mxe/mxe/pull/1017#issuecomment-161557440 See http://wiki.bash-hackers.org/howto/mutex
Diffstat (limited to 'plugins/luarocks/luarocks.mk')
-rw-r--r--plugins/luarocks/luarocks.mk24
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/luarocks/luarocks.mk b/plugins/luarocks/luarocks.mk
index b7cbbae..10131ee 100644
--- a/plugins/luarocks/luarocks.mk
+++ b/plugins/luarocks/luarocks.mk
@@ -33,6 +33,30 @@ define $(PKG)_BUILD_SHARED
LUAROCKS_UNAME_S="MXE" \
LUAROCKS_UNAME_M="$(TARGET)"
$(MAKE) -C '$(1)' install
+
+ # move installed lua file luarocks to luarocks.lua
+ mv '$(PREFIX)/$(TARGET)/bin/luarocks' '$(PREFIX)/$(TARGET)/bin/luarocks.lua'
+
+ # create bash wrapper adding inter-process mutex
+ # see https://github.com/mxe/mxe/pull/1017#issuecomment-161557440
+ (echo '#!/usr/bin/env bash'; \
+ echo 'echo "== Using MXE wrapper: $(PREFIX)/$(TARGET)/bin/luarocks"'; \
+ echo '# Creating a directory is an atomic operation, that is why'; \
+ echo '# it can be used as a mutex.'; \
+ echo '# See http://wiki.bash-hackers.org/howto/mutex'; \
+ echo 'while ( ! mkdir "$(PREFIX)/$(TARGET)/lib/luarocks/lock.dir" ); do'; \
+ echo ' echo "Waiting for $(PREFIX)/$(TARGET)/lib/luarocks/lock.dir to lock"'; \
+ echo ' sleep 5'; \
+ echo 'done'; \
+ echo '"$(PREFIX)/$(TARGET)/bin/luarocks.lua" "$$@"'; \
+ echo 'rmdir "$(PREFIX)/$(TARGET)/lib/luarocks/lock.dir"'; \
+ ) \
+ > '$(PREFIX)/$(TARGET)/bin/luarocks'
+ chmod 0755 '$(PREFIX)/$(TARGET)/bin/luarocks'
+ # remove lock dir if it exists after previous failed installation
+ -rmdir "$(PREFIX)/$(TARGET)/lib/luarocks/lock.dir"
+
+ # symlink
ln -sf '$(PREFIX)/$(TARGET)/bin/luarocks' '$(PREFIX)/bin/$(TARGET)-luarocks'
# create wine wrapper for testing