diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-12-02 14:09:35 +0100 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-12-02 14:09:35 +0100 |
commit | 52b6e37e53c7f99134f3b2aa9c07595221c1f7b2 (patch) | |
tree | c04cbea4d1102060c169a02267c349d3484a7f7a | |
parent | aeff1458076fdefccea990a6d62139084ee605e2 (diff) | |
download | luarocks-52b6e37e53c7f99134f3b2aa9c07595221c1f7b2.tar.gz luarocks-52b6e37e53c7f99134f3b2aa9c07595221c1f7b2.tar.bz2 luarocks-52b6e37e53c7f99134f3b2aa9c07595221c1f7b2.zip |
Commandline options where silently ignored if config.lua already existed. Now a backup is made and the options are written.
Additional paths to the local tree are now listed after installing
Diffstat (limited to '')
-rw-r--r-- | install.bat | 98 |
1 files changed, 64 insertions, 34 deletions
diff --git a/install.bat b/install.bat index 1e4763fc..8373f856 100644 --- a/install.bat +++ b/install.bat | |||
@@ -88,6 +88,19 @@ local function permission() | |||
88 | return exec("net session >nul 2>&1") -- fails if not admin | 88 | return exec("net session >nul 2>&1") -- fails if not admin |
89 | end | 89 | end |
90 | 90 | ||
91 | -- rename file (full path) to backup (name only), appending number if required | ||
92 | -- returns the new name (name only) | ||
93 | local function backup(filename, backupname) | ||
94 | local path = filename:match("(.+)%\\.-$").."\\" | ||
95 | local nname = backupname | ||
96 | local i = 0 | ||
97 | while exists(path..nname) do | ||
98 | i = i + 1 | ||
99 | nname = backupname..tostring(i) | ||
100 | end | ||
101 | exec([[REN "]]..filename..[[" "]]..nname..[[" > NUL]]) | ||
102 | return nname | ||
103 | end | ||
91 | 104 | ||
92 | -- interpolate string with values from 'vars' table | 105 | -- interpolate string with values from 'vars' table |
93 | local function S (tmpl) | 106 | local function S (tmpl) |
@@ -699,51 +712,56 @@ vars.CONFIG_FILE = vars.SYSCONFDIR.."\\config.lua" | |||
699 | if not exists(vars.SYSCONFDIR) then | 712 | if not exists(vars.SYSCONFDIR) then |
700 | mkdir(vars.SYSCONFDIR) | 713 | mkdir(vars.SYSCONFDIR) |
701 | end | 714 | end |
702 | if not exists(vars.CONFIG_FILE) then | 715 | if exists(vars.CONFIG_FILE) then |
703 | local f = io.open(vars.CONFIG_FILE, "w") | 716 | local nname = backup(vars.CONFIG_FILE, "config.bak") |
704 | f:write([=[ | 717 | print("***************") |
718 | print(S"*** WARNING *** LuaRocks config file already exists: '$CONFIG_FILE'. The old file has been renamed to '"..nname.."'") | ||
719 | print("***************") | ||
720 | end | ||
721 | local f = io.open(vars.CONFIG_FILE, "w") | ||
722 | f:write([=[ | ||
705 | rocks_servers = { | 723 | rocks_servers = { |
706 | [[http://luarocks.org/repositories/rocks]] | 724 | [[http://luarocks.org/repositories/rocks]] |
707 | } | 725 | } |
708 | rocks_trees = { | 726 | rocks_trees = { |
709 | ]=]) | 727 | ]=]) |
710 | if FORCE_CONFIG then | 728 | if FORCE_CONFIG then |
711 | f:write(" home..[[/luarocks]],\n") | 729 | f:write(" home..[[/luarocks]],\n") |
712 | end | 730 | end |
713 | f:write(S" [[$ROCKS_TREE]]\n") | 731 | f:write(S" [[$ROCKS_TREE]]\n") |
714 | f:write("}\n") | 732 | f:write("}\n") |
715 | if vars.SCRIPTS_DIR then | 733 | if vars.SCRIPTS_DIR then |
716 | f:write(S"scripts_dir=[[$SCRIPTS_DIR]]\n") | 734 | f:write(S"scripts_dir=[[$SCRIPTS_DIR]]\n") |
717 | end | 735 | end |
718 | f:write("variables = {\n") | 736 | f:write("variables = {\n") |
719 | if USE_MINGW and vars.LUA_RUNTIME == "MSVCRT" then | 737 | if USE_MINGW and vars.LUA_RUNTIME == "MSVCRT" then |
720 | f:write(" MSVCRT = 'm', -- make MinGW use MSVCRT.DLL as runtime\n") | 738 | f:write(" MSVCRT = 'm', -- make MinGW use MSVCRT.DLL as runtime\n") |
721 | else | ||
722 | f:write(" MSVCRT = '"..vars.LUA_RUNTIME.."',\n") | ||
723 | end | ||
724 | f:write(S" LUALIB = '$LUA_LIBNAME'\n") | ||
725 | f:write("}\n") | ||
726 | f:write("verbose = false -- set to 'true' to enable verbose output\n") | ||
727 | f:close() | ||
728 | print(S"Created LuaRocks config file: $CONFIG_FILE") | ||
729 | else | 739 | else |
730 | print(S"LuaRocks config file already exists: $CONFIG_FILE") | 740 | f:write(" MSVCRT = '"..vars.LUA_RUNTIME.."',\n") |
731 | end | 741 | end |
742 | f:write(S" LUALIB = '$LUA_LIBNAME'\n") | ||
743 | f:write("}\n") | ||
744 | f:write("verbose = false -- set to 'true' to enable verbose output\n") | ||
745 | f:close() | ||
746 | |||
747 | print(S"Created LuaRocks config file: $CONFIG_FILE") | ||
748 | |||
732 | 749 | ||
733 | print() | 750 | print() |
734 | print("Creating rocktrees...") | 751 | print("Creating rocktrees...") |
735 | if not exists(vars.ROCKS_TREE) then | 752 | if not exists(vars.ROCKS_TREE) then |
736 | mkdir(vars.ROCKS_TREE) | 753 | mkdir(vars.ROCKS_TREE) |
737 | print(S[[Created rocktree: "$ROCKS_TREE"]]) | 754 | print(S[[Created system rocktree : "$ROCKS_TREE"]]) |
738 | else | 755 | else |
739 | print(S[[Rocktree exists: "$ROCKS_TREE"]]) | 756 | print(S[[System rocktree exists : "$ROCKS_TREE"]]) |
740 | end | 757 | end |
741 | local APPDATA = os.getenv("APPDATA") | 758 | |
742 | if not exists(APPDATA.."\\luarocks") then | 759 | vars.LOCAL_TREE = os.getenv("APPDATA")..[[\LuaRocks]] |
743 | mkdir(APPDATA.."\\luarocks") | 760 | if not exists(vars.LOCAL_TREE) then |
744 | print([[Created rocktree: "]]..APPDATA..[[\luarocks"]]) | 761 | mkdir(vars.LOCAL_TREE) |
762 | print(S[[Created local user rocktree: "$LOCAL_TREE"]]) | ||
745 | else | 763 | else |
746 | print([[Rocktree exists: "]]..APPDATA..[[\luarocks"]]) | 764 | print(S[[Local user rocktree exists : "$LOCAL_TREE"]]) |
747 | end | 765 | end |
748 | 766 | ||
749 | -- Load registry information | 767 | -- Load registry information |
@@ -768,12 +786,24 @@ exec( S[[del "$FULL_PREFIX\pe-parser.lua" > nul]] ) | |||
768 | -- *********************************************************** | 786 | -- *********************************************************** |
769 | 787 | ||
770 | print(S[[ | 788 | print(S[[ |
789 | |||
771 | *** LuaRocks is installed! *** | 790 | *** LuaRocks is installed! *** |
772 | 791 | ||
773 | You may want to add the following elements to your paths; | 792 | You may want to add the following elements to your paths; |
774 | PATH : $LUA_BINDIR;$FULL_PREFIX | 793 | Lua interpreter; |
775 | LUA_PATH : $ROCKS_TREE\share\lua\$LUA_VERSION\?.lua;$ROCKS_TREE\share\lua\$LUA_VERSION\?\init.lua | 794 | PATH : $LUA_BINDIR |
776 | LUA_CPATH: $ROCKS_TREE\lib\lua\$LUA_VERSION\?.dll | 795 | PATHEXT : .LUA |
796 | LuaRocks; | ||
797 | PATH : $FULL_PREFIX | ||
798 | LUA_PATH : $FULL_PREFIX\lua\?.lua;$FULL_PREFIX\lua\?\init.lua | ||
799 | Local user rocktree (Note: %APPDATA% is user dependent); | ||
800 | PATH : %APPDATA%\LuaRock\bin | ||
801 | LUA_PATH : %APPDATA%\LuaRocks\share\lua\$LUA_VERSION\?.lua;%APPDATA%\LuaRocks\share\lua\$LUA_VERSION\?\init.lua | ||
802 | LUA_CPATH: %APPDATA%\LuaRocks\lib\lua\$LUA_VERSION\?.dll | ||
803 | System rocktree | ||
804 | PATH : $ROCKS_TREE\bin | ||
805 | LUA_PATH : $ROCKS_TREE\share\lua\$LUA_VERSION\?.lua;$ROCKS_TREE\share\lua\$LUA_VERSION\?\init.lua | ||
806 | LUA_CPATH: $ROCKS_TREE\lib\lua\$LUA_VERSION\?.dll | ||
777 | 807 | ||
778 | ]]) | 808 | ]]) |
779 | os.exit(0) | 809 | os.exit(0) |