Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
provision
Commits
b46237f4
Commit
b46237f4
authored
Mar 28, 2009
by
Adrian Rossouw
Committed by
adrian
Mar 28, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#368294
- replacement package checking functions.
parent
b3d93f35
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
280 additions
and
101 deletions
+280
-101
platform/drupal_5_packages.inc
platform/drupal_5_packages.inc
+59
-0
platform/drupal_packages.inc
platform/drupal_packages.inc
+110
-0
platform/install.provision.inc
platform/install.provision.inc
+1
-0
platform/provision_drupal.drush.inc
platform/provision_drupal.drush.inc
+106
-89
platform/verify.provision.inc
platform/verify.provision.inc
+4
-12
No files found.
platform/drupal_5_packages.inc
0 → 100644
View file @
b46237f4
<?php
// $Id$
/**
* @file Package management code for Drupal 5
*/
function
_provision_drupal_parse_info_file
(
$filename
)
{
return
parse_ini_file
(
$filename
);
}
/**
* Find themes in a certain scope
*
* This function is based on system_theme_data in Drupal 5.
* We only support PHPTemplate based themes in this, the rest
* are so uncommonly used, that it's almost not worth it.
*/
function
_provision_drupal_find_themes
(
$scope
,
$key
=
''
)
{
$paths
=
_provision_drupal_search_paths
(
$scope
,
$key
,
'themes'
);
$files
=
array
();
$themes
=
array
();
$templates
=
array
();
foreach
(
$paths
as
$path
)
{
$themes
=
array_merge
(
$themes
,
drush_scan_directory
(
$path
,
".theme$"
,
array
(
'.'
,
'..'
,
'CVS'
,
'.svn'
),
0
,
true
,
'name'
));
$templates
=
array_merge
(
$templates
,
drush_scan_directory
(
$path
,
"page.tpl.php$"
,
array
(
'.'
,
'..'
,
'CVS'
,
'.svn'
),
0
,
true
,
'filename'
));
}
foreach
(
$themes
as
$name
=>
$file
)
{
$files
[
$name
]
=
$file
;
}
foreach
(
$templates
as
$filename
=>
$file
)
{
// The directory in which the template is stored is the name of the theme.
$name
=
basename
(
dirname
(
$filename
));
$file
->
template
=
TRUE
;
$file
->
engine
=
'phptemplate'
;
$files
[
$name
]
=
$file
;
}
foreach
(
$files
as
$name
=>
$theme
)
{
// Now that we have the themes, let's get the sub styles.
foreach
(
drush_scan_directory
(
dirname
(
$theme
->
filename
),
'style.css$'
)
as
$style
)
{
$style
->
style
=
TRUE
;
$style
->
template
=
isset
(
$theme
->
template
)
?
$theme
->
template
:
FALSE
;
$style
->
name
=
basename
(
dirname
(
$style
->
filename
));
$style
->
owner
=
$theme
->
filename
;
if
(
array_key_exists
(
$style
->
name
,
$files
))
{
continue
;
}
$files
[
$style
->
name
]
=
$style
;
}
}
foreach
(
$files
as
$name
=>
$file
)
{
// Now we get the information about the themes and styles from cvs_deploy
_provision_cvs_deploy
(
$files
[
$name
]);
}
return
$files
;
}
platform/drupal_packages.inc
0 → 100644
View file @
b46237f4
<?php
// $Id$
/**
* @file Package management code for Drupal 6 and Drupal 7
*/
/**
* Find themes in a certain scope
*
* This function is based on _system_theme_data in Drupal 6 and Drupal 7.
* We do not support, nor need information on subthemes at this point.
*/
function
_provision_drupal_find_themes
(
$scope
,
$key
=
''
)
{
$paths
=
_provision_drupal_search_paths
(
$scope
,
$key
,
'themes'
);
$files
=
array
();
$engines
=
array
();
foreach
(
$paths
as
$path
)
{
$files
=
array_merge
(
$files
,
drush_scan_directory
(
$path
,
".info$"
,
array
(
'.'
,
'..'
,
'CVS'
,
'.svn'
),
0
,
true
,
'name'
));
$engines
=
array_merge
(
$engines
,
drush_scan_directory
(
$path
.
"/engines"
,
".engine$"
,
array
(
'.'
,
'..'
,
'CVS'
,
'.svn'
),
0
,
true
,
'name'
));
}
foreach
(
$files
as
$name
=>
$file
)
{
$files
[
$name
]
->
info
=
_provision_drupal_parse_info_file
(
$file
->
filename
);
if
(
!
empty
(
$files
[
$name
]
->
info
[
'name'
]))
{
$files
[
$name
]
->
name
=
$files
[
$name
]
->
info
[
'name'
];
}
if
(
empty
(
$files
[
$name
]
->
info
[
'engine'
]))
{
$filename
=
dirname
(
$files
[
$name
]
->
filename
)
.
'/'
.
$files
[
$name
]
->
name
.
'.theme'
;
if
(
file_exists
(
$filename
))
{
$files
[
$name
]
->
owner
=
$filename
;
$files
[
$name
]
->
prefix
=
$name
;
}
}
else
{
$engine
=
$files
[
$name
]
->
info
[
'engine'
];
if
(
isset
(
$engines
[
$engine
]))
{
$files
[
$name
]
->
owner
=
$engines
[
$engine
]
->
filename
;
$files
[
$name
]
->
prefix
=
$engines
[
$engine
]
->
name
;
$files
[
$name
]
->
template
=
TRUE
;
}
}
_provision_cvs_deploy
(
$files
[
$name
]);
}
return
$files
;
}
/**
* This code is based on the Drupal 6 and Drupal 7 drupal_parse_info_file
*/
function
_provision_drupal_parse_info_file
(
$filename
)
{
$info
=
array
();
if
(
!
file_exists
(
$filename
))
{
return
$info
;
}
$data
=
file_get_contents
(
$filename
);
if
(
preg_match_all
(
'
@^\s* # Start at the beginning of a line, ignoring leading whitespace
((?:
[^=;\[\]]| # Key names cannot contain equal signs, semi-colons or square brackets,
\[[^\[\]]*\] # unless they are balanced and not nested
)+?)
\s*=\s* # Key/value pairs are separated by equal signs (ignoring white-space)
(?:
("(?:[^"]|(?<=\\\\)")*")| # Double-quoted string, which may contain slash-escaped quotes/slashes
(\'(?:[^\']|(?<=\\\\)\')*\')| # Single-quoted string, which may contain slash-escaped quotes/slashes
([^\r\n]*?) # Non-quoted string
)\s*$ # Stop at the next end of a line, ignoring trailing whitespace
@msx'
,
$data
,
$matches
,
PREG_SET_ORDER
))
{
foreach
(
$matches
as
$match
)
{
// Fetch the key and value string
$i
=
0
;
foreach
(
array
(
'key'
,
'value1'
,
'value2'
,
'value3'
)
as
$var
)
{
$$var
=
isset
(
$match
[
++
$i
])
?
$match
[
$i
]
:
''
;
}
$value
=
stripslashes
(
substr
(
$value1
,
1
,
-
1
))
.
stripslashes
(
substr
(
$value2
,
1
,
-
1
))
.
$value3
;
// Parse array syntax
$keys
=
preg_split
(
'/\]?\[/'
,
rtrim
(
$key
,
']'
));
$last
=
array_pop
(
$keys
);
$parent
=
&
$info
;
// Create nested arrays
foreach
(
$keys
as
$key
)
{
if
(
$key
==
''
)
{
$key
=
count
(
$parent
);
}
if
(
!
isset
(
$parent
[
$key
])
||
!
is_array
(
$parent
[
$key
]))
{
$parent
[
$key
]
=
array
();
}
$parent
=
&
$parent
[
$key
];
}
// Handle PHP constants
if
(
defined
(
$value
))
{
$value
=
constant
(
$value
);
}
// Insert actual value
if
(
$last
==
''
)
{
$last
=
count
(
$parent
);
}
$parent
[
$last
]
=
$value
;
}
}
return
$info
;
}
platform/install.provision.inc
View file @
b46237f4
...
@@ -61,5 +61,6 @@ function provision_drupal_provision_post_install($url) {
...
@@ -61,5 +61,6 @@ function provision_drupal_provision_post_install($url) {
_provision_drupal_maintain_aliases
(
$url
);
_provision_drupal_maintain_aliases
(
$url
);
provision_path
(
"chmod"
,
"./sites/
$url
/settings.php"
,
0440
,
dt
(
"Secured settings.php with safe permissions"
));
provision_path
(
"chmod"
,
"./sites/
$url
/settings.php"
,
0440
,
dt
(
"Secured settings.php with safe permissions"
));
_provision_drupal_rebuild_caches
(
$url
);
_provision_drupal_rebuild_caches
(
$url
);
drush_set_option
(
'packages'
,
_scrub_object
(
provision_drupal_system_map
()),
'site'
);
}
}
platform/provision_drupal.drush.inc
View file @
b46237f4
...
@@ -269,6 +269,7 @@ function _provision_find_profiles() {
...
@@ -269,6 +269,7 @@ function _provision_find_profiles() {
$profile
->
name
=
$name
;
$profile
->
name
=
$name
;
$profile
->
filename
=
$file
;
$profile
->
filename
=
$file
;
_provision_cvs_deploy
(
$profile
);
require_once
(
$profile
->
filename
);
require_once
(
$profile
->
filename
);
$func
=
$profile
->
name
.
"_profile_details"
;
$func
=
$profile
->
name
.
"_profile_details"
;
if
(
function_exists
(
$func
))
{
if
(
function_exists
(
$func
))
{
...
@@ -288,7 +289,7 @@ function _provision_find_profiles() {
...
@@ -288,7 +289,7 @@ function _provision_find_profiles() {
}
}
$profile
->
info
[
'languages'
]
=
array_keys
(
$languages
);
$profile
->
info
[
'languages'
]
=
array_keys
(
$languages
);
$return
[
$name
]
=
$profile
;
$return
[
$name
]
=
$profile
;
drush_log
(
dt
(
'
f
ound install profile %name'
,
array
(
'%name'
=>
$name
)));
drush_log
(
dt
(
'
F
ound install profile %name'
,
array
(
'%name'
=>
$name
)));
}
}
return
$return
;
return
$return
;
...
@@ -380,27 +381,115 @@ function provision_drupal_install_log($ret) {
...
@@ -380,27 +381,115 @@ function provision_drupal_install_log($ret) {
require_once
(
'cvs_deploy.inc'
);
require_once
(
'cvs_deploy.inc'
);
function
provision_find_packages
()
{
function
provision_find_packages
()
{
$drupal_root
=
drush_get_context
(
'DRUSH_DRUPAL_ROOT'
);
// Load the version specific include files.
$searchpaths
[]
=
sprintf
(
"%s/modules"
,
$drupal_root
);
provision_platform_include
(
dirname
(
__FILE__
),
'packages'
);
$searchpaths
[]
=
sprintf
(
"%s/sites/all/modules"
,
$drupal_root
);
$packages
[
'core'
][
'modules'
]
=
provision_parse_packages
(
$searchpaths
);
$packages
[
'base'
]
=
_provision_find_packages
(
'base'
);
$profiles
=
drush_get_option
(
'profiles'
,
array
());
// Create a package for the Drupal release
$packages
[
'base'
][
'platforms'
]
=
_provision_find_platforms
();
// Find install profiles.
$profiles
=
_provision_find_profiles
();
drush_set_option
(
'profiles'
,
array_keys
((
array
)
$profiles
),
'drupal'
);
$packages
[
'base'
][
'profiles'
]
=
_scrub_object
(
$profiles
);
// Iterate through the install profiles, finding the profile specific packages
foreach
(
$profiles
as
$profile
=>
$info
)
{
foreach
(
$profiles
as
$profile
=>
$info
)
{
$searchpaths
=
array
();
$packages
[
'profiles'
][
$profile
]
=
_provision_find_packages
(
'profiles'
,
$profile
);
$searchpaths
[]
=
sprintf
(
"%s/profiles/%s/modules"
,
$drupal_root
,
$profile
);
}
$packages
[
'profiles'
][
$profile
][
'modules'
]
=
provision_parse_packages
(
$searchpaths
);
// Iterate through the sites, finding site specific packages
foreach
(
drush_get_option
(
'sites'
,
array
())
as
$site
)
{
$packages
[
'sites'
][
$site
]
=
_provision_find_packages
(
'sites'
,
$site
);
}
}
$sites
=
drush_get_option
(
'sites'
,
array
());
return
$packages
;
foreach
(
$sites
as
$site
)
{
}
$searchpaths
=
array
();
$searchpaths
[]
=
sprintf
(
"%s/sites/%s/modules"
,
$drupal_root
,
$site
);
function
_provision_find_platforms
()
{
$packages
[
'sites'
][
$site
][
'modules'
]
=
provision_parse_packages
(
$searchpaths
);
return
array
(
'drupal'
=>
array
(
'short_name'
=>
'drupal'
,
'version'
=>
drush_drupal_version
(),
'description'
=>
dt
(
"This platform is running @short_name @version"
,
array
(
'@short_name'
=>
'Drupal'
,
'@version'
=>
VERSION
))));
}
/**
* A small helper function to reduce code duplication
*/
function
_provision_find_packages
(
$scope
,
$key
=
''
)
{
$scope_text
=
(
$key
)
?
"
$scope
/
$key
"
:
$scope
;
foreach
(
array
(
'modules'
,
'themes'
)
as
$type
)
{
$func
=
"_provision_drupal_find_
$type
"
;
$result
=
$func
(
$scope
,
$key
);
if
(
sizeof
(
$result
))
{
$packages
[
$type
]
=
$result
;
drush_log
(
dt
(
"Found !count !type in !scope"
,
array
(
'!count'
=>
sizeof
(
$result
),
'!scope'
=>
$scope_text
,
'!type'
=>
$type
)));
}
}
}
return
$packages
;
return
$packages
;
}
}
/**
* Map the system table to a packages multi-dimensional array component
*/
function
provision_drupal_system_map
()
{
$profile
=
drush_get_option
(
'profile'
);
$profiles
=
_provision_find_profiles
();
$packages
[
'platforms'
]
=
_provision_find_platforms
();
$packages
[
'profiles'
][
$profile
]
=
$profiles
[
$profile
];
$packages
[
'profiles'
][
$profile
]
->
status
=
1
;
$result
=
db_query
(
"SELECT * FROM
{
system
}
WHERE type='module'"
);
while
(
$module
=
db_fetch_object
(
$result
))
{
_provision_cvs_deploy
(
$module
);
$module
->
filename
=
realpath
(
$module
->
filename
);
$packages
[
'modules'
][
$module
->
name
]
=
$module
;
}
drush_log
(
dt
(
"Found !count modules"
,
array
(
'!count'
=>
sizeof
(
$packages
[
'modules'
]))));
$result
=
db_query
(
"SELECT * FROM
{
system
}
WHERE type='theme'"
);
while
(
$theme
=
db_fetch_object
(
$result
))
{
_provision_cvs_deploy
(
$theme
);
$theme
->
filename
=
realpath
(
$theme
->
filename
);
$packages
[
'themes'
][
$theme
->
name
]
=
$theme
;
}
drush_log
(
dt
(
"Found !count themes"
,
array
(
'!count'
=>
sizeof
(
$packages
[
'themes'
]))));
return
$packages
;
}
/**
* Retrieve a list of paths to search in a certain scope
*/
function
_provision_drupal_search_paths
(
$scope
,
$key
=
''
,
$type
=
'modules'
)
{
$searchpaths
=
array
();
$drupal_root
=
drush_get_context
(
'DRUSH_DRUPAL_ROOT'
);
switch
(
$scope
)
{
case
'base'
:
$searchpaths
[]
=
sprintf
(
"%s/%s"
,
$drupal_root
,
$type
);
$searchpaths
[]
=
sprintf
(
"%s/sites/all/%s"
,
$drupal_root
,
$type
);
break
;
default
:
if
(
$key
)
{
$searchpaths
[]
=
sprintf
(
"%s/%s/%s/%s"
,
$drupal_root
,
$scope
,
$key
,
$type
);
}
break
;
}
return
$searchpaths
;
}
function
provision_parse_packages
(
$paths
,
$type
=
'module'
)
{
/**
* Find modules in a certain scope.
*
* This function is general enough that it works for all supported
* versions of Drupal.
*/
function
_provision_drupal_find_modules
(
$scope
,
$key
=
''
)
{
$paths
=
_provision_drupal_search_paths
(
$scope
,
$key
,
'modules'
);
$files
=
array
();
$files
=
array
();
foreach
(
$paths
as
$path
)
{
foreach
(
$paths
as
$path
)
{
$files
=
array_merge
(
$files
,
drush_scan_directory
(
$path
,
".module$"
,
array
(
'.'
,
'..'
,
'CVS'
,
'.svn'
),
0
,
true
,
'name'
));
$files
=
array_merge
(
$files
,
drush_scan_directory
(
$path
,
".module$"
,
array
(
'.'
,
'..'
,
'CVS'
,
'.svn'
),
0
,
true
,
'name'
));
...
@@ -427,11 +516,10 @@ function provision_parse_packages($paths, $type = 'module') {
...
@@ -427,11 +516,10 @@ function provision_parse_packages($paths, $type = 'module') {
return
$files
;
return
$files
;
}
}
function
provision_parse_info_file
(
$filename
)
{
function
provision_parse_info_file
(
$filename
)
{
$info
=
array
();
$info
=
array
();
$defaults
=
array
(
$defaults
=
array
(
'dependencies'
=>
array
(),
'dependencies'
=>
array
(),
'description'
=>
''
,
'description'
=>
''
,
'version'
=>
NULL
,
'version'
=>
NULL
,
...
@@ -439,81 +527,10 @@ function provision_parse_info_file($filename) {
...
@@ -439,81 +527,10 @@ function provision_parse_info_file($filename) {
);
);
if
(
file_exists
(
$filename
))
{
if
(
file_exists
(
$filename
))
{
$info
=
_provision_drupal_parse_info_file
(
$filename
);
switch
(
drush_drupal_major_version
())
{
case
5
:
$info
=
parse_ini_file
(
$filename
);
break
;
default
:
$info
=
_provision_drupal_parse_info_file
(
$filename
);
break
;
}
}
}
// Merge in defaults and return
// Merge in defaults and return
return
$info
+
$defaults
;
return
$info
+
$defaults
;
}
}
/**
* This code is based on the Drupal 6 and Drupal 7 drupal_parse_info_file
*/
function
_provision_drupal_parse_info_file
(
$filename
)
{
$info
=
array
();
if
(
!
file_exists
(
$filename
))
{
return
$info
;
}
$data
=
file_get_contents
(
$filename
);
if
(
preg_match_all
(
'
@^\s* # Start at the beginning of a line, ignoring leading whitespace
((?:
[^=;\[\]]| # Key names cannot contain equal signs, semi-colons or square brackets,
\[[^\[\]]*\] # unless they are balanced and not nested
)+?)
\s*=\s* # Key/value pairs are separated by equal signs (ignoring white-space)
(?:
("(?:[^"]|(?<=\\\\)")*")| # Double-quoted string, which may contain slash-escaped quotes/slashes
(\'(?:[^\']|(?<=\\\\)\')*\')| # Single-quoted string, which may contain slash-escaped quotes/slashes
([^\r\n]*?) # Non-quoted string
)\s*$ # Stop at the next end of a line, ignoring trailing whitespace
@msx'
,
$data
,
$matches
,
PREG_SET_ORDER
))
{
foreach
(
$matches
as
$match
)
{
// Fetch the key and value string
$i
=
0
;
foreach
(
array
(
'key'
,
'value1'
,
'value2'
,
'value3'
)
as
$var
)
{
$$var
=
isset
(
$match
[
++
$i
])
?
$match
[
$i
]
:
''
;
}
$value
=
stripslashes
(
substr
(
$value1
,
1
,
-
1
))
.
stripslashes
(
substr
(
$value2
,
1
,
-
1
))
.
$value3
;
// Parse array syntax
$keys
=
preg_split
(
'/\]?\[/'
,
rtrim
(
$key
,
']'
));
$last
=
array_pop
(
$keys
);
$parent
=
&
$info
;
// Create nested arrays
foreach
(
$keys
as
$key
)
{
if
(
$key
==
''
)
{
$key
=
count
(
$parent
);
}
if
(
!
isset
(
$parent
[
$key
])
||
!
is_array
(
$parent
[
$key
]))
{
$parent
[
$key
]
=
array
();
}
$parent
=
&
$parent
[
$key
];
}
// Handle PHP constants
if
(
defined
(
$value
))
{
$value
=
constant
(
$value
);
}
// Insert actual value
if
(
$last
==
''
)
{
$last
=
count
(
$parent
);
}
$parent
[
$last
]
=
$value
;
}
}
return
$info
;
}
platform/verify.provision.inc
View file @
b46237f4
...
@@ -26,27 +26,19 @@ function provision_drupal_provision_verify($url = null) {
...
@@ -26,27 +26,19 @@ function provision_drupal_provision_verify($url = null) {
dt
(
"Drupal sites directory is not writable by the provisioning script"
),
PROVISION_SITES_DIR_NOT_WRITABLE
);
dt
(
"Drupal sites directory is not writable by the provisioning script"
),
PROVISION_SITES_DIR_NOT_WRITABLE
);
drush_set_option
(
'sites'
,
array_keys
((
array
)
provision_drupal_find_sites
()),
'drupal'
);
drush_set_option
(
'sites'
,
array_keys
((
array
)
provision_drupal_find_sites
()),
'drupal'
);
drush_set_option
(
'platform'
,
array
(
'short_name'
=>
'drupal'
,
'version'
=>
drush_drupal_version
()));
drush_log
(
dt
(
"This platform is running @short_name @version"
,
array
(
'@short_name'
=>
'drupal'
,
'@version'
=>
VERSION
)));
drush_log
(
dt
(
"This platform is running @short_name @version"
,
array
(
'@short_name'
=>
'drupal'
,
'@version'
=>
VERSION
)));
drush_set_option
(
'profiles'
,
_scrub_object
(
_provision_find_profiles
()),
'drupal'
);
drush_set_option
(
'packages'
,
_scrub_object
(
provision_find_packages
()),
'drupal'
);
drush_set_option
(
'packages'
,
_scrub_object
(
provision_find_packages
()),
'drupal'
);
}
}
else
{
else
{
drush_set_option
(
'packages'
,
_scrub_object
(
provision_drupal_system_map
()),
'site'
);
// This is the actual drupal provisioning requirements.
// This is the actual drupal provisioning requirements.
_provision_drupal_create_directories
(
$url
);
_provision_drupal_create_directories
(
$url
);
_provision_drupal_maintain_aliases
(
$url
);
_provision_drupal_maintain_aliases
(
$url
);
// Requires at least the database settings to complete.
// Requires at least the database settings to complete.
_provision_drupal_create_settings_file
(
$url
);
_provision_drupal_create_settings_file
(
$url
);
provision_platform_include
(
dirname
(
__FILE__
),
'verify'
);
}
}
#if (is_array($data['modules'])) {
// get the correct version names for everything.
#$data['modules'] = _provision_drupal_get_cvs_versions($data['modules']);
#}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment