aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2012-10-16 18:37:24 -0300
committerHisham Muhammad <hisham@gobolinux.org>2012-10-16 18:37:24 -0300
commitd61ba8874d1e98892d12852852877ed7bf101383 (patch)
tree010997ae78af90e4a238006849700f825cb12cb0
parent5ccd4ab61619088de4a23a37735f2b08fee85f52 (diff)
parent479ee453640cac4e375b1800f2354963129e388c (diff)
downloadluarocks-d61ba8874d1e98892d12852852877ed7bf101383.tar.gz
luarocks-d61ba8874d1e98892d12852852877ed7bf101383.tar.bz2
luarocks-d61ba8874d1e98892d12852852877ed7bf101383.zip
Merge branch 'master' into multitree
-rw-r--r--Makefile7
-rw-r--r--src/luarocks/fs/unix.lua14
-rw-r--r--src/luarocks/fs/win32.lua17
-rw-r--r--src/luarocks/manif.lua2
4 files changed, 38 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 4c18cd34..0e3871e5 100644
--- a/Makefile
+++ b/Makefile
@@ -125,7 +125,12 @@ install_bins: built
125 125
126install_luas: built 126install_luas: built
127 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" 127 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks"
128 cd src/luarocks && for f in $(LUAROCKS_FILES); do d="$(DESTDIR)$(LUADIR)/luarocks"/`dirname "$$f"`; mkdir -p "$$d"; cp "$$f" "$$d"; done 128 cd src/luarocks && for f in $(LUAROCKS_FILES); \
129 do \
130 d="$(DESTDIR)$(LUADIR)/luarocks"/`dirname "$$f"` && \
131 mkdir -p "$$d" && \
132 cp "$$f" "$$d" || exit 1; \
133 done
129 134
130install_site_config: built 135install_site_config: built
131 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" 136 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks"
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua
index e0d40970..cfd20c70 100644
--- a/src/luarocks/fs/unix.lua
+++ b/src/luarocks/fs/unix.lua
@@ -93,3 +93,17 @@ end
93function copy_binary(filename, dest) 93function copy_binary(filename, dest)
94 return fs.copy(filename, dest, "0755") 94 return fs.copy(filename, dest, "0755")
95end 95end
96
97--- Move a file on top of the other.
98-- The new file ceases to exist under its original name,
99-- and takes over the name of the old file.
100-- On Unix this is done through a single rename operation.
101-- @param old_file The name of the original file,
102-- which will be the new name of new_file.
103-- @param new_file The name of the new file,
104-- which will replace old_file.
105-- @return boolean or (nil, string): True if succeeded, or nil and
106-- an error message.
107function replace_file(old_file, new_file)
108 return os.rename(new_file, old_file)
109end
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua
index cbf5fc60..2c78d9b6 100644
--- a/src/luarocks/fs/win32.lua
+++ b/src/luarocks/fs/win32.lua
@@ -112,3 +112,20 @@ end
112function get_permissions(filename) 112function get_permissions(filename)
113 return "" 113 return ""
114end 114end
115
116--- Move a file on top of the other.
117-- The new file ceases to exist under its original name,
118-- and takes over the name of the old file.
119-- On Windows this is done by removing the original file and
120-- renaming the new file to its original name.
121-- @param old_file The name of the original file,
122-- which will be the new name of new_file.
123-- @param new_file The name of the new file,
124-- which will replace old_file.
125-- @return boolean or (nil, string): True if succeeded, or nil and
126-- an error message.
127function replace_file(old_file, new_file)
128 os.remove(old_file)
129 return os.rename(new_file, old_file)
130end
131
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua
index 9e5ee823..b7554a33 100644
--- a/src/luarocks/manif.lua
+++ b/src/luarocks/manif.lua
@@ -33,7 +33,7 @@ local function save_table(where, name, tbl)
33 local filename = dir.path(where, name) 33 local filename = dir.path(where, name)
34 local ok, err = persist.save_from_table(filename..".tmp", tbl) 34 local ok, err = persist.save_from_table(filename..".tmp", tbl)
35 if ok then 35 if ok then
36 ok, err = os.rename(filename..".tmp", filename) 36 ok, err = fs.replace_file(filename, filename..".tmp")
37 end 37 end
38 return ok, err 38 return ok, err
39end 39end