capistrano-typo3 0.2.4 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +8 -0
- data/CHANGELOG.md +7 -0
- data/README.md +11 -12
- data/capistrano-typo3.gemspec +3 -3
- data/docs/homestead_nl.md +164 -0
- data/docs/install_from_scratch.md +263 -0
- data/homestead_files/Vagrantfile +193 -0
- data/homestead_files/homestead.rb +35 -0
- data/homestead_files/vagrant.yml +62 -0
- data/lib/capistrano/tasks/git.cap +7 -0
- data/lib/capistrano/tasks/typo3.cap +303 -316
- data/lib/capistrano/typo3/dt3_div.rb +52 -0
- data/lib/capistrano/typo3/dt3_mysql.rb +179 -0
- data/lib/capistrano/typo3/typo3_helper.rb +481 -0
- data/lib/capistrano/typo3/version.rb +1 -1
- data/lib/capistrano/typo3.rb +7 -0
- metadata +16 -6
@@ -0,0 +1,52 @@
|
|
1
|
+
class DT3Div
|
2
|
+
def self.downloadTo(src_url,src_path,dest_filepath)
|
3
|
+
p src_url
|
4
|
+
p src_path
|
5
|
+
p dest_filepath
|
6
|
+
Net::HTTP.start(src_url) { |http2|
|
7
|
+
resp2 = http2.get(src_path)
|
8
|
+
open(dest_filepath, "w+") { |file2|
|
9
|
+
file2.write(resp2.body)
|
10
|
+
}
|
11
|
+
}
|
12
|
+
return true
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.checkValidDir(dir)
|
16
|
+
if dir!= '..' and dir != '.' and dir!= '.svn' and dir!= '.git'
|
17
|
+
return true
|
18
|
+
else
|
19
|
+
return false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.rmsymlink(symlink)
|
24
|
+
if File.symlink?( symlink )
|
25
|
+
FileUtils.rm_r( symlink )
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.hashlist_to_table_string(hashlist)
|
30
|
+
|
31
|
+
if(hashlist.count < 1)
|
32
|
+
return
|
33
|
+
end
|
34
|
+
|
35
|
+
table = Text::Table.new
|
36
|
+
table.head = []
|
37
|
+
table.rows = []
|
38
|
+
|
39
|
+
hashlist[0].each {|key,val|
|
40
|
+
table.head << key
|
41
|
+
}
|
42
|
+
hashlist.each {|keyd_row|
|
43
|
+
row = []
|
44
|
+
keyd_row.each {|key,val|
|
45
|
+
row << val
|
46
|
+
}
|
47
|
+
table.rows << row
|
48
|
+
}
|
49
|
+
|
50
|
+
return table.to_s
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
class DT3MySQL
|
2
|
+
|
3
|
+
def self.mysql_executable_dir
|
4
|
+
if fetch(:rake_mysql_exec_dir)
|
5
|
+
return fetch(:rake_mysql_exec_dir)
|
6
|
+
else
|
7
|
+
return '/usr/bin'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.flush_tables
|
12
|
+
tablelist = `#{self.create_mysql_base_command} -e "show tables" | grep -v Tables_in | grep -v "+"`
|
13
|
+
dropsql = ''
|
14
|
+
tablelist.split("\n").each {|table|
|
15
|
+
dropsql +="drop table #{table};"
|
16
|
+
}
|
17
|
+
self.mysql_execute(dropsql)
|
18
|
+
return true
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.show_tables
|
22
|
+
return self.mysql_execute('show tables')
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.truncate_table(table)
|
26
|
+
self.mysql_execute("TRUNCATE TABLE #{table};")
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.create_mysql_base_command_with(user,host,password,db,exec='mysql')
|
30
|
+
cmd = "#{self.mysql_executable_dir}/#{exec} -u#{user} -h#{host} -p#{password} #{db}"
|
31
|
+
return cmd
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.test_connection
|
35
|
+
stdout = self.mysql_execute('SHOW TABLES;')
|
36
|
+
if stdout.include? 'denied'
|
37
|
+
return false
|
38
|
+
else
|
39
|
+
return 1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.dump_db_version(name=nil, table_exclude_list=nil)
|
44
|
+
|
45
|
+
if not File.directory?(TYPO3_DB_DUMP_DIR)
|
46
|
+
FileUtils.mkdir TYPO3_DB_DUMP_DIR
|
47
|
+
end
|
48
|
+
|
49
|
+
filename =''
|
50
|
+
numbers = []
|
51
|
+
dbsettings = Typo3Helper::get_db_settings
|
52
|
+
|
53
|
+
if name
|
54
|
+
filename = File.join(TYPO3_DB_DUMP_DIR,"#{dbsettings['name']}-#{ENV['name']}.sql")
|
55
|
+
version = name
|
56
|
+
else
|
57
|
+
Dir.foreach(TYPO3_DB_DUMP_DIR) {|sql|
|
58
|
+
tmpname = sql.split('.')
|
59
|
+
if(tmpname.count == 3)
|
60
|
+
numbers << tmpname[1].to_i
|
61
|
+
end
|
62
|
+
}
|
63
|
+
if(numbers.count > 0)
|
64
|
+
version = (numbers.max + 1)
|
65
|
+
else
|
66
|
+
version = 1
|
67
|
+
end
|
68
|
+
|
69
|
+
filename = File.join(TYPO3_DB_DUMP_DIR,"#{dbsettings['name']}.#{version.to_s}.sql")
|
70
|
+
end
|
71
|
+
|
72
|
+
print "new image:#{dbsettings['name']} version:#{version}\n"
|
73
|
+
DT3MySQL::mysqldump_to(filename,table_exclude_list)
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.db_image_list
|
77
|
+
images_arr = []
|
78
|
+
idx = 0
|
79
|
+
|
80
|
+
Dir.glob("#{TYPO3_DB_DUMP_DIR}/*.sql").sort.each {|sql|
|
81
|
+
image = Hash.new
|
82
|
+
if File.extname(sql) == '.sql'
|
83
|
+
idx = idx+1
|
84
|
+
image['index'] = idx
|
85
|
+
|
86
|
+
image['filesize (Mb)'] = '%.2f' % (File.size(sql).to_f / 2**20)
|
87
|
+
|
88
|
+
|
89
|
+
if(sql.split('.').count == 3)
|
90
|
+
image['version'] = sql.split('.')[1]
|
91
|
+
image['name'] = File.basename(sql.split('.')[0])
|
92
|
+
elsif(sql.split('-').count == 2)
|
93
|
+
image['version'] = sql.split('-')[1].split('.')[0]
|
94
|
+
image['name'] = File.basename(sql.split('-')[0])
|
95
|
+
else
|
96
|
+
image['version'] = '[MASTER]'
|
97
|
+
image['name'] = File.basename(sql,'.*')
|
98
|
+
end
|
99
|
+
image['time'] = File.mtime(sql).strftime("%Y-%m-%d")
|
100
|
+
image['filename'] = sql
|
101
|
+
|
102
|
+
images_arr << image
|
103
|
+
end
|
104
|
+
}
|
105
|
+
return images_arr
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.create_exclude_list
|
109
|
+
|
110
|
+
table_exclude_list = %w( be_users be_sessions cache_* cf_* fe_session_data fe_sessions static_countries \
|
111
|
+
static_country_zones static_currencies static_languages static_territories sys_history sys_log tx_devlog \
|
112
|
+
zzz_deleted_* )
|
113
|
+
|
114
|
+
tables = self.show_tables
|
115
|
+
table_arr = tables.split("\n")
|
116
|
+
|
117
|
+
substr_arr = []
|
118
|
+
excltable_arr = []
|
119
|
+
realexclude_list = []
|
120
|
+
|
121
|
+
table_exclude_list.each {|excltable|
|
122
|
+
if(excltable.include? '*')
|
123
|
+
substr_arr << excltable[0,excltable.index('*')]
|
124
|
+
else
|
125
|
+
excltable_arr << excltable
|
126
|
+
end
|
127
|
+
}
|
128
|
+
|
129
|
+
table_arr.each {|table|
|
130
|
+
if(excltable_arr.include?(table))
|
131
|
+
realexclude_list << table
|
132
|
+
else
|
133
|
+
substr_arr.each {|substr|
|
134
|
+
if(table[0,substr.length] == substr)
|
135
|
+
realexclude_list << table
|
136
|
+
end
|
137
|
+
}
|
138
|
+
end
|
139
|
+
}
|
140
|
+
|
141
|
+
return realexclude_list.uniq
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.create_mysql_base_command(exec='mysql')
|
145
|
+
return self.create_mysql_base_command_with(fetch(:dbuser),fetch(:dbhost),fetch(:dbpass),fetch(:dbname),exec)
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.mysql_execute(sql)
|
149
|
+
"#{self.create_mysql_base_command} -e \"#{sql}\""
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.create_exclude_string(excludelist,db)
|
153
|
+
s = ''
|
154
|
+
excludelist.each {|extab|
|
155
|
+
if(s.length>0)
|
156
|
+
s += " "
|
157
|
+
end
|
158
|
+
s += "--ignore-table=#{db}.#{extab}"
|
159
|
+
}
|
160
|
+
return s
|
161
|
+
end
|
162
|
+
|
163
|
+
def self.mysqldump_to(outputfile,excludelist=nil,no_schema=nil)
|
164
|
+
|
165
|
+
if(not excludelist.nil?)
|
166
|
+
excludestring = self.create_exclude_string(excludelist,db)
|
167
|
+
else
|
168
|
+
excludestring = ''
|
169
|
+
end
|
170
|
+
|
171
|
+
cmd="#{create_mysql_base_command('mysqldump')} #{excludestring} > #{outputfile}"
|
172
|
+
system(cmd)
|
173
|
+
end
|
174
|
+
|
175
|
+
def self.mysql_import(user,pass,host,db,insqlfile)
|
176
|
+
cmd ="#{create_mysql_base_command} < #{insqlfile}"
|
177
|
+
system(cmd)
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,481 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Typo3Helper
|
5
|
+
|
6
|
+
def self.typo3_version_list
|
7
|
+
|
8
|
+
source = "https://get.typo3.org/json"
|
9
|
+
content = ""
|
10
|
+
open(source) do |s|
|
11
|
+
content = s.read
|
12
|
+
end
|
13
|
+
|
14
|
+
my_hash = JSON.parse(content)
|
15
|
+
_version_arr= []
|
16
|
+
|
17
|
+
my_hash.each do |k,v|
|
18
|
+
|
19
|
+
if(v['releases'])
|
20
|
+
|
21
|
+
v['releases'].each do |rel,relprops|
|
22
|
+
_version_arr << rel
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
return _version_arr.uniq.sort
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.get_typo3_versions
|
32
|
+
|
33
|
+
version_arr = self.typo3_version_list
|
34
|
+
return_string = ""
|
35
|
+
version_arr.each { |v|
|
36
|
+
return_string << "TYPO3 version: "+ v+ "\n"
|
37
|
+
}
|
38
|
+
|
39
|
+
return return_string
|
40
|
+
end
|
41
|
+
|
42
|
+
# from 4.7.12 it should return 12
|
43
|
+
def self.minor_version total_version
|
44
|
+
version_m = total_version.split "."
|
45
|
+
return version_m[2]
|
46
|
+
end
|
47
|
+
|
48
|
+
# from 4.7.12 it should return 4.7
|
49
|
+
def self.major_version total_version
|
50
|
+
version_m = total_version.split "."
|
51
|
+
return "#{version_m[0]}.#{version_m[1]}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.typo3_version_list_for_table
|
55
|
+
version_arr = []
|
56
|
+
idx = 0
|
57
|
+
versions_list_in = []
|
58
|
+
versions = Typo3Helper::get_typo3_versions
|
59
|
+
versions_list_in << Typo3Helper::last_minor_version(versions,'6.2')
|
60
|
+
versions_list_in << Typo3Helper::last_minor_version(versions,'7.0')
|
61
|
+
versions_list_in << Typo3Helper::last_minor_version(versions,'7.6')
|
62
|
+
versions_list_in << Typo3Helper::last_minor_version(versions,'8.1')
|
63
|
+
|
64
|
+
versions_list_in.each {|version_in|
|
65
|
+
idx = idx+1
|
66
|
+
version = Hash.new
|
67
|
+
version['index'] = idx
|
68
|
+
version['main version'] = self.major_version version_in
|
69
|
+
version['last minor version'] = version_in
|
70
|
+
|
71
|
+
version_arr << version
|
72
|
+
}
|
73
|
+
return version_arr
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.php_exexcutable
|
77
|
+
if(CONFIG['PHPEXEC'])
|
78
|
+
return CONFIG['PHPEXEC']
|
79
|
+
else
|
80
|
+
return 'php'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Get last minor version bases on configuration or argument, e.g 6.2 returns ATOW 6.2.9
|
85
|
+
def self.typo3_last_version(version=nil)
|
86
|
+
|
87
|
+
if version.nil?
|
88
|
+
version = CONFIG['TYPO3_MAIN_VERSION']
|
89
|
+
end
|
90
|
+
|
91
|
+
if version.split('.').count == 3
|
92
|
+
typo3_version = version
|
93
|
+
else
|
94
|
+
versions = self.get_typo3_versions
|
95
|
+
typo3_version = Typo3Helper::last_minor_version(versions,version.to_s)
|
96
|
+
end
|
97
|
+
|
98
|
+
return typo3_version
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.download_typo3_source version
|
102
|
+
|
103
|
+
tarball= "typo3source/typo3_src-#{version}.tar.gz"
|
104
|
+
|
105
|
+
unless File.directory?('typo3source')
|
106
|
+
FileUtils.mkdir('typo3source')
|
107
|
+
end
|
108
|
+
|
109
|
+
unless File.exist?(tarball)
|
110
|
+
if(CONFIG['TYPO3_ALTERNATIVE_SOURCE_URL'])
|
111
|
+
altsrc = CONFIG['TYPO3_ALTERNATIVE_SOURCE_URL']
|
112
|
+
srcurl = altsrc[7..(altsrc.index('/',8)-1)]
|
113
|
+
srcpath = altsrc[(altsrc.index('/',8))..-1]
|
114
|
+
version = altsrc[altsrc.index('typo3_src-')+10,6]
|
115
|
+
|
116
|
+
DT3Div::downloadTo(srcurl,srcpath,tarball)
|
117
|
+
else
|
118
|
+
srcurl = "get.typo3.org"
|
119
|
+
srcpath = "/#{version}"
|
120
|
+
|
121
|
+
DT3Div::downloadTo(srcurl,srcpath,tarball)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
if File.directory?(File.join('typo3source', "typo3_src-#{version}"))
|
126
|
+
FileUtils.rm_r(File.join('typo3source',"typo3_src-#{version}"))
|
127
|
+
end
|
128
|
+
system("tar xzf #{tarball} -C typo3source/")
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.last_minor_version(versions, majorversion)
|
132
|
+
list = []
|
133
|
+
versions.each_line do |line|
|
134
|
+
if(line[15,3]==majorversion)
|
135
|
+
if(line.chomp[19,2].to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/))
|
136
|
+
list << sprintf('%02d',line.chomp[19,2])
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
return majorversion+"."+list.sort.reverse[0].to_i.to_s
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.flush_config_cache()
|
144
|
+
system("rm -Rf current/dummy/typo3conf/temp_CACHED_*")
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.flush_cache()
|
148
|
+
system("rm -Rf current/dummy/typo3temp/*")
|
149
|
+
system("rm -Rf current/dummy/typo3conf/temp_CACHED_*")
|
150
|
+
end
|
151
|
+
|
152
|
+
#truncates a list of tables
|
153
|
+
def self.truncate_tables(tables)
|
154
|
+
|
155
|
+
all_current_tables = capture DT3MySQL::show_tables.split("\n")
|
156
|
+
|
157
|
+
tables.each do |table|
|
158
|
+
if all_current_tables.include?(table)
|
159
|
+
execute DT3MySQL::truncate_table(table)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.truncate_cache_tables()
|
165
|
+
cache_tables= %w(cache_extensions cache_hash cache_imagesizes cache_md5params cache_pages cache_pagesection cache_sys_dmail_stat cache_treelist cache_typo3temp_log cachingframework_cache_hash cachingframework_cache_hash_tags cachingframework_cache_pages cachingframework_cache_pages_tags cachingframework_cache_pagesection cachingframework_cache_pagesection_tags cf_cache_hash cf_cache_hash_tags cf_cache_pages cf_cache_pages_tags cf_cache_pagesection cf_cache_pagesection_tags cf_extbase_object cf_extbase_object_tags cf_extbase_reflection cf_extbase_reflection_tags cf_tt_news_cache cf_tt_news_cache_tags cf_tx_solr cf_tx_solr_tags tt_news_cache tt_news_cache_tags tx_realurl_chashcache tx_realurl_errorlog tx_realurl_pathcache tx_realurl_uniqalias tx_realurl_urldecodecache tx_realurl_urlencodecache tx_solr_cache tx_solr_cache_tags)
|
166
|
+
self.truncate_tables(cache_tables)
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.truncate_session_tables()
|
170
|
+
|
171
|
+
session_tables=%w(be_sessions fe_session_data fe_sessions)
|
172
|
+
self.truncate_tables(session_tables)
|
173
|
+
end
|
174
|
+
|
175
|
+
def self.get_db_settings
|
176
|
+
if(self.typo3_localconf_version == 6)
|
177
|
+
cmd = "php -r \'define(\"TYPO3_MODE\", \"BE\");$arr = include \"#{TYPO3_V6_LOCAL_CONF_PATH}\";echo \"{$arr[\"DB\"][\"username\"]} {$arr[\"DB\"][\"password\"]} {$arr[\"DB\"][\"host\"]} {$arr[\"DB\"][\"database\"]}\";\'"
|
178
|
+
elsif(self.typo3_localconf_version == 4)
|
179
|
+
cmd = "php -r \'define(\"TYPO3_MODE\", \"BE\");include \"#{TYPO3_V4_LOCAL_CONF_PATH}\";echo \"$typo_db_username $typo_db_password $typo_db_host $typo_db\";\'"
|
180
|
+
end
|
181
|
+
|
182
|
+
dbsettings =%x[ #{cmd} ].split(' ')
|
183
|
+
|
184
|
+
dbsetarr = {}
|
185
|
+
dbsetarr['name'] = dbsettings[3]
|
186
|
+
dbsetarr['host'] = dbsettings[2]
|
187
|
+
dbsetarr['user'] = dbsettings[0]
|
188
|
+
dbsetarr['password'] = dbsettings[1]
|
189
|
+
|
190
|
+
return dbsetarr
|
191
|
+
end
|
192
|
+
|
193
|
+
# replaces database settings in the localconf file
|
194
|
+
def self.make_set_localconf_database_settings_command(db,user,password,host='localhost')
|
195
|
+
cmd1 = "php -r \'define(\"TYPO3_MODE\", \"BE\");" \
|
196
|
+
"$arr = include \"#{fetch(:typo3_v6_local_conf_path)}\"; " \
|
197
|
+
"echo \"<?php\\n\";" \
|
198
|
+
"echo \"return \";" \
|
199
|
+
"$arr[\"DB\"][\"username\"]=\"#{user}\"; " \
|
200
|
+
"$arr[\"DB\"][\"database\"]=\"#{db}\";" \
|
201
|
+
"$arr[\"DB\"][\"password\"]=\"#{password}\";" \
|
202
|
+
"$arr[\"DB\"][\"host\"]=\"#{host}\";" \
|
203
|
+
"var_export($arr);" \
|
204
|
+
"echo \";\\n?>\";\'" \
|
205
|
+
"> #{fetch(:typo3_v6_local_conf_path)}.tmp"
|
206
|
+
cmd1
|
207
|
+
end
|
208
|
+
|
209
|
+
def self.set_v4_typo3_extconf_settings(extconfvars)
|
210
|
+
text = File.read(TYPO3_V4_LOCAL_CONF_PATH)
|
211
|
+
extconfvars.each do |key,arr|
|
212
|
+
|
213
|
+
typo3_conf_vars = "$TYPO3_CONF_VARS['EXT']['extConf']['#{key}'] = '#{PHP.serialize(arr).gsub("'", "\\\\'")}'; #{TYPO3_MODIFY_SIGNATURE}"
|
214
|
+
|
215
|
+
if text.include?("$TYPO3_CONF_VARS['EXT']['extConf']['#{key}']")
|
216
|
+
text = text.gsub(/^\$TYPO3_CONF_VARS\['EXT'\]\['extConf'\]\['#{key}'\].*/, typo3_conf_vars)
|
217
|
+
else
|
218
|
+
text = text.gsub(/^\?>/, typo3_conf_vars + "\n?>")
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
File.open(TYPO3_V4_LOCAL_CONF_PATH, "w") {|file| file.puts text}
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
def self.set_typo3_extconf_settings(extconfvars)
|
227
|
+
if(self.typo3_localconf_version == 4)
|
228
|
+
return set_v4_typo3_extconf_settings extconfvars
|
229
|
+
elsif(self.typo3_localconf_version == 6)
|
230
|
+
return set_v6_typo3_extconf_settings extconfvars
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
def self.set_v6_typo3_extconf_settings(extconfvars)
|
236
|
+
confVars = {}
|
237
|
+
confVars['EXT'] = {}
|
238
|
+
confVars['EXT']['extConf'] = {}
|
239
|
+
|
240
|
+
extconfvars.each do |key,arr|
|
241
|
+
confVars['EXT']['extConf'][key] = "#{PHP.serialize(arr).gsub("'", "\\\\'")}"
|
242
|
+
end
|
243
|
+
self.set_v6_typo3_conf_vars confVars
|
244
|
+
end
|
245
|
+
|
246
|
+
def self.set_v4_typo3_conf_vars(confvars)
|
247
|
+
text = File.read(TYPO3_V4_LOCAL_CONF_PATH)
|
248
|
+
|
249
|
+
confvars.each do |mainKey, mainHash|
|
250
|
+
mainHash.each do |key,var|
|
251
|
+
|
252
|
+
confstring = "$TYPO3_CONF_VARS['#{mainKey}']['#{key}'] = '#{var}'; #{TYPO3_MODIFY_SIGNATURE}"
|
253
|
+
|
254
|
+
if text.include?("$TYPO3_CONF_VARS['#{mainKey}']['#{key}']")
|
255
|
+
text = text.gsub(/^\$TYPO3_CONF_VARS\['#{mainKey}'\]\['#{key}'\].*/, confstring)
|
256
|
+
else
|
257
|
+
text = text.gsub(/^\?>/, confstring + "\n?>")
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
File.open(TYPO3_V4_LOCAL_CONF_PATH, "w") {|file| file.puts text}
|
263
|
+
end
|
264
|
+
|
265
|
+
def self.set_v6_typo3_conf_vars(confvars)
|
266
|
+
|
267
|
+
outfile = TYPO3_V6_LOCAL_CONF_PATH
|
268
|
+
|
269
|
+
confhash = self.get_v6_localconf_array
|
270
|
+
confjson = confhash.deep_merge!(confvars)
|
271
|
+
|
272
|
+
File.open('tmpjson', 'w') { |file| file.write(confjson.to_json) }
|
273
|
+
|
274
|
+
cmd = "php -r \'define(\"TYPO3_MODE\", \"BE\");echo \"<?php\\n\";echo \"return \";$contents = file_get_contents(\"./tmpjson\"); $arr = json_decode($contents);var_export($arr);echo \";\\n?>\";\'"
|
275
|
+
newphpconf = `#{cmd}`
|
276
|
+
|
277
|
+
newphpconf.gsub!('))',')')
|
278
|
+
newphpconf.gsub!('stdClass::__set_state(','')
|
279
|
+
|
280
|
+
cmd = "rm tmpjson"
|
281
|
+
system (cmd)
|
282
|
+
cmd = "cp #{outfile} #{outfile}.bak"
|
283
|
+
system (cmd)
|
284
|
+
|
285
|
+
File.open(outfile, 'w') { |file| file.write(newphpconf) }
|
286
|
+
end
|
287
|
+
|
288
|
+
def self.set_typo3_conf_vars(confvars)
|
289
|
+
if(confvars)
|
290
|
+
|
291
|
+
if(self.typo3_localconf_version == 6)
|
292
|
+
self.set_v6_typo3_conf_vars(confvars)
|
293
|
+
|
294
|
+
elsif(self.typo3_localconf_version == 4)
|
295
|
+
self.set_v4_typo3_conf_vars(confvars)
|
296
|
+
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
return true
|
301
|
+
end
|
302
|
+
|
303
|
+
def self.set_localconf_extlist(extList)
|
304
|
+
if(self.typo3_localconf_version == 4)
|
305
|
+
self.set_v4_localconf_extlist(extList)
|
306
|
+
elsif(self.typo3_localconf_version == 6)
|
307
|
+
self.set_v6_localconf_extlist(extList)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def self.set_v4_localconf_extlist(extList)
|
312
|
+
|
313
|
+
extList = Typo3Helper::get_v4_localconf_extlist('extList')
|
314
|
+
extList_fe = Typo3Helper::get_v4_localconf_extlist('extList_FE')
|
315
|
+
|
316
|
+
CONFIG['DISABLE_EXTENSIONS'].each do |delext|
|
317
|
+
extList.delete(delext)
|
318
|
+
extList_fe.delete(delext)
|
319
|
+
end
|
320
|
+
|
321
|
+
newconf= "$TYPO3_CONF_VARS['EXT']['extList'] = '#{extList.join(',')}'"
|
322
|
+
newconf_FE= "$TYPO3_CONF_VARS['EXT']['extList_FE'] = '#{extList_fe.join(',')}'"
|
323
|
+
|
324
|
+
text = File.read(TYPO3_V4_LOCAL_CONF_PATH)
|
325
|
+
text = text.gsub(/^\$TYPO3_CONF_VARS\['EXT'\]\['extList'\].*/, newconf+"; #{TYPO3_MODIFY_SIGNATURE}")
|
326
|
+
text = text.gsub(/^\$TYPO3_CONF_VARS\['EXT'\]\['extList_FE'\].*/, newconf_FE+"; #{TYPO3_MODIFY_SIGNATURE}")
|
327
|
+
|
328
|
+
File.open(TYPO3_V4_LOCAL_CONF_PATH, "w") {|file| file.puts text}
|
329
|
+
|
330
|
+
end
|
331
|
+
|
332
|
+
## Based on a list with extKeys it set the new active extensions
|
333
|
+
def self.set_v6_localconf_extlist(extList)
|
334
|
+
|
335
|
+
outfile = File.join('current','dummy','typo3conf','PackageStates.php')
|
336
|
+
confhash = self.get_v6_package_states
|
337
|
+
# require 'pp'
|
338
|
+
# PP.pp confhash
|
339
|
+
confhash['packages'].each do |extKey, extAttr|
|
340
|
+
if extList.include? extKey
|
341
|
+
extAttr['state']='active'
|
342
|
+
else
|
343
|
+
extAttr['state']='inactive'
|
344
|
+
end
|
345
|
+
confhash['packages'][extKey] = extAttr
|
346
|
+
end
|
347
|
+
|
348
|
+
File.open('tmpjson', 'w') { |file| file.write(confhash.to_json) }
|
349
|
+
|
350
|
+
cmd = "php -r \'define(\"TYPO3_MODE\", \"BE\");echo \"<?php\\n\";echo \"return \";$contents = file_get_contents(\"./tmpjson\");
|
351
|
+
$arr_unsorted = array();
|
352
|
+
$arr_sorted = array();
|
353
|
+
$arr_unsorted[\"packages\"] = array();
|
354
|
+
$arr_sorted[\"packages\"] = array();
|
355
|
+
$arr = json_decode($contents);
|
356
|
+
foreach($arr->packages as $key => $a){
|
357
|
+
if($key==\"core\") $arr_sorted[\"packages\"][$key] = $a;
|
358
|
+
else $arr_unsorted[\"packages\"][$key] = $a;
|
359
|
+
}
|
360
|
+
foreach($arr_unsorted[\"packages\"] as $key => $a){
|
361
|
+
$arr_sorted[\"packages\"][$key] = $a;
|
362
|
+
}
|
363
|
+
$arr->packages = $arr_sorted[\"packages\"];
|
364
|
+
var_export($arr);
|
365
|
+
echo \";\\n?>\";\'"
|
366
|
+
newphpconf = `#{cmd}`
|
367
|
+
|
368
|
+
newphpconf.gsub!('))',')')
|
369
|
+
newphpconf.gsub!('stdClass::__set_state(','')
|
370
|
+
|
371
|
+
cmd = "rm tmpjson"
|
372
|
+
system (cmd)
|
373
|
+
cmd = "cp #{outfile} #{outfile}.bak"
|
374
|
+
system (cmd)
|
375
|
+
|
376
|
+
File.open(outfile, 'w') { |file| file.write(newphpconf) }
|
377
|
+
end
|
378
|
+
|
379
|
+
def self.symlink_source version
|
380
|
+
system("rm -f #{File.join('current','dummy','typo3_src')}")
|
381
|
+
system("ln -sf ../../../typo3source/typo3_src-#{version} #{File.join('current','dummy','typo3_src')}")
|
382
|
+
#system("cd current/dummy && ln -sf ../../../typo3source/typo3_src-#{version} typo3_src")
|
383
|
+
end
|
384
|
+
|
385
|
+
def self.typo3_localconf_version
|
386
|
+
if(CONFIG['TYPO3_MAIN_VERSION'].to_s.split('.')[0].to_i > 4)
|
387
|
+
return 6
|
388
|
+
else
|
389
|
+
return 4
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
def self.typo3_localconf_file
|
394
|
+
if self.typo3_localconf_version == 4
|
395
|
+
return TYPO3_V4_LOCAL_CONF_PATH
|
396
|
+
elsif self.typo3_localconf_version == 6
|
397
|
+
return TYPO3_V6_LOCAL_CONF_PATH
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
def self.get_v6_localconf_array
|
402
|
+
cmd = "php -r \'define(\"TYPO3_MODE\", \"BE\");$arr = include \"#{TYPO3_V6_LOCAL_CONF_PATH}\";echo json_encode($arr);'"
|
403
|
+
json = `#{cmd}`
|
404
|
+
return JSON.parse(json)
|
405
|
+
end
|
406
|
+
|
407
|
+
def self.get_v6_package_states
|
408
|
+
infile = File.join('current','dummy','typo3conf','PackageStates.php')
|
409
|
+
cmd = "php -r \'define(\"TYPO3_MODE\", \"BE\");$arr = include \"#{infile}\";echo json_encode($arr);'"
|
410
|
+
json = `#{cmd}`
|
411
|
+
return JSON.parse(json)
|
412
|
+
end
|
413
|
+
|
414
|
+
def self.get_v4_localconf_array
|
415
|
+
infile = File.join('current','dummy','typo3conf','localconf.php')
|
416
|
+
cmd = "php -r '\define(\"TYPO3_MODE\", \"BE\");include \"#{infile}\";echo serialize($TYPO3_CONF_VARS);\'"
|
417
|
+
ret =%x[ #{cmd} ]
|
418
|
+
return PHP.unserialize(ret)
|
419
|
+
end
|
420
|
+
|
421
|
+
def self.get_localconf_extlist
|
422
|
+
if(self.typo3_localconf_version == 6)
|
423
|
+
confhash = self.get_v6_package_states
|
424
|
+
activeList = []
|
425
|
+
confhash['packages'].each do |extKey, extAttr|
|
426
|
+
if extAttr['state']=='active'
|
427
|
+
activeList << extKey
|
428
|
+
end
|
429
|
+
end
|
430
|
+
return activeList
|
431
|
+
|
432
|
+
elsif(self.typo3_localconf_version == 4)
|
433
|
+
return get_v4_localconf_extlist('extList')
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
def self.get_v4_localconf_extlist(extlistKey='extList')
|
438
|
+
cmd = "php -r '\define(\"TYPO3_MODE\", \"BE\");include \"#{TYPO3_V4_LOCAL_CONF_PATH}\";echo $TYPO3_CONF_VARS[\"EXT\"][\"#{extlistKey}\"];\'"
|
439
|
+
extList =%x[ #{cmd} ]
|
440
|
+
return extList.split(',');
|
441
|
+
end
|
442
|
+
|
443
|
+
#unused at the moment, could be handy
|
444
|
+
def self.get_confarray_from_localconf
|
445
|
+
if(self.typo3_localconf_version == 6)
|
446
|
+
return self.get_v6_localconf_array
|
447
|
+
elsif(self.typo3_localconf_version == '4')
|
448
|
+
return self.get_v4_localconf_array
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
def self.get_extconfarray_from_localconf(infile)
|
453
|
+
if(self.typo3_localconf_version == 6)
|
454
|
+
confhash = self.get_v6_localconf_array
|
455
|
+
extensionArr = Hash.new
|
456
|
+
confhash['EXT']['extConf'].each {|extkey,extconf|
|
457
|
+
extensionArr[extkey] = PHP.unserialize(extconf)
|
458
|
+
}
|
459
|
+
return extensionArr
|
460
|
+
|
461
|
+
elsif
|
462
|
+
cmd = "php -r '\define(\"TYPO3_MODE\", \"BE\");include \"#{infile}\";echo serialize($TYPO3_CONF_VARS[\"EXT\"][\"extConf\"]);\'"
|
463
|
+
ret =%x[ #{cmd} ]
|
464
|
+
|
465
|
+
extensionArr = Hash.new
|
466
|
+
_extArray= PHP.unserialize(ret)
|
467
|
+
_extArray.each {|extkey,extconf|
|
468
|
+
extensionArr[extkey] = PHP.unserialize(extconf)
|
469
|
+
|
470
|
+
}
|
471
|
+
return extensionArr
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
def self.download_ext_xml
|
476
|
+
DT3Div.downloadTo('typo3.org','/fileadmin/ter/extensions.xml.gz','current/dummy/typo3temp/extensions.xml.gz')
|
477
|
+
system('gunzip -c current/dummy/typo3temp/extensions.xml.gz > current/dummy/typo3temp/extensions.xml');
|
478
|
+
return true
|
479
|
+
end
|
480
|
+
|
481
|
+
end
|