diff options
author | hisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c> | 2009-07-05 03:46:41 +0000 |
---|---|---|
committer | hisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c> | 2009-07-05 03:46:41 +0000 |
commit | f072d458fa89d1af16284353a9a74d2172abc83c (patch) | |
tree | 28ee8a25c1c751126cb10353bc90ceff271fd200 /src | |
parent | 6d045abb61a68e573cefb63b32c3bd85c7b6249e (diff) | |
download | luarocks-f072d458fa89d1af16284353a9a74d2172abc83c.tar.gz luarocks-f072d458fa89d1af16284353a9a74d2172abc83c.tar.bz2 luarocks-f072d458fa89d1af16284353a9a74d2172abc83c.zip |
progress converting LuaRocks commands to 2.0 format
git-svn-id: http://luarocks.org/svn/luarocks/trunk@38 9ca3f7c1-7366-0410-b1a3-b5c78f85698c
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks.lua | 2 | ||||
-rw-r--r-- | src/luarocks/cfg.lua | 98 | ||||
-rw-r--r-- | src/luarocks/command_line.lua | 15 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 13 | ||||
-rw-r--r-- | src/luarocks/fs/unix/tools.lua | 9 | ||||
-rw-r--r-- | src/luarocks/list.lua | 4 | ||||
-rw-r--r-- | src/luarocks/make_manifest.lua | 4 | ||||
-rw-r--r-- | src/luarocks/manif.lua | 34 | ||||
-rw-r--r-- | src/luarocks/pack.lua | 33 | ||||
-rw-r--r-- | src/luarocks/path.lua | 84 | ||||
-rw-r--r-- | src/luarocks/remove.lua | 14 | ||||
-rw-r--r-- | src/luarocks/rep.lua | 10 | ||||
-rw-r--r-- | src/luarocks/util.lua | 2 | ||||
-rw-r--r-- | src/luarocks/validate.lua | 3 |
14 files changed, 211 insertions, 114 deletions
diff --git a/src/luarocks.lua b/src/luarocks.lua index 8530fd90..3e2088a4 100644 --- a/src/luarocks.lua +++ b/src/luarocks.lua | |||
@@ -23,7 +23,7 @@ local function load_rocks_trees() | |||
23 | local any_ok = false | 23 | local any_ok = false |
24 | local trees = {} | 24 | local trees = {} |
25 | for _, tree in pairs(cfg.rocks_trees) do | 25 | for _, tree in pairs(cfg.rocks_trees) do |
26 | local rocks_dir = tree .. "/rocks/" | 26 | local rocks_dir = path.rocks_dir(tree) |
27 | local manifest, err = manif_core.load_local_manifest(rocks_dir) | 27 | local manifest, err = manif_core.load_local_manifest(rocks_dir) |
28 | if manifest then | 28 | if manifest then |
29 | any_ok = true | 29 | any_ok = true |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index f74c40ad..d4bcbfb6 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -10,6 +10,7 @@ local rawset, next, table, pairs, print, require, io, os, setmetatable, pcall = | |||
10 | module("luarocks.cfg") | 10 | module("luarocks.cfg") |
11 | 11 | ||
12 | program_version = "1.1" | 12 | program_version = "1.1" |
13 | user_agent = "LuaRocks/"..program_version | ||
13 | 14 | ||
14 | local persist = require("luarocks.persist") | 15 | local persist = require("luarocks.persist") |
15 | 16 | ||
@@ -24,6 +25,8 @@ else | |||
24 | os.exit(1) | 25 | os.exit(1) |
25 | end | 26 | end |
26 | 27 | ||
28 | -- System detection: | ||
29 | |||
27 | local detected = {} | 30 | local detected = {} |
28 | local system,proc | 31 | local system,proc |
29 | 32 | ||
@@ -61,6 +64,8 @@ else | |||
61 | -- Fall back to Unix in unknown systems. | 64 | -- Fall back to Unix in unknown systems. |
62 | end | 65 | end |
63 | 66 | ||
67 | -- Path configuration: | ||
68 | |||
64 | local sys_config_file, home_config_file, home_tree | 69 | local sys_config_file, home_config_file, home_tree |
65 | if detected.windows then | 70 | if detected.windows then |
66 | home = os.getenv("APPDATA") or "c:" | 71 | home = os.getenv("APPDATA") or "c:" |
@@ -88,46 +93,65 @@ if not LUAROCKS_FORCE_CONFIG then | |||
88 | end | 93 | end |
89 | end | 94 | end |
90 | 95 | ||
96 | if not next(rocks_trees) then | ||
97 | if home_tree then | ||
98 | table.insert(rocks_trees, home_tree) | ||
99 | end | ||
100 | if LUAROCKS_ROCKS_TREE then | ||
101 | table.insert(rocks_trees, LUAROCKS_ROCKS_TREE) | ||
102 | end | ||
103 | end | ||
104 | |||
105 | -- Configure defaults: | ||
106 | |||
107 | local root = LUAROCKS_ROCKS_TREE or home_tree | ||
91 | local defaults = { | 108 | local defaults = { |
109 | root_dir = root, | ||
110 | rocks_dir = root.."/lib/luarocks/rocks", | ||
111 | scripts_dir = root.."/bin/", | ||
112 | lua_modules_dir = root.."/share/lua/5.1/", | ||
113 | bin_modules_dir = root.."/lib/lua/5.1/", | ||
114 | |||
92 | arch = "unknown", | 115 | arch = "unknown", |
93 | lib_extension = "unknown", | 116 | lib_extension = "unknown", |
94 | obj_extension = "unknown", | 117 | obj_extension = "unknown", |
118 | |||
95 | rocks_servers = { | 119 | rocks_servers = { |
96 | "http://luarocks.luaforge.net/rocks" | 120 | "http://luarocks.luaforge.net/rocks" |
97 | }, | 121 | }, |
122 | |||
98 | lua_extension = "lua", | 123 | lua_extension = "lua", |
99 | lua_interpreter = LUA_INTERPRETER or "lua", | 124 | lua_interpreter = LUA_INTERPRETER or "lua", |
100 | downloader = LUAROCKS_DOWNLOADER or "wget", | 125 | downloader = LUAROCKS_DOWNLOADER or "wget", |
101 | md5checker = LUAROCKS_MD5CHECKER or "md5sum", | 126 | md5checker = LUAROCKS_MD5CHECKER or "md5sum", |
102 | variables = {} | ||
103 | } | ||
104 | 127 | ||
105 | defaults.external_deps_subdirs = { | 128 | variables = {}, |
106 | bin = "bin", | 129 | |
107 | lib = "lib", | 130 | external_deps_subdirs = { |
108 | include = "include" | 131 | bin = "bin", |
132 | lib = "lib", | ||
133 | include = "include" | ||
134 | }, | ||
135 | runtime_external_deps_subdirs = { | ||
136 | bin = "bin", | ||
137 | lib = "lib", | ||
138 | include = "include" | ||
139 | }, | ||
109 | } | 140 | } |
110 | defaults.runtime_external_deps_subdirs = defaults.external_deps_subdirs | ||
111 | 141 | ||
112 | if detected.windows then | 142 | if detected.windows then |
113 | home_config_file = home_config_file:gsub("\\","/") | 143 | home_config_file = home_config_file:gsub("\\","/") |
144 | defaults.arch = "win32-"..proc | ||
145 | defaults.platforms = {"win32", "windows" } | ||
114 | defaults.lib_extension = "dll" | 146 | defaults.lib_extension = "dll" |
147 | defaults.external_lib_extension = "dll" | ||
115 | defaults.obj_extension = "obj" | 148 | defaults.obj_extension = "obj" |
116 | local rootdir = LUAROCKS_ROCKS_TREE or home_tree | ||
117 | defaults.root_dir = rootdir | ||
118 | defaults.rocks_dir = rootdir.."/rocks/" | ||
119 | defaults.scripts_dir = rootdir.."/bin/" | ||
120 | defaults.external_deps_dirs = { "c:/external/" } | 149 | defaults.external_deps_dirs = { "c:/external/" } |
121 | defaults.variables.LUA_BINDIR = LUA_BINDIR and LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" | 150 | defaults.variables.LUA_BINDIR = LUA_BINDIR and LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" |
122 | defaults.variables.LUA_INCDIR = LUA_INCDIR and LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" | 151 | defaults.variables.LUA_INCDIR = LUA_INCDIR and LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" |
123 | defaults.variables.LUA_LIBDIR = LUA_LIBDIR and LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" | 152 | defaults.variables.LUA_LIBDIR = LUA_LIBDIR and LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" |
124 | defaults.arch = "win32-"..proc | ||
125 | defaults.platforms = {"win32", "windows" } | ||
126 | defaults.cmake_generator = "MinGW Makefiles" | 153 | defaults.cmake_generator = "MinGW Makefiles" |
127 | -- TODO: Split Windows flavors between mingw and msvc | 154 | defaults.make = "nmake" -- TODO: Split Windows flavors between mingw and msvc |
128 | -- defaults.make = "make" | ||
129 | -- defaults.makefile = "Makefile" | ||
130 | defaults.make = "nmake" | ||
131 | defaults.makefile = "Makefile.win" | 155 | defaults.makefile = "Makefile.win" |
132 | defaults.variables.CC = "cl" | 156 | defaults.variables.CC = "cl" |
133 | defaults.variables.LD = "link" | 157 | defaults.variables.LD = "link" |
@@ -148,11 +172,8 @@ end | |||
148 | 172 | ||
149 | if detected.unix then | 173 | if detected.unix then |
150 | defaults.lib_extension = "so" | 174 | defaults.lib_extension = "so" |
175 | defaults.external_lib_extension = "so" | ||
151 | defaults.obj_extension = "o" | 176 | defaults.obj_extension = "o" |
152 | local rootdir = LUAROCKS_ROCKS_TREE or home_tree | ||
153 | defaults.root_dir = rootdir | ||
154 | defaults.rocks_dir = rootdir.."/rocks/" | ||
155 | defaults.scripts_dir = rootdir.."/bin/" | ||
156 | defaults.external_deps_dirs = { "/usr/local", "/usr" } | 177 | defaults.external_deps_dirs = { "/usr/local", "/usr" } |
157 | defaults.variables.LUA_BINDIR = LUA_BINDIR or "/usr/local/bin" | 178 | defaults.variables.LUA_BINDIR = LUA_BINDIR or "/usr/local/bin" |
158 | defaults.variables.LUA_INCDIR = LUA_INCDIR or "/usr/local/include" | 179 | defaults.variables.LUA_INCDIR = LUA_INCDIR or "/usr/local/include" |
@@ -186,8 +207,6 @@ if detected.cygwin then | |||
186 | defaults.variables.LIBFLAG = "-shared" | 207 | defaults.variables.LIBFLAG = "-shared" |
187 | end | 208 | end |
188 | 209 | ||
189 | defaults.external_lib_extension = defaults.lib_extension | ||
190 | |||
191 | if detected.macosx then | 210 | if detected.macosx then |
192 | defaults.external_lib_extension = "dylib" | 211 | defaults.external_lib_extension = "dylib" |
193 | defaults.arch = "macosx-"..proc | 212 | defaults.arch = "macosx-"..proc |
@@ -224,16 +243,10 @@ defaults.variables.LIB_EXTENSION = defaults.lib_extension | |||
224 | defaults.variables.OBJ_EXTENSION = defaults.obj_extension | 243 | defaults.variables.OBJ_EXTENSION = defaults.obj_extension |
225 | defaults.variables.LUAROCKS_PREFIX = LUAROCKS_PREFIX | 244 | defaults.variables.LUAROCKS_PREFIX = LUAROCKS_PREFIX |
226 | 245 | ||
227 | local cfg_mt = { | 246 | -- Use defaults: |
228 | __index = function(t, k) | ||
229 | local default = defaults[k] | ||
230 | if default then | ||
231 | rawset(t, k, default) | ||
232 | end | ||
233 | return default | ||
234 | end | ||
235 | } | ||
236 | 247 | ||
248 | -- Populate values from 'defaults.variables' in 'variables' if they were not | ||
249 | -- already set by user. | ||
237 | if not _M.variables then | 250 | if not _M.variables then |
238 | _M.variables = {} | 251 | _M.variables = {} |
239 | end | 252 | end |
@@ -243,15 +256,14 @@ for k,v in pairs(defaults.variables) do | |||
243 | end | 256 | end |
244 | end | 257 | end |
245 | 258 | ||
246 | setmetatable(_M, cfg_mt) | 259 | -- For values not set in the config file, use values from the 'defaults' table. |
247 | 260 | local cfg_mt = { | |
248 | if not next(rocks_trees) then | 261 | __index = function(t, k) |
249 | if home_tree then | 262 | local default = defaults[k] |
250 | table.insert(rocks_trees, home_tree) | 263 | if default then |
251 | end | 264 | rawset(t, k, default) |
252 | if LUAROCKS_ROCKS_TREE then | 265 | end |
253 | table.insert(rocks_trees, LUAROCKS_ROCKS_TREE) | 266 | return default |
254 | end | 267 | end |
255 | end | 268 | } |
256 | 269 | setmetatable(_M, cfg_mt) | |
257 | user_agent = "LuaRocks/"..program_version | ||
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 972302ee..963916bd 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
@@ -5,6 +5,7 @@ module("luarocks.command_line", package.seeall) | |||
5 | local util = require("luarocks.util") | 5 | local util = require("luarocks.util") |
6 | local cfg = require("luarocks.cfg") | 6 | local cfg = require("luarocks.cfg") |
7 | local fs = require("luarocks.fs") | 7 | local fs = require("luarocks.fs") |
8 | local path = require("luarocks.path") | ||
8 | 9 | ||
9 | --- Display an error message and exit. | 10 | --- Display an error message and exit. |
10 | -- @param message string: The error message. | 11 | -- @param message string: The error message. |
@@ -50,16 +51,20 @@ function run_command(...) | |||
50 | end | 51 | end |
51 | local root_dir = fs.absolute_name(flags["to"]) | 52 | local root_dir = fs.absolute_name(flags["to"]) |
52 | cfg.root_dir = root_dir | 53 | cfg.root_dir = root_dir |
53 | cfg.rocks_dir = root_dir.."/rocks" | 54 | cfg.rocks_dir = path.rocks_dir(root_dir) |
54 | cfg.scripts_dir = root_dir.."/bin" | 55 | cfg.scripts_dir = path.scripts_dir(root_dir) |
56 | cfg.lua_modules_dir = path.lua_modules_dir(root_dir) | ||
57 | cfg.bin_modules_dir = path.bin_modules_dir(root_dir) | ||
55 | else | 58 | else |
56 | local trees = cfg.rocks_trees | 59 | local trees = cfg.rocks_trees |
57 | for i = #trees, 1, -1 do | 60 | for i = #trees, 1, -1 do |
58 | local tree = trees[i] | 61 | local tree = trees[i] |
59 | if fs.make_dir(tree) and fs.is_writable(tree) then | 62 | if fs.make_dir(tree) and fs.is_writable(tree) then |
60 | cfg.root_dir = tree | 63 | cfg.root_dir = tree |
61 | cfg.rocks_dir = tree.."/rocks" | 64 | cfg.rocks_dir = path.rocks_dir(tree) |
62 | cfg.scripts_dir = rawget(cfg, "scripts_dir") or tree.."/bin" | 65 | cfg.scripts_dir = rawget(cfg, "scripts_dir") or path.scripts_dir(tree) |
66 | cfg.lua_modules_dir = rawget(cfg, "lua_modules_dir") or path.lua_modules_dir(tree) | ||
67 | cfg.bin_modules_dir = rawget(cfg, "bin_modules_dir") or path.bin_modules_dir(tree) | ||
63 | break | 68 | break |
64 | end | 69 | end |
65 | end | 70 | end |
@@ -68,6 +73,8 @@ function run_command(...) | |||
68 | cfg.root_dir = cfg.root_dir:gsub("/+$", "") | 73 | cfg.root_dir = cfg.root_dir:gsub("/+$", "") |
69 | cfg.rocks_dir = cfg.rocks_dir:gsub("/+$", "") | 74 | cfg.rocks_dir = cfg.rocks_dir:gsub("/+$", "") |
70 | cfg.scripts_dir = cfg.scripts_dir:gsub("/+$", "") | 75 | cfg.scripts_dir = cfg.scripts_dir:gsub("/+$", "") |
76 | cfg.lua_modules_dir = cfg.lua_modules_dir:gsub("/+$", "") | ||
77 | cfg.bin_modules_dir = cfg.bin_modules_dir:gsub("/+$", "") | ||
71 | 78 | ||
72 | cfg.variables.ROCKS_TREE = cfg.root_dir | 79 | cfg.variables.ROCKS_TREE = cfg.root_dir |
73 | cfg.variables.SCRIPTS_DIR = cfg.scripts_dir | 80 | cfg.variables.SCRIPTS_DIR = cfg.scripts_dir |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 91cabe51..013fad5f 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -177,6 +177,19 @@ function remove_dir_if_empty(d) | |||
177 | lfs.rmdir(d) | 177 | lfs.rmdir(d) |
178 | end | 178 | end |
179 | 179 | ||
180 | --- Remove a directory if it is empty. | ||
181 | -- Does not return errors (for example, if directory is not empty or | ||
182 | -- if already does not exist) | ||
183 | -- @param d string: pathname of directory to remove. | ||
184 | function remove_dir_tree_if_empty(d) | ||
185 | assert(d) | ||
186 | for i=1,10 do | ||
187 | print(d) | ||
188 | lfs.rmdir(d) | ||
189 | d = dir.dir_name(d) | ||
190 | end | ||
191 | end | ||
192 | |||
180 | --- Copy a file. | 193 | --- Copy a file. |
181 | -- @param src string: Pathname of source | 194 | -- @param src string: Pathname of source |
182 | -- @param dest string: Pathname of destination | 195 | -- @param dest string: Pathname of destination |
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index 5d3afd5e..71dfe074 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -79,6 +79,15 @@ function remove_dir_if_empty(d) | |||
79 | fs.execute_string("rmdir "..fs.Q(d).." 1> /dev/null 2> /dev/null") | 79 | fs.execute_string("rmdir "..fs.Q(d).." 1> /dev/null 2> /dev/null") |
80 | end | 80 | end |
81 | 81 | ||
82 | --- Remove a directory if it is empty. | ||
83 | -- Does not return errors (for example, if directory is not empty or | ||
84 | -- if already does not exist) | ||
85 | -- @param dir string: pathname of directory to remove. | ||
86 | function remove_dir_tree_if_empty(d) | ||
87 | assert(d) | ||
88 | fs.execute_string("rmdir -p "..fs.Q(d).." 1> /dev/null 2> /dev/null") | ||
89 | end | ||
90 | |||
82 | --- Copy a file. | 91 | --- Copy a file. |
83 | -- @param src string: Pathname of source | 92 | -- @param src string: Pathname of source |
84 | -- @param dest string: Pathname of destination | 93 | -- @param dest string: Pathname of destination |
diff --git a/src/luarocks/list.lua b/src/luarocks/list.lua index f918640c..87c5a2ae 100644 --- a/src/luarocks/list.lua +++ b/src/luarocks/list.lua | |||
@@ -6,7 +6,7 @@ module("luarocks.list", package.seeall) | |||
6 | local search = require("luarocks.search") | 6 | local search = require("luarocks.search") |
7 | local cfg = require("luarocks.cfg") | 7 | local cfg = require("luarocks.cfg") |
8 | local util = require("luarocks.util") | 8 | local util = require("luarocks.util") |
9 | local dir = require("luarocks.dir") | 9 | local path = require("luarocks.path") |
10 | 10 | ||
11 | help_summary = "Lists currently installed rocks." | 11 | help_summary = "Lists currently installed rocks." |
12 | 12 | ||
@@ -24,7 +24,7 @@ function run(...) | |||
24 | local query = search.make_query(filter or "", version) | 24 | local query = search.make_query(filter or "", version) |
25 | query.exact_name = false | 25 | query.exact_name = false |
26 | for _, tree in ipairs(cfg.rocks_trees) do | 26 | for _, tree in ipairs(cfg.rocks_trees) do |
27 | search.manifest_search(results, dir.path(tree, "rocks"), query) | 27 | search.manifest_search(results, path.rocks_dir(tree), query) |
28 | end | 28 | end |
29 | print() | 29 | print() |
30 | print("Installed rocks:") | 30 | print("Installed rocks:") |
diff --git a/src/luarocks/make_manifest.lua b/src/luarocks/make_manifest.lua index 6edbd14b..622c21a0 100644 --- a/src/luarocks/make_manifest.lua +++ b/src/luarocks/make_manifest.lua | |||
@@ -23,10 +23,10 @@ function run(repo) | |||
23 | 23 | ||
24 | print("Making manifest for "..repo) | 24 | print("Making manifest for "..repo) |
25 | 25 | ||
26 | ok = manif.make_manifest(repo) | 26 | ok, err = manif.make_manifest(repo) |
27 | if ok then | 27 | if ok then |
28 | print("Generating index.html for "..repo) | 28 | print("Generating index.html for "..repo) |
29 | manif.make_index(repo) | 29 | manif.make_index(repo) |
30 | end | 30 | end |
31 | return ok | 31 | return ok, err |
32 | end | 32 | end |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 74289ee5..5f4e60a9 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -28,20 +28,31 @@ local function rename_module(file, pkgid) | |||
28 | return dir.path(path, pkgid.."-"..name) | 28 | return dir.path(path, pkgid.."-"..name) |
29 | end | 29 | end |
30 | 30 | ||
31 | local function make_global_lib(repo, manifest) | 31 | local function update_global_lib(repo, manifest) |
32 | local lib_dir = dir.path(dir.dir_name(repo), "lib") | 32 | fs.make_dir(cfg.lua_modules_dir) |
33 | fs.make_dir(lib_dir) | 33 | fs.make_dir(cfg.bin_modules_dir) |
34 | for rock, modules in pairs(manifest.modules) do | 34 | for rock, modules in pairs(manifest.modules) do |
35 | for module, file in pairs(modules) do | 35 | for module, file in pairs(modules) do |
36 | if not file:match("^"..lib_dir) then | 36 | local module_type, modules_dir |
37 | |||
38 | if file:match("%."..cfg.lua_extension.."$") then | ||
39 | module_type = "lua" | ||
40 | modules_dir = cfg.lua_modules_dir | ||
41 | else | ||
42 | module_type = "bin" | ||
43 | modules_dir = cfg.bin_modules_dir | ||
44 | end | ||
45 | |||
46 | if not file:match("^"..modules_dir) then | ||
37 | local path_in_rock = dir.strip_base_dir(file:sub(#dir.path(repo, module)+2)) | 47 | local path_in_rock = dir.strip_base_dir(file:sub(#dir.path(repo, module)+2)) |
38 | local module_dir = dir.dir_name(path_in_rock) | 48 | local module_dir = dir.dir_name(path_in_rock) |
39 | local dest = dir.path(lib_dir, path_in_rock) | 49 | local dest = dir.path(modules_dir, path_in_rock) |
40 | if module_dir ~= "" then | 50 | if module_dir ~= "" then |
41 | fs.make_dir(dir.dir_name(dest)) | 51 | fs.make_dir(dir.dir_name(dest)) |
42 | end | 52 | end |
43 | if not fs.exists(dest) then | 53 | if not fs.exists(dest) then |
44 | fs.copy(file, dest) | 54 | fs.move(file, dest) |
55 | fs.remove_dir_tree_if_empty(dir.dir_name(file)) | ||
45 | manifest.modules[rock][module] = dest | 56 | manifest.modules[rock][module] = dest |
46 | else | 57 | else |
47 | local current = find_module_at_file(dest, modules) | 58 | local current = find_module_at_file(dest, modules) |
@@ -55,14 +66,14 @@ local function make_global_lib(repo, manifest) | |||
55 | local ok, err = fs.move(dest, newname) | 66 | local ok, err = fs.move(dest, newname) |
56 | if ok then | 67 | if ok then |
57 | manifest.modules[rock][current] = newname | 68 | manifest.modules[rock][current] = newname |
58 | fs.copy(file, dest) | 69 | fs.move(file, dest) |
70 | fs.remove_dir_tree_if_empty(dir.dir_name(file)) | ||
59 | manifest.modules[rock][module] = dest | 71 | manifest.modules[rock][module] = dest |
60 | else | 72 | else |
61 | util.warning(err) | 73 | util.warning(err) |
62 | end | 74 | end |
63 | end | 75 | end |
64 | end | 76 | end |
65 | -- TODO | ||
66 | end | 77 | end |
67 | else | 78 | else |
68 | print("DBG file already in place.") | 79 | print("DBG file already in place.") |
@@ -275,7 +286,7 @@ function update_manifest(name, version, repo) | |||
275 | local results = {[name] = {[version] = {{arch = "installed", repo = repo}}}} | 286 | local results = {[name] = {[version] = {{arch = "installed", repo = repo}}}} |
276 | 287 | ||
277 | store_results(results, manifest) | 288 | store_results(results, manifest) |
278 | make_global_lib(repo, manifest) | 289 | update_global_lib(repo, manifest) |
279 | return save_manifest(repo, manifest) | 290 | return save_manifest(repo, manifest) |
280 | end | 291 | end |
281 | 292 | ||
@@ -299,10 +310,7 @@ function make_manifest(repo) | |||
299 | local manifest = { repository = {}, modules = {}, commands = {} } | 310 | local manifest = { repository = {}, modules = {}, commands = {} } |
300 | manif_core.manifest_cache[repo] = manifest | 311 | manif_core.manifest_cache[repo] = manifest |
301 | store_results(results, manifest) | 312 | store_results(results, manifest) |
302 | local lib_dir = dir.path(dir.dir_name(repo), "lib") | 313 | update_global_lib(repo, manifest) |
303 | -- TODO | ||
304 | fs.delete(lib_dir) | ||
305 | make_global_lib(repo, manifest) | ||
306 | return save_manifest(repo, manifest) | 314 | return save_manifest(repo, manifest) |
307 | end | 315 | end |
308 | 316 | ||
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index 7b1c68dd..4bfdb320 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua | |||
@@ -10,6 +10,7 @@ local fs = require("luarocks.fs") | |||
10 | local cfg = require("luarocks.cfg") | 10 | local cfg = require("luarocks.cfg") |
11 | local util = require("luarocks.util") | 11 | local util = require("luarocks.util") |
12 | local dir = require("luarocks.dir") | 12 | local dir = require("luarocks.dir") |
13 | local manif = require("luarocks.manif") | ||
13 | 14 | ||
14 | help_summary = "Create a rock, packing sources or binaries." | 15 | help_summary = "Create a rock, packing sources or binaries." |
15 | help_arguments = "{<rockspec>|<name> [<version>]}" | 16 | help_arguments = "{<rockspec>|<name> [<version>]}" |
@@ -81,10 +82,37 @@ local function pack_binary_rock(name, version) | |||
81 | if not fs.exists(prefix) then | 82 | if not fs.exists(prefix) then |
82 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." | 83 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." |
83 | end | 84 | end |
85 | |||
84 | local name_version = name .. "-" .. version | 86 | local name_version = name .. "-" .. version |
85 | local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") | 87 | local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") |
86 | fs.change_dir(prefix) | 88 | |
87 | if not rep.is_binary_rock(name, version) then | 89 | local temp_dir = fs.make_temp_dir("pack") |
90 | fs.copy_contents(prefix, temp_dir) | ||
91 | |||
92 | local is_binary = false | ||
93 | local manifest = manif.load_manifest(cfg.rocks_dir) | ||
94 | for module_name, module_data in pairs(manifest.modules) do | ||
95 | for package, file in pairs(module_data) do | ||
96 | if package == name.."/"..version then | ||
97 | local dest | ||
98 | if file:match("^"..cfg.lua_modules_dir) then | ||
99 | local pathname = file:sub(#cfg.lua_modules_dir + 1) | ||
100 | dest = dir.path(temp_dir, "lua", dir.dir_name(pathname)) | ||
101 | elseif file:match("^"..cfg.bin_modules_dir) then | ||
102 | local pathname = file:sub(#cfg.bin_modules_dir + 1) | ||
103 | dest = dir.path(temp_dir, "lib", dir.dir_name(pathname)) | ||
104 | is_binary = true | ||
105 | end | ||
106 | if dest then | ||
107 | fs.make_dir(dest) | ||
108 | fs.copy(file, dest) | ||
109 | end | ||
110 | end | ||
111 | end | ||
112 | end | ||
113 | |||
114 | fs.change_dir(temp_dir) | ||
115 | if not is_binary and not rep.has_binaries(name, version) then | ||
88 | rock_file = rock_file:gsub("%."..cfg.arch:gsub("%-","%%-").."%.", ".all.") | 116 | rock_file = rock_file:gsub("%."..cfg.arch:gsub("%-","%%-").."%.", ".all.") |
89 | end | 117 | end |
90 | fs.delete(rock_file) | 118 | fs.delete(rock_file) |
@@ -92,6 +120,7 @@ local function pack_binary_rock(name, version) | |||
92 | return nil, "Failed packing "..rock_file | 120 | return nil, "Failed packing "..rock_file |
93 | end | 121 | end |
94 | fs.pop_dir() | 122 | fs.pop_dir() |
123 | fs.delete(temp_dir) | ||
95 | return rock_file | 124 | return rock_file |
96 | end | 125 | end |
97 | 126 | ||
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index c9085431..fccabc99 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -16,115 +16,135 @@ function rockspec_name_from_rock(rock_name) | |||
16 | return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec" | 16 | return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec" |
17 | end | 17 | end |
18 | 18 | ||
19 | function rocks_dir(repo) | ||
20 | return dir.path(repo, "lib", "luarocks", "rocks") | ||
21 | end | ||
22 | |||
23 | function scripts_dir(repo) | ||
24 | return dir.path(repo, "bin") | ||
25 | end | ||
26 | |||
27 | function lua_modules_dir(repo) | ||
28 | return dir.path(repo, "share", "lua", "5.1") | ||
29 | end | ||
30 | |||
31 | function bin_modules_dir(repo) | ||
32 | return dir.path(repo, "lib", "lua", "5.1") | ||
33 | end | ||
34 | |||
35 | function manifest_file(repo) | ||
36 | return dir.path(repo, "lib", "luarocks", "rocks", "manifest") | ||
37 | end | ||
38 | |||
19 | --- Get the repository directory for all versions of a package. | 39 | --- Get the repository directory for all versions of a package. |
20 | -- @param name string: The package name. | 40 | -- @param name string: The package name. |
21 | -- @return string: The resulting path -- does not guarantee that | 41 | -- @return string: The resulting path -- does not guarantee that |
22 | -- @param repo string or nil: If given, specifies the local repository to use. | 42 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
23 | -- the package (and by extension, the path) exists. | 43 | -- the package (and by extension, the path) exists. |
24 | function versions_dir(name, repo) | 44 | function versions_dir(name, rocks_dir) |
25 | assert(type(name) == "string") | 45 | assert(type(name) == "string") |
26 | assert(not repo or type(repo) == "string") | 46 | assert(not rocks_dir or type(rocks_dir) == "string") |
27 | 47 | ||
28 | return dir.path(repo or cfg.rocks_dir, name) | 48 | return dir.path(rocks_dir or cfg.rocks_dir, name) |
29 | end | 49 | end |
30 | 50 | ||
31 | --- Get the local installation directory (prefix) for a package. | 51 | --- Get the local installation directory (prefix) for a package. |
32 | -- @param name string: The package name. | 52 | -- @param name string: The package name. |
33 | -- @param version string: The package version. | 53 | -- @param version string: The package version. |
34 | -- @param repo string or nil: If given, specifies the local repository to use. | 54 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
35 | -- @return string: The resulting path -- does not guarantee that | 55 | -- @return string: The resulting path -- does not guarantee that |
36 | -- the package (and by extension, the path) exists. | 56 | -- the package (and by extension, the path) exists. |
37 | function install_dir(name, version, repo) | 57 | function install_dir(name, version, rocks_dir) |
38 | assert(type(name) == "string") | 58 | assert(type(name) == "string") |
39 | assert(type(version) == "string") | 59 | assert(type(version) == "string") |
40 | assert(not repo or type(repo) == "string") | 60 | assert(not rocks_dir or type(rocks_dir) == "string") |
41 | 61 | ||
42 | return dir.path(repo or cfg.rocks_dir, name, version) | 62 | return dir.path(rocks_dir or cfg.rocks_dir, name, version) |
43 | end | 63 | end |
44 | 64 | ||
45 | --- Get the local filename of the rockspec of an installed rock. | 65 | --- Get the local filename of the rockspec of an installed rock. |
46 | -- @param name string: The package name. | 66 | -- @param name string: The package name. |
47 | -- @param version string: The package version. | 67 | -- @param version string: The package version. |
48 | -- @param repo string or nil: If given, specifies the local repository to use. | 68 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
49 | -- @return string: The resulting path -- does not guarantee that | 69 | -- @return string: The resulting path -- does not guarantee that |
50 | -- the package (and by extension, the file) exists. | 70 | -- the package (and by extension, the file) exists. |
51 | function rockspec_file(name, version, repo) | 71 | function rockspec_file(name, version, rocks_dir) |
52 | assert(type(name) == "string") | 72 | assert(type(name) == "string") |
53 | assert(type(version) == "string") | 73 | assert(type(version) == "string") |
54 | assert(not repo or type(repo) == "string") | 74 | assert(not rocks_dir or type(rocks_dir) == "string") |
55 | 75 | ||
56 | return dir.path(repo or cfg.rocks_dir, name, version, name.."-"..version..".rockspec") | 76 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, name.."-"..version..".rockspec") |
57 | end | 77 | end |
58 | 78 | ||
59 | --- Get the local installation directory for C libraries of a package. | 79 | --- Get the local installation directory for C libraries of a package. |
60 | -- @param name string: The package name. | 80 | -- @param name string: The package name. |
61 | -- @param version string: The package version. | 81 | -- @param version string: The package version. |
62 | -- @param repo string or nil: If given, specifies the local repository to use. | 82 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
63 | -- @return string: The resulting path -- does not guarantee that | 83 | -- @return string: The resulting path -- does not guarantee that |
64 | -- the package (and by extension, the path) exists. | 84 | -- the package (and by extension, the path) exists. |
65 | function lib_dir(name, version, repo) | 85 | function lib_dir(name, version, rocks_dir) |
66 | assert(type(name) == "string") | 86 | assert(type(name) == "string") |
67 | assert(type(version) == "string") | 87 | assert(type(version) == "string") |
68 | assert(not repo or type(repo) == "string") | 88 | assert(not rocks_dir or type(rocks_dir) == "string") |
69 | 89 | ||
70 | return dir.path(repo or cfg.rocks_dir, name, version, "lib") | 90 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, "lib") |
71 | end | 91 | end |
72 | 92 | ||
73 | --- Get the local installation directory for Lua modules of a package. | 93 | --- Get the local installation directory for Lua modules of a package. |
74 | -- @param name string: The package name. | 94 | -- @param name string: The package name. |
75 | -- @param version string: The package version. | 95 | -- @param version string: The package version. |
76 | -- @param repo string or nil: If given, specifies the local repository to use. | 96 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
77 | -- @return string: The resulting path -- does not guarantee that | 97 | -- @return string: The resulting path -- does not guarantee that |
78 | -- the package (and by extension, the path) exists. | 98 | -- the package (and by extension, the path) exists. |
79 | function lua_dir(name, version, repo) | 99 | function lua_dir(name, version, rocks_dir) |
80 | assert(type(name) == "string") | 100 | assert(type(name) == "string") |
81 | assert(type(version) == "string") | 101 | assert(type(version) == "string") |
82 | assert(not repo or type(repo) == "string") | 102 | assert(not rocks_dir or type(rocks_dir) == "string") |
83 | 103 | ||
84 | return dir.path(repo or cfg.rocks_dir, name, version, "lua") | 104 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, "lua") |
85 | end | 105 | end |
86 | 106 | ||
87 | --- Get the local installation directory for documentation of a package. | 107 | --- Get the local installation directory for documentation of a package. |
88 | -- @param name string: The package name. | 108 | -- @param name string: The package name. |
89 | -- @param version string: The package version. | 109 | -- @param version string: The package version. |
90 | -- @param repo string or nil: If given, specifies the local repository to use. | 110 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
91 | -- @return string: The resulting path -- does not guarantee that | 111 | -- @return string: The resulting path -- does not guarantee that |
92 | -- the package (and by extension, the path) exists. | 112 | -- the package (and by extension, the path) exists. |
93 | function doc_dir(name, version, repo) | 113 | function doc_dir(name, version, rocks_dir) |
94 | assert(type(name) == "string") | 114 | assert(type(name) == "string") |
95 | assert(type(version) == "string") | 115 | assert(type(version) == "string") |
96 | assert(not repo or type(repo) == "string") | 116 | assert(not rocks_dir or type(rocks_dir) == "string") |
97 | 117 | ||
98 | return dir.path(repo or cfg.rocks_dir, name, version, "doc") | 118 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, "doc") |
99 | end | 119 | end |
100 | 120 | ||
101 | --- Get the local installation directory for configuration files of a package. | 121 | --- Get the local installation directory for configuration files of a package. |
102 | -- @param name string: The package name. | 122 | -- @param name string: The package name. |
103 | -- @param version string: The package version. | 123 | -- @param version string: The package version. |
104 | -- @param repo string or nil: If given, specifies the local repository to use. | 124 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
105 | -- @return string: The resulting path -- does not guarantee that | 125 | -- @return string: The resulting path -- does not guarantee that |
106 | -- the package (and by extension, the path) exists. | 126 | -- the package (and by extension, the path) exists. |
107 | function conf_dir(name, version, repo) | 127 | function conf_dir(name, version, rocks_dir) |
108 | assert(type(name) == "string") | 128 | assert(type(name) == "string") |
109 | assert(type(version) == "string") | 129 | assert(type(version) == "string") |
110 | assert(not repo or type(repo) == "string") | 130 | assert(not rocks_dir or type(rocks_dir) == "string") |
111 | 131 | ||
112 | return dir.path(repo or cfg.rocks_dir, name, version, "conf") | 132 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, "conf") |
113 | end | 133 | end |
114 | 134 | ||
115 | --- Get the local installation directory for command-line scripts | 135 | --- Get the local installation directory for command-line scripts |
116 | -- of a package. | 136 | -- of a package. |
117 | -- @param name string: The package name. | 137 | -- @param name string: The package name. |
118 | -- @param version string: The package version. | 138 | -- @param version string: The package version. |
119 | -- @param repo string or nil: If given, specifies the local repository to use. | 139 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
120 | -- @return string: The resulting path -- does not guarantee that | 140 | -- @return string: The resulting path -- does not guarantee that |
121 | -- the package (and by extension, the path) exists. | 141 | -- the package (and by extension, the path) exists. |
122 | function bin_dir(name, version, repo) | 142 | function bin_dir(name, version, rocks_dir) |
123 | assert(type(name) == "string") | 143 | assert(type(name) == "string") |
124 | assert(type(version) == "string") | 144 | assert(type(version) == "string") |
125 | assert(not repo or type(repo) == "string") | 145 | assert(not rocks_dir or type(rocks_dir) == "string") |
126 | 146 | ||
127 | return dir.path(repo or cfg.rocks_dir, name, version, "bin") | 147 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, "bin") |
128 | end | 148 | end |
129 | 149 | ||
130 | --- Extract name, version and arch of a rock filename. | 150 | --- Extract name, version and arch of a rock filename. |
diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index d7162336..ba70f53e 100644 --- a/src/luarocks/remove.lua +++ b/src/luarocks/remove.lua | |||
@@ -101,7 +101,7 @@ local function delete_versions(name, versions) | |||
101 | return true | 101 | return true |
102 | end | 102 | end |
103 | 103 | ||
104 | --- Driver function for the "install" command. | 104 | --- Driver function for the "remove" command. |
105 | -- @param name string: name of a rock. If a version is given, refer to | 105 | -- @param name string: name of a rock. If a version is given, refer to |
106 | -- a specific version; otherwise, try to remove all versions. | 106 | -- a specific version; otherwise, try to remove all versions. |
107 | -- @param version string: When passing a package name, a version number | 107 | -- @param version string: When passing a package name, a version number |
@@ -117,6 +117,8 @@ function run(...) | |||
117 | local results = {} | 117 | local results = {} |
118 | search.manifest_search(results, cfg.rocks_dir, search.make_query(name, version)) | 118 | search.manifest_search(results, cfg.rocks_dir, search.make_query(name, version)) |
119 | 119 | ||
120 | print("remove functionality is currently broken") | ||
121 | --[[ | ||
120 | local versions = results[name] | 122 | local versions = results[name] |
121 | if not versions then | 123 | if not versions then |
122 | return nil, "Could not find rock '"..name..(version and " "..version or "").."' in local tree." | 124 | return nil, "Could not find rock '"..name..(version and " "..version or "").."' in local tree." |
@@ -139,10 +141,11 @@ function run(...) | |||
139 | print() | 141 | print() |
140 | end | 142 | end |
141 | local ok, err1 = delete_versions(name, versions) | 143 | local ok, err1 = delete_versions(name, versions) |
142 | local ok, err2 = manif.make_manifest(cfg.rocks_dir) | 144 | -- FIXME |
143 | if err1 or err2 then | 145 | -- local ok, err2 = manif.make_manifest(cfg.rocks_dir) |
144 | return nil, err1 or err2 | 146 | -- if err1 or err2 then |
145 | end | 147 | -- return nil, err1 or err2 |
148 | -- end | ||
146 | else | 149 | else |
147 | if not second then | 150 | if not second then |
148 | print("Will not remove "..name.." "..version..".") | 151 | print("Will not remove "..name.." "..version..".") |
@@ -159,5 +162,6 @@ function run(...) | |||
159 | return nil, "Failed removing." | 162 | return nil, "Failed removing." |
160 | end | 163 | end |
161 | end | 164 | end |
165 | ]] | ||
162 | return true | 166 | return true |
163 | end | 167 | end |
diff --git a/src/luarocks/rep.lua b/src/luarocks/rep.lua index 392c4353..2c7659c1 100644 --- a/src/luarocks/rep.lua +++ b/src/luarocks/rep.lua | |||
@@ -143,17 +143,13 @@ function package_commands(package, version) | |||
143 | return result | 143 | return result |
144 | end | 144 | end |
145 | 145 | ||
146 | --- Check if a rock contains binary parts or if it is pure Lua. | 146 | --- Check if a rock contains binary executables. |
147 | -- @param name string: name of an installed rock | 147 | -- @param name string: name of an installed rock |
148 | -- @param version string: version of an installed rock | 148 | -- @param version string: version of an installed rock |
149 | -- @return boolean: returns true if rock contains platform-specific | 149 | -- @return boolean: returns true if rock contains platform-specific |
150 | -- binary code, or false if it is a pure-Lua rock. | 150 | -- binary executables, or false if it is a pure-Lua rock. |
151 | function is_binary_rock(name, version) | 151 | function has_binaries(name, version) |
152 | local bin_dir = path.bin_dir(name, version) | 152 | local bin_dir = path.bin_dir(name, version) |
153 | local lib_dir = path.lib_dir(name, version) | ||
154 | if fs.exists(lib_dir) then | ||
155 | return true | ||
156 | end | ||
157 | if fs.exists(bin_dir) then | 153 | if fs.exists(bin_dir) then |
158 | for _, name in pairs(fs.find(bin_dir)) do | 154 | for _, name in pairs(fs.find(bin_dir)) do |
159 | if fs.is_actual_binary(dir.path(bin_dir, name)) then | 155 | if fs.is_actual_binary(dir.path(bin_dir, name)) then |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 5686d0cf..6e9c3547 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -127,9 +127,7 @@ local var_format_pattern = "%$%((%a[%a%d_]+)%)" | |||
127 | --- Display a warning message. | 127 | --- Display a warning message. |
128 | -- @param msg string: the warning message | 128 | -- @param msg string: the warning message |
129 | function warning(msg) | 129 | function warning(msg) |
130 | print() | ||
131 | print("Warning: "..msg) | 130 | print("Warning: "..msg) |
132 | print() | ||
133 | end | 131 | end |
134 | 132 | ||
135 | --- Create a new shallow copy of a table: a new table with | 133 | --- Create a new shallow copy of a table: a new table with |
diff --git a/src/luarocks/validate.lua b/src/luarocks/validate.lua index 36163afe..fdcfd7c8 100644 --- a/src/luarocks/validate.lua +++ b/src/luarocks/validate.lua | |||
@@ -3,6 +3,7 @@ module("luarocks.validate", package.seeall) | |||
3 | 3 | ||
4 | local fs = require("luarocks.fs") | 4 | local fs = require("luarocks.fs") |
5 | local dir = require("luarocks.dir") | 5 | local dir = require("luarocks.dir") |
6 | local path = require("luarocks.path") | ||
6 | local cfg = require("luarocks.cfg") | 7 | local cfg = require("luarocks.cfg") |
7 | local build = require("luarocks.build") | 8 | local build = require("luarocks.build") |
8 | local install = require("luarocks.install") | 9 | local install = require("luarocks.install") |
@@ -36,7 +37,7 @@ end | |||
36 | local function prepare_sandbox(file) | 37 | local function prepare_sandbox(file) |
37 | local root_dir = fs.make_temp_dir(file):gsub("/+$", "") | 38 | local root_dir = fs.make_temp_dir(file):gsub("/+$", "") |
38 | cfg.root_dir = root_dir | 39 | cfg.root_dir = root_dir |
39 | cfg.rocks_dir = root_dir.."/rocks" | 40 | cfg.rocks_dir = path.rocks_dir(root_dir) |
40 | cfg.scripts_dir = root_dir.."/bin" | 41 | cfg.scripts_dir = root_dir.."/bin" |
41 | cfg.variables.ROCKS_TREE = cfg.root_dir | 42 | cfg.variables.ROCKS_TREE = cfg.root_dir |
42 | cfg.variables.SCRIPTS_DIR = cfg.scripts_dir | 43 | cfg.variables.SCRIPTS_DIR = cfg.scripts_dir |