Commit a25b26f7 authored by Jon Pugh's avatar Jon Pugh

Merge branch '7.x-3.x' into 2794915-grant-all-hosts

parents 60ca1cfc b44a7d66
#
# CI for Aegir Hosting System
#
# For docs see http://docs.aegirproject.org
# and http://docs.aegirproject.org/en/3.x/community/release-process/#setting-up-a-gitlab-runner
# Is performed before the scripts in the stages step
before_script:
- source /etc/profile
# Defines stages which are to be executed
stages:
- syntax
- build
- test
- publish
- upgradetest
# Stage "build"
#
### Stage syntax
#
syntax:lint:
stage: syntax
image: bobey/docker-gitlab-ci-runner-php7
allow_failure: false
script:
- composer require overtrue/phplint
- echo "Syntax checking PHP files"
- echo "For more information http://www.icosaedro.it/phplint/"
- vendor/bin/phplint ./ --exclude "vendor"
#
### Stage "build"
#
build:deb:
stage: build
image: aegir/hostmaster:packaging_base
......@@ -21,6 +47,7 @@ build:deb:
- dpkg-buildpackage
- mkdir build
- mv -v ../aegir3*.deb build/
- mv -v ../aegir-archive-keyring*.deb build/
- mv -v ../aegir3*.tar.gz build/
- mv -v ../aegir3*.dsc build/
- mv -v ../aegir3*.changes build/
......@@ -31,12 +58,20 @@ build:deb:
- build/*
# Stage "test"
#
### Stage "test"
#
test:debian-jessie-aegir3-apt:
stage: test
image: debian:jessie
allow_failure: true
dependencies:
- build:deb
only:
- 7.x-3.x
- /^7\.x-3\.\d+\.x/
- /-runalltests$/
before_script:
- apt-get update
......@@ -50,11 +85,14 @@ test:debian-jessie-aegir3-apt:
test:debian-stretch-aegir3-apt:
stage: test
image: debian:stretch
allow_failure: true
allow_failure: false
dependencies:
- build:deb
only:
- 7.x-3.x
- /^7\.x-3\.\d+\.x/
- /-runalltests$/
before_script:
- apt-get update
......@@ -65,13 +103,52 @@ test:debian-stretch-aegir3-apt:
script: "scripts/ci-aegir-dev-install-apt-debian9.sh"
test:debian-buster-aegir3-apt:
stage: test
image: debian:buster
allow_failure: false
dependencies:
- build:deb
before_script:
- apt-get update
# Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start.
- echo "#!/bin/sh" > /usr/sbin/policy-rc.d
- echo "exit 0" >> /usr/sbin/policy-rc.d
- apt-get install --yes sudo curl
script: "scripts/ci-aegir-dev-install-apt-debian10.sh"
test:ubuntu-xenial-aegir3-apt:
stage: test
image: ubuntu:xenial
dependencies:
- build:deb
only:
- 7.x-3.x
- /^7\.x-3\.\d+\.x/
- /-runalltests$/
before_script:
- apt-get update
# Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start.
- echo "#!/bin/sh" > /usr/sbin/policy-rc.d
- echo "exit 0" >> /usr/sbin/policy-rc.d
- apt-get install --yes sudo curl
script: "scripts/ci-aegir-dev-install-apt-ubuntu-xenial.sh"
test:ubuntu-bionic-aegir3-apt:
stage: test
image: ubuntu:bionic
dependencies:
- build:deb
only:
- 7.x-3.x
- /^7\.x-3\.\d+\.x/
- /-runalltests$/
before_script:
- apt-get update
......@@ -80,7 +157,28 @@ test:ubuntu-xenial-aegir3-apt:
- echo "exit 0" >> /usr/sbin/policy-rc.d
- apt-get install --yes sudo curl
script: "scripts/ci-aegir-dev-install-apt-ubuntu.sh"
script: "scripts/ci-aegir-dev-install-apt-ubuntu-bionic.sh"
test:cluster-slave-debian-stretch-apt:
stage: test
image: debian:stretch
allow_failure: false
dependencies:
- build:deb
only:
- 7.x-3.x
- /^7\.x-3\.\d+\.x/
- /-runalltests$/
before_script:
- apt-get update
# Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start.
- echo "#!/bin/sh" > /usr/sbin/policy-rc.d
- echo "exit 0" >> /usr/sbin/policy-rc.d
- apt-get install --yes sudo curl
script: "scripts/ci-aegir-dev-install-apt-debian9-cluster-slave.sh"
test:behat:
stage: test
......@@ -115,13 +213,14 @@ test:behat:
- sudo docker-compose -f docker-compose-provision.yml run hostmaster
#
### Stage "publish"
#
publish:unstable-repo:
stage: publish
dependencies:
- build:deb
allow_failure: true
only:
- 7.x-3.x
......@@ -149,14 +248,21 @@ publish:unstable-repo:
# reprepro should pick this up in seconds and update the repository index.
#
### Stage "upgradetest"
#
# Upgrade the latest stable Aegir to our unstable repo.
upgradetest:debian-jessie-aegir3-apt-upgrade:
upgradetest:debian-stretch-aegir3-apt-upgrade:
stage: upgradetest
image: debian:jessie
image: debian:stretch
dependencies:
- publish:unstable-repo
when: manual
only:
- 7.x-3.x
- /^7\.x-3\.\d+\.x/
- /-runalltests$/
before_script:
- apt-get update
......@@ -166,7 +272,7 @@ upgradetest:debian-jessie-aegir3-apt-upgrade:
- apt-get install --yes sudo curl cron
script:
- "scripts/ci-aegir-stable-install-apt-debian8.sh"
- "scripts/ci-aegir-stable-install-apt-debian9.sh"
# extra step to run the task queue.
- sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
- sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
......@@ -178,6 +284,6 @@ upgradetest:debian-jessie-aegir3-apt-upgrade:
- sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
# upgrade to the latest version from the unstable repo.
- rm -v /etc/apt/sources.list.d/aegir-stable.list
- echo "deb http://debian2.aegirproject.org unstable main" | sudo tee -a /etc/apt/sources.list.d/aegir-unstable.list
- echo "deb [signed-by=/usr/share/keyrings/aegir-archive-keyring.gpg] http://debian.aegirproject.org unstable main" | sudo tee -a /etc/apt/sources.list.d/aegir-unstable.list
- sudo apt-get update
- sudo apt-get --yes upgrade
- sudo apt-get --yes dist-upgrade
......@@ -43,4 +43,4 @@ before_install:
script:
# Tests are included in the docker-compose.yml file in the tests repo.
- sudo docker-compose -f docker-compose-provision.yml run hostmaster
- sudo docker-compose -f docker-compose-provision.yml run -T -e TERM=xterm hostmaster
......@@ -126,7 +126,6 @@ if (isset($_SERVER['db_name'])) {
ini_set('session.cache_limiter', 'none');
ini_set('session.cookie_lifetime', 0);
ini_set('session.gc_maxlifetime', 200000);
ini_set('session.save_handler', 'user');
ini_set('session.use_only_cookies', 1);
ini_set('session.use_trans_sid', 0);
ini_set('url_rewriter.tags', '');
......@@ -155,6 +154,13 @@ if (isset($_SERVER['db_name'])) {
<?php endif; ?>
<?php endif; ?>
/**
* If external request was HTTPS but internal request is HTTP, set $_SERVER['HTTPS'] so Drupal detects the right scheme.
*/
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' && $_SERVER["REQUEST_SCHEME"] == 'http') {
$_SERVER['HTTPS'] = 'on';
}
<?php print $extra_config; ?>
# Additional host wide configuration settings. Useful for safely specifying configuration settings.
......@@ -162,6 +168,16 @@ if (isset($_SERVER['db_name'])) {
include_once('<?php print $this->platform->server->include_path ?>/global.inc');
}
# Additional platform wide configuration settings.
if (is_readable('<?php print $this->platform->root ?>/sites/all/platform.settings.php')) {
include_once('<?php print $this->platform->root ?>/sites/all/platform.settings.php');
}
# Additional platform wide configuration settings.
if (is_readable('<?php print $this->platform->root ?>/sites/all/settings.php')) {
include_once('<?php print $this->platform->root ?>/sites/all/settings.php');
}
# Additional site configuration settings.
if (is_readable('<?php print $this->site_path ?>/local.settings.php')) {
include_once('<?php print $this->site_path ?>/local.settings.php');
......
......@@ -23,6 +23,8 @@ print '<?php' ?>
*/
if (isset($_SERVER['SITE_SUBDIR']) && isset($_SERVER['RAW_HOST'])) {
$base_url = 'http://' . $_SERVER['RAW_HOST'] . '/' . $_SERVER['SITE_SUBDIR'];
$cookie_domain = "." . $_SERVER['RAW_HOST'];
ini_set('session.cookie_path', '/' . $_SERVER['SITE_SUBDIR'] . '/');
}
<?php endif; ?>
......@@ -155,6 +157,18 @@ if (isset($_SERVER['db_name'])) {
<?php endif; ?>
<?php endif; ?>
/**
* Set the Syslog identity to the site name so it's not always "drupal".
*/
$conf['syslog_identity'] = '<?php print $this->uri ?>';
/**
* If external request was HTTPS but internal request is HTTP, set $_SERVER['HTTPS'] so Drupal detects the right scheme.
*/
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' && $_SERVER["REQUEST_SCHEME"] == 'http') {
$_SERVER['HTTPS'] = 'on';
}
<?php print $extra_config; ?>
# Additional host wide configuration settings. Useful for safely specifying configuration settings.
......@@ -162,6 +176,16 @@ if (isset($_SERVER['db_name'])) {
include_once('<?php print $this->platform->server->include_path ?>/global.inc');
}
# Additional platform wide configuration settings.
if (is_readable('<?php print $this->platform->root ?>/sites/all/platform.settings.php')) {
include_once('<?php print $this->platform->root ?>/sites/all/platform.settings.php');
}
# Additional platform wide configuration settings.
if (is_readable('<?php print $this->platform->root ?>/sites/all/settings.php')) {
include_once('<?php print $this->platform->root ?>/sites/all/settings.php');
}
# Additional site configuration settings.
if (is_readable('<?php print $this->site_path ?>/local.settings.php')) {
include_once('<?php print $this->site_path ?>/local.settings.php');
......
......@@ -23,6 +23,7 @@ print '<?php' ?>
*/
if (isset($_SERVER['SITE_SUBDIR']) && isset($_SERVER['RAW_HOST'])) {
$base_url = 'http://' . $_SERVER['RAW_HOST'] . '/' . $_SERVER['SITE_SUBDIR'];
ini_set('session.cookie_path', '/' . $_SERVER['SITE_SUBDIR'] . '/');
}
<?php endif; ?>
......@@ -110,9 +111,6 @@ if (isset($_SERVER['db_name'])) {
<?php endif; ?>
$profile = "<?php print $this->profile ?>";
$install_profile = "<?php print $this->profile ?>";
/**
* PHP settings:
*
......@@ -133,7 +131,6 @@ if (isset($_SERVER['db_name'])) {
*/
umask(0002);
$settings['install_profile'] = '<?php print $this->profile ?>';
$settings['file_public_path'] = 'sites/<?php print $this->uri ?>/files';
$settings['file_private_path'] = 'sites/<?php print $this->uri ?>/private/files';
$config['system.file']['path']['temporary'] = 'sites/<?php print $this->uri ?>/private/temp';
......@@ -173,7 +170,7 @@ if (isset($_SERVER['db_name'])) {
$esc_uri = str_replace('.', '\.', $this->uri);
print " '^{$esc_uri}\$',\n";
foreach ($this->aliases as $alias_url) {
$esc_alias = str_replace('.', '\.', $alias_url);
$esc_alias = preg_replace(['/\./', '/\/.+/'], ['\.', ''], $alias_url);
print " '^{$esc_alias}\$',\n";
}
?>
......@@ -182,14 +179,36 @@ if (isset($_SERVER['db_name'])) {
'\.local$',
);
/**
* Set the Syslog identity to the site name so it's not always "drupal".
*/
$config['syslog.settings']['identity'] = '<?php print $this->uri ?>';
/**
* If external request was HTTPS but internal request is HTTP, set $_SERVER['HTTPS'] so Drupal detects the right scheme.
*/
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' && $_SERVER["REQUEST_SCHEME"] == 'http') {
$_SERVER['HTTPS'] = 'on';
}
<?php print $extra_config; ?>
# Additional host wide configuration settings. Useful for safely specifying configuration settings.
if (is_readable('<?php print $this->platform->server->include_path ?>/global.inc')) {
include_once('<?php print $this->platform->server->include_path ?>/global.inc');
include('<?php print $this->platform->server->include_path ?>/global.inc');
}
# Additional platform wide configuration settings.
if (is_readable('<?php print $this->platform->root ?>/sites/all/platform.settings.php')) {
include('<?php print $this->platform->root ?>/sites/all/platform.settings.php');
}
# Additional platform wide configuration settings.
if (is_readable('<?php print $this->platform->root ?>/sites/all/settings.php')) {
include_once('<?php print $this->platform->root ?>/sites/all/settings.php');
}
# Additional site configuration settings.
if (is_readable('<?php print $this->site_path ?>/local.settings.php')) {
include_once('<?php print $this->site_path ?>/local.settings.php');
include('<?php print $this->site_path ?>/local.settings.php');
}
......@@ -19,10 +19,10 @@ class Provision_Config_Drushrc_Alias extends Provision_Config_Drushrc {
function __construct($context, $data = array()) {
parent::__construct($context, $data);
if (is_array($data['aliases'])) {
if (isset($data['aliases']) && is_array($data['aliases'])) {
$data['aliases'] = array_unique($data['aliases']);
}
if (is_array($data['drush_aliases'])) {
if (isset($data['drush_aliases']) && is_array($data['drush_aliases'])) {
$data['drush_aliases'] = array_unique($data['drush_aliases']);
}
......
......@@ -16,6 +16,9 @@ print "\$options['hosting_features'] = ". var_export($hosting_features, TRUE) .
print "# A list of modules to be excluded because the hosting feature is not enabled.\n";
print "\$options['exclude'] = ". var_export($drush_exclude, TRUE) . ";\n\n";
print "# Drush 8 looks at ignored-modules instead of exclude.\n";
print "\$options['ignored-modules'] = \$options['exclude'];\n\n";
print "# A list of paths that drush should include even when working outside\n";
print "# the context of the hostmaster site.\n";
print "\$options['include'] = ". var_export($drush_include, TRUE) . ";\n";
......
......@@ -41,6 +41,13 @@ class Provision_Context {
* proper. Properties that refer to Provision_Context objects will be run
* through d(), see is_oid().
*
* If value does not exist in $this->properties, and $this->name refers to a
* normal drush alias instead of a Provision context, and the property exists,
* return that value.
*
* This way, d('@drushalias')->uri will work for normal drush aliases or
* Provision Contexts.
*
* TODO: consider returning a reference to the value, so we can do things like:
* `$this->options['option'] = 'value'` and it will correctly set it in the
* drush context cache.
......@@ -60,6 +67,14 @@ class Provision_Context {
return $this->properties[$name];
}
}
// If $this->name refers to a basic drush alias (not an aegir managed site),
// and the property exists in drush alias, return it.
elseif ($drush_alias = provision_sitealias_get_record($this->name)) {
if (isset($drush_alias[$name])) {
return $drush_alias[$name];
}
}
}
/**
......
......@@ -284,7 +284,7 @@ class Provision_Service extends Provision_ChainedState {
drush_log(dt('%service on %server has been restarted', array(
'%service' => $service,
'%server' => $this->server->remote_host))
);
, 'success');
return TRUE;
}
......
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ClassLoader;
/**
* ApcUniversalClassLoader implements a "universal" autoloader cached in APC for PHP 5.3.
*
* It is able to load classes that use either:
*
* * The technical interoperability standards for PHP 5.3 namespaces and
* class names (http://groups.google.com/group/php-standards/web/psr-0-final-proposal);
*
* * The PEAR naming convention for classes (http://pear.php.net/).
*
* Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be
* looked for in a list of locations to ease the vendoring of a sub-set of
* classes for large projects.
*
* Example usage:
*
* require 'vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
* require 'vendor/symfony/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
*
* use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
*
* $loader = new ApcUniversalClassLoader('apc.prefix.');
*
* // register classes with namespaces
* $loader->registerNamespaces(array(
* 'Symfony\Component' => __DIR__.'/component',
* 'Symfony' => __DIR__.'/framework',
* 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
* ));
*
* // register a library using the PEAR naming convention
* $loader->registerPrefixes(array(
* 'Swift_' => __DIR__.'/Swift',
* ));
*
* // activate the autoloader
* $loader->register();
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Kris Wallsmith <kris@symfony.com>
*
* @api
*/
class ApcUniversalClassLoader extends UniversalClassLoader
{
private $prefix;
/**
* Constructor.
*
* @param string $prefix A prefix to create a namespace in APC
*
* @api
*/
public function __construct($prefix)
{
if (!extension_loaded('apc')) {
throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.');
}
$this->prefix = $prefix;
}
/**
* Finds a file by class name while caching lookups to APC.
*
* @param string $class A class name to resolve to file
*/
public function findFile($class)
{
if (false === $file = apc_fetch($this->prefix.$class)) {
apc_store($this->prefix.$class, $file = parent::findFile($class));
}
return $file;
}
}
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ClassLoader;
/**
* ClassCollectionLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ClassCollectionLoader
{
static private $loaded;
/**
* Loads a list of classes and caches them in one big file.
*
* @param array $classes An array of classes to load
* @param string $cacheDir A cache directory
* @param string $name The cache name prefix
* @param Boolean $autoReload Whether to flush the cache when the cache is stale or not
* @param Boolean $adaptive Whether to remove already declared classes or not
* @param string $extension File extension of the resulting file
*
* @throws \InvalidArgumentException When class can't be loaded
*/
static public function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php')
{
// each $name can only be loaded once per PHP process
if (isset(self::$loaded[$name])) {
return;
}
self::$loaded[$name] = true;
if ($adaptive) {
// don't include already declared classes
$classes = array_diff($classes, get_declared_classes(), get_declared_interfaces());
// the cache is different depending on which classes are already declared
$name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5);
}
$cache = $cacheDir.'/'.$name.$extension;
// auto-reload
$reload = false;
if ($autoReload) {
$metadata = $cacheDir.'/'.$name.$extension.'.meta';
if (!file_exists($metadata) || !file_exists($cache)) {
$reload = true;
} else {
$time = filemtime($cache);
$meta = unserialize(file_get_contents($metadata));
if ($meta[1] != $classes) {
$reload = true;
} else {
foreach ($meta[0] as $resource) {
if (!file_exists($resource) || filemtime($resource) > $time) {
$reload = true;
break;
}
}
}
}
}
if (!$reload && file_exists($cache)) {
require_once $cache;
return;
}
$files = array();
$content = '';
foreach ($classes as $class) {
if (!class_exists($class) && !interface_exists($class) && (!function_exists('trait_exists') || !trait_exists($class))) {
throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
}
$r = new \ReflectionClass($class);
$files[] = $r->getFileName();
$c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($r->getFileName()));
// add namespace declaration for global code
if (!$r->inNamespace()) {
$c = "\nnamespace\n{\n".self::stripComments($c)."\n}\n";
} else {
$c = self::fixNamespaceDeclarations('<?php '.$c);
$c = preg_replace('/^\s*<\?php/', '', $c);
}
$content .= $c;
}
// cache the core classes
if (!is_dir(dirname($cache))) {
mkdir(dirname($cache), 0777, true);
}
self::writeCacheFile($cache, '<?php '.$content);
if ($autoReload) {
// save the resources
self::writeCacheFile($metadata, serialize(array($files, $classes)));
}
}
/**
* Adds brackets around each namespace if it's not already the case.
*
* @param string $source Namespace string
*
* @return string Namespaces with brackets
*/
static public function fixNamespaceDeclarations($source)
{
if (!function_exists('token_get_all')) {
return $source;
}
$output = '';
$inNamespace = false;
$tokens = token_get_all($source);
for ($i = 0, $max = count($tokens); $i < $max; $i++) {
$token = $tokens[$i];
if (is_string($token)) {
$output .= $token;
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
// strip comments
continue;
} elseif (T_NAMESPACE === $token[0]) {
if ($inNamespace) {