Added support for configuration to Roc.
The installer can now use a roc.cfg file to define the various needed modules.
Format:
{ "name": "demo", "location": ".",
"modules": {
"foo": { "location": "path-to-source-of-module-foo"; },
"bar": { "location": "path-to-source-of-module-bar"; }
}
}
This commit is contained in:
24
tools/roc/roc.cfg-example
Normal file
24
tools/roc/roc.cfg-example
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "demo",
|
||||||
|
"project": "demo-safe.ecf",
|
||||||
|
"location": ".",
|
||||||
|
"site_directory": "site",
|
||||||
|
"modules": {
|
||||||
|
"admin": { "location": "../../modules/admin" },
|
||||||
|
"auth": { "location": "../../modules/auth" },
|
||||||
|
"basic_auth": { "location": "../../modules/basic_auth" },
|
||||||
|
"blog": { "location": "../../modules/blog" },
|
||||||
|
"contact": { "location": "../../modules/contact" },
|
||||||
|
"feed_aggregator": { "location": "../../modules/feed_aggregator" },
|
||||||
|
"google_search": { "location": "../../modules/google_search" },
|
||||||
|
"node": { "location": "../../modules/node" },
|
||||||
|
"oauth20": { "location": "../../modules/oauth20" },
|
||||||
|
"openid": { "location": "../../modules/openid" },
|
||||||
|
"recent_changes": { "location": "../../modules/recent_changes" },
|
||||||
|
"seo": { "location": "../../modules/seo" },
|
||||||
|
"session_auth": { "location": "../../modules/session_auth" },
|
||||||
|
"taxonomy": { "location": "../../modules/taxonomy" },
|
||||||
|
"files": { "location": "../../modules/files" },
|
||||||
|
"custom_block": { "location": "../../modules/custom_block" }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="roc" uuid="10B0F9A7-B711-419B-A1B5-833EB61DF8A6">
|
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-16-0 http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" name="roc" uuid="10B0F9A7-B711-419B-A1B5-833EB61DF8A6">
|
||||||
<target name="roc">
|
<target name="roc">
|
||||||
<root class="APPLICATION" feature="make"/>
|
<root class="APPLICATION" feature="make"/>
|
||||||
<option warning="true" void_safety="all">
|
<option warning="true" is_obsolete_routine_type="true">
|
||||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||||
</option>
|
</option>
|
||||||
<setting name="console_application" value="true"/>
|
<setting name="console_application" value="true"/>
|
||||||
|
<capability>
|
||||||
|
<concurrency support="none"/>
|
||||||
|
<void_safety support="all"/>
|
||||||
|
</capability>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="encoding" location="$ISE_LIBRARY\library\encoding\encoding-safe.ecf"/>
|
<library name="encoding" location="$ISE_LIBRARY\library\encoding\encoding-safe.ecf"/>
|
||||||
|
<library name="config" location="../../library/configuration/config-safe.ecf"/>
|
||||||
<cluster name="roc" location=".\" recursive="true">
|
<cluster name="roc" location=".\" recursive="true">
|
||||||
<file_rule>
|
<file_rule>
|
||||||
<exclude>/EIFGENs$</exclude>
|
|
||||||
<exclude>/CVS$</exclude>
|
|
||||||
<exclude>/.svn$</exclude>
|
<exclude>/.svn$</exclude>
|
||||||
|
<exclude>/CVS$</exclude>
|
||||||
|
<exclude>/EIFGENs$</exclude>
|
||||||
</file_rule>
|
</file_rule>
|
||||||
</cluster>
|
</cluster>
|
||||||
</target>
|
</target>
|
||||||
|
|||||||
@@ -26,17 +26,22 @@ feature -- Status report
|
|||||||
local
|
local
|
||||||
i, n: INTEGER
|
i, n: INTEGER
|
||||||
optional_module: BOOLEAN
|
optional_module: BOOLEAN
|
||||||
|
optional_config: BOOLEAN
|
||||||
cms_path: BOOLEAN
|
cms_path: BOOLEAN
|
||||||
do
|
do
|
||||||
n := args.upper
|
n := args.upper
|
||||||
-- TODO add error reporting.
|
-- TODO add error reporting.
|
||||||
if n >= 1 and then n <= 4 then
|
if n >= 1 and then n <= 5 then
|
||||||
from
|
from
|
||||||
i := 1
|
i := 1
|
||||||
until
|
until
|
||||||
i > n
|
i > n
|
||||||
loop
|
loop
|
||||||
if args [i].same_string ("-m") then
|
if args [i].same_string ("-f") then
|
||||||
|
optional_config := True
|
||||||
|
elseif args [i].same_string ("--config") then
|
||||||
|
optional_config := True
|
||||||
|
elseif args [i].same_string ("-m") then
|
||||||
optional_module := True
|
optional_module := True
|
||||||
elseif args [i].same_string ("--module") then
|
elseif args [i].same_string ("--module") then
|
||||||
optional_module := True
|
optional_module := True
|
||||||
@@ -47,14 +52,17 @@ feature -- Status report
|
|||||||
end
|
end
|
||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
if n = 4 then
|
if optional_config then
|
||||||
if (cms_path and optional_module) then
|
Result := True
|
||||||
|
else
|
||||||
|
if n <= 5 then
|
||||||
|
if (cms_path and (optional_module)) then
|
||||||
-- valid command
|
-- valid command
|
||||||
Result := True
|
Result := True
|
||||||
else
|
else
|
||||||
print ("Error check the optional argument --module|-m and --dir|-d")
|
print ("Error check the optional argument --module|-m and --dir|-d")
|
||||||
end
|
end
|
||||||
elseif n = 2 then
|
elseif n <= 3 then
|
||||||
if (cms_path and not optional_module) then
|
if (cms_path and not optional_module) then
|
||||||
Result := True
|
Result := True
|
||||||
else
|
else
|
||||||
@@ -64,9 +72,10 @@ feature -- Status report
|
|||||||
else
|
else
|
||||||
Result := True
|
Result := True
|
||||||
end
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Result := False
|
Result := False
|
||||||
if n > 4 then
|
if n > 5 then
|
||||||
print ("Too many arguments")
|
print ("Too many arguments")
|
||||||
end
|
end
|
||||||
if n < 1 then
|
if n < 1 then
|
||||||
@@ -93,12 +102,14 @@ feature -- Execution
|
|||||||
-- Install a module into a cms application.
|
-- Install a module into a cms application.
|
||||||
-- Pattern: module_src/site/* => cms/site/modules/$module_name/*
|
-- Pattern: module_src/site/* => cms/site/modules/$module_name/*
|
||||||
local
|
local
|
||||||
l_site_path, l_cms_path, l_module_source_path: detachable PATH
|
l_config_path, l_site_path, l_cms_path, p: detachable PATH
|
||||||
|
l_module_source_locations: ARRAYED_LIST [PATH]
|
||||||
l_site_dir: DIRECTORY
|
l_site_dir: DIRECTORY
|
||||||
l_modules_dir: DIRECTORY
|
l_modules_dir: DIRECTORY
|
||||||
l_dest_dir: DIRECTORY
|
l_dest_dir: DIRECTORY
|
||||||
i,n: INTEGER
|
i,n: INTEGER
|
||||||
do
|
do
|
||||||
|
create l_module_source_locations.make (1)
|
||||||
from
|
from
|
||||||
i := 1
|
i := 1
|
||||||
n := args.upper
|
n := args.upper
|
||||||
@@ -107,6 +118,14 @@ feature -- Execution
|
|||||||
loop
|
loop
|
||||||
if attached args[i] as arg then
|
if attached args[i] as arg then
|
||||||
if
|
if
|
||||||
|
arg.same_string ("-f")
|
||||||
|
or arg.same_string ("--config")
|
||||||
|
then
|
||||||
|
i := i + 1
|
||||||
|
if i <= n then
|
||||||
|
create l_config_path.make_from_string (args[i])
|
||||||
|
end
|
||||||
|
elseif
|
||||||
arg.same_string ("-d")
|
arg.same_string ("-d")
|
||||||
or arg.same_string ("--dir")
|
or arg.same_string ("--dir")
|
||||||
then
|
then
|
||||||
@@ -127,28 +146,75 @@ feature -- Execution
|
|||||||
then
|
then
|
||||||
i := i + 1
|
i := i + 1
|
||||||
if i <= n then
|
if i <= n then
|
||||||
create l_module_source_path.make_from_string (args[i])
|
l_module_source_locations.force (create {PATH}.make_from_string (args[i]))
|
||||||
end
|
end
|
||||||
|
elseif
|
||||||
|
arg.same_string ("-v")
|
||||||
|
or arg.same_string ("--verbose")
|
||||||
|
then
|
||||||
|
is_verbose := True
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
if l_module_source_path = Void then
|
|
||||||
l_module_source_path := Execution_environment.current_working_path
|
if l_config_path /= Void and then attached {CONFIG_READER} roc_configuration (l_config_path) as cfg then
|
||||||
|
if attached cfg.resolved_text_item ("location") as cfg_location then
|
||||||
|
create p.make_from_string (cfg_location)
|
||||||
|
if not p.is_absolute then
|
||||||
|
p := l_config_path.parent.extended_path (p)
|
||||||
end
|
end
|
||||||
|
l_cms_path := p.canonical_path
|
||||||
|
end
|
||||||
|
if l_cms_path = Void then
|
||||||
|
l_cms_path := l_config_path.parent
|
||||||
|
end
|
||||||
|
|
||||||
|
if attached cfg.resolved_text_item ("site_directory") as cfg_site_dir then
|
||||||
|
create p.make_from_string (cfg_site_dir)
|
||||||
|
if not p.is_absolute then
|
||||||
|
p := l_cms_path.extended_path (p)
|
||||||
|
end
|
||||||
|
l_site_path := p.canonical_path
|
||||||
|
end
|
||||||
|
if attached cfg.resolved_text_table_item ("modules") as tb then
|
||||||
|
across
|
||||||
|
tb as ic
|
||||||
|
loop
|
||||||
|
l_module_source_locations.extend (create {PATH}.make_from_string (ic.item))
|
||||||
|
end
|
||||||
|
elseif attached cfg.table_keys ("modules") as tb_keys then
|
||||||
|
across
|
||||||
|
tb_keys as ic
|
||||||
|
loop
|
||||||
|
if attached cfg.resolved_text_item ({STRING_32} "modules." + ic.item + ".location") as l_loc then
|
||||||
|
create p.make_from_string (l_loc)
|
||||||
|
if not p.is_absolute then
|
||||||
|
p := l_cms_path.extended_path (p)
|
||||||
|
end
|
||||||
|
l_module_source_locations.extend (p.canonical_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if l_cms_path = Void then
|
if l_cms_path = Void then
|
||||||
l_cms_path := Execution_environment.current_working_path.extended ("modules")
|
l_cms_path := Execution_environment.current_working_path.extended ("modules")
|
||||||
end
|
end
|
||||||
if l_cms_path /= Void and l_module_source_path /= Void then
|
|
||||||
-- If l_site_path is not set; initialize it to $cms_path/site.
|
-- If l_site_path is not set; initialize it to $cms_path/site.
|
||||||
if l_site_path = Void then
|
if l_site_path = Void then
|
||||||
l_site_path := l_cms_path.extended ("site")
|
l_site_path := l_cms_path.extended ("site").canonical_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
across
|
||||||
|
l_module_source_locations as ic
|
||||||
|
loop
|
||||||
|
if
|
||||||
|
attached ic.item as l_module_source_path and then
|
||||||
|
attached module_name (l_module_source_path) as l_mod_name
|
||||||
|
then
|
||||||
-- Install configuration files.
|
-- Install configuration files.
|
||||||
if attached module_name (l_module_source_path) as l_mod_name then
|
|
||||||
create l_site_dir.make_with_path (l_site_path)
|
create l_site_dir.make_with_path (l_site_path)
|
||||||
|
|
||||||
if l_site_dir.exists then
|
if l_site_dir.exists then
|
||||||
create l_modules_dir.make_with_path (l_site_path.extended ("modules"))
|
create l_modules_dir.make_with_path (l_site_path.extended ("modules"))
|
||||||
if not l_modules_dir.exists then
|
if not l_modules_dir.exists then
|
||||||
@@ -159,27 +225,37 @@ feature -- Execution
|
|||||||
if not l_dest_dir.exists then
|
if not l_dest_dir.exists then
|
||||||
l_dest_dir.create_dir
|
l_dest_dir.create_dir
|
||||||
end
|
end
|
||||||
|
print ("Install module ")
|
||||||
|
print (l_mod_name)
|
||||||
|
print (" in %"")
|
||||||
|
print (l_dest_dir.path.name)
|
||||||
|
print ("%":%N")
|
||||||
install_module_elements (l_module_source_path, l_dest_dir.path, Void)
|
install_module_elements (l_module_source_path, l_dest_dir.path, Void)
|
||||||
-- install_module_elements (l_module_source_path, l_dest_dir.path, Config_dir)
|
-- install_module_elements (l_module_source_path, l_dest_dir.path, Config_dir)
|
||||||
-- install_module_elements (l_module_source_path, l_dest_dir.path, Scripts_dir)
|
-- install_module_elements (l_module_source_path, l_dest_dir.path, Scripts_dir)
|
||||||
-- install_module_elements (l_module_source_path, l_dest_dir.path, Themes_dir)
|
-- install_module_elements (l_module_source_path, l_dest_dir.path, Themes_dir)
|
||||||
print ("Module ")
|
|
||||||
print (l_mod_name)
|
print (" - ")
|
||||||
print (" was successfuly installed to the CMS Application location ")
|
print (directories_count.out + " director" + if directories_count > 1 then "ies" else "y" end + ", ")
|
||||||
print (l_cms_path.name)
|
print (files_count.out + " file" + if files_count > 1 then "s" else "" end)
|
||||||
print ("%NCheck the module elements at ")
|
if files_changes_count > 0 then
|
||||||
print (l_dest_dir.path.name)
|
print (" (+" + files_changes_count.out + ")")
|
||||||
|
end
|
||||||
print (".%N")
|
print (".%N")
|
||||||
print ("Copied " + directories_count.out + " directories.%N")
|
|
||||||
print ("Copied " + files_count.out + " files.%N")
|
|
||||||
else
|
else
|
||||||
print ({STRING_32} "The CMS Application located at " + l_cms_path.name + "does not have the site or modules folders.%N")
|
print ({STRING_32} "The CMS Application located at " + l_cms_path.name + "does not have the site or modules folders.%N")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print ("Error: not possible to retrieve module name.%N")
|
print ("Error: could not retrieve module name.%N")
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
print ("Error: wrong path to CMS application.%N")
|
end
|
||||||
|
|
||||||
|
roc_configuration (a_cfg_location: PATH): detachable CONFIG_READER
|
||||||
|
do
|
||||||
|
create {JSON_CONFIG} Result.make_from_file (a_cfg_location)
|
||||||
|
if Result.has_error then
|
||||||
|
Result := Void
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -206,15 +282,23 @@ feature -- Execution
|
|||||||
end
|
end
|
||||||
files_count := 0
|
files_count := 0
|
||||||
directories_count := -1
|
directories_count := -1
|
||||||
|
files_changes_count := 0
|
||||||
|
|
||||||
copy_directory (l_src_dir, l_dest_dir, True)
|
copy_directory (l_src_dir, l_dest_dir, True)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
is_verbose: BOOLEAN
|
||||||
|
|
||||||
files_count: INTEGER
|
files_count: INTEGER
|
||||||
-- Number of copied files during installation.
|
-- Number of copied files during installation.
|
||||||
|
|
||||||
|
files_changes_count: INTEGER
|
||||||
|
-- Number of files changed during installation.
|
||||||
|
|
||||||
directories_count: INTEGER
|
directories_count: INTEGER
|
||||||
-- Number of copied directories during installation.
|
-- Number of copied directories during installation.
|
||||||
|
|
||||||
|
|
||||||
feature {NONE} -- System/copy files
|
feature {NONE} -- System/copy files
|
||||||
|
|
||||||
copy_directory (a_src: DIRECTORY; a_dest: DIRECTORY; is_recursive: BOOLEAN)
|
copy_directory (a_src: DIRECTORY; a_dest: DIRECTORY; is_recursive: BOOLEAN)
|
||||||
@@ -257,16 +341,25 @@ feature {NONE} -- System/copy files
|
|||||||
do
|
do
|
||||||
if not retried then
|
if not retried then
|
||||||
if attached a_file.path.entry as e then
|
if attached a_file.path.entry as e then
|
||||||
create l_dest.make_with_path (a_dir.extended_path (e))
|
|
||||||
l_dest.create_read_write
|
|
||||||
a_file.open_read
|
a_file.open_read
|
||||||
-- Copy file source to destination
|
-- Copy file source to destination
|
||||||
if
|
if
|
||||||
l_dest.exists and then
|
|
||||||
l_dest.is_writable and then
|
|
||||||
a_file.exists and then
|
a_file.exists and then
|
||||||
a_file.is_readable
|
a_file.is_access_readable
|
||||||
then
|
then
|
||||||
|
create l_dest.make_with_path (a_dir.extended_path (e))
|
||||||
|
if
|
||||||
|
not l_dest.exists or else
|
||||||
|
l_dest.is_writable
|
||||||
|
then
|
||||||
|
if not l_dest.exists or else (a_file.date > l_dest.date) then
|
||||||
|
files_changes_count := files_changes_count + 1
|
||||||
|
if is_verbose then
|
||||||
|
print ({STRING_32} " - file %"" + l_dest.path.name + "%"%N")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
l_dest.create_read_write
|
||||||
a_file.copy_to (l_dest)
|
a_file.copy_to (l_dest)
|
||||||
a_file.close
|
a_file.close
|
||||||
l_dest.close
|
l_dest.close
|
||||||
@@ -274,6 +367,7 @@ feature {NONE} -- System/copy files
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
rescue
|
rescue
|
||||||
retried := True
|
retried := True
|
||||||
retry
|
retry
|
||||||
@@ -292,6 +386,6 @@ feature {NONE} -- System/copy files
|
|||||||
|
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user