Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
require_once __DIR__ . '/vendor/autoload.php';
umask(0002);
$fs = new Filesystem();
$src = __DIR__ . '/src';
$build = __DIR__ . '/build';
$drush = __DIR__ . '/vendor/drush/drush/drush.php';
$tmp = sys_get_temp_dir() . '/cambridge-drupal-' . uniqid();
$fs->remove($build);
$arguments = array_slice($argv, 1);
$profiles = array(
'cambridge',
'cambridge_lite',
);
if (count($arguments) > 0) {
foreach ($arguments as $argument) {
if (FALSE === in_array($argument, $profiles)) {
throw new Exception('Unknown profile \'' . $argument . '\'');
}
}
$profiles = $arguments;
}
foreach ($profiles as $profile) {
$profileSrc = $src . '/' . $profile;
$info = parse_ini_file($profileSrc . '/' . $profile . '.info');
$make = new Process('php ' . $drush . ' make --no-core --contrib-destination=. ' . $profileSrc . '/' . $profile . '.make ' . $tmp . '/' . $profile);
$make->setTimeout(NULL);
if ($make->run() > 0) {
throw new Exception('Failed to run command: ' . $make->getCommandLine());
}
$filesets = array(
$profileSrc => array(
$profile . '.info',
$profile . '.install',
$profile . '.profile'
),
$src => array('cambridge_base.inc'),
);
foreach ($filesets as $fileDir => $files) {
foreach ($files as $file) {
$fs->copy($fileDir . '/' . $file, $build . '/src/' . $profile . '/' . $file);
}
}
$fs->mirror($tmp . '/' . $profile, $build . '/src/' . $profile);
$tar = new PharData($tmp . '/' . $profile . '.tar');
$tar->buildFromDirectory($build . '/src/' . $profile);
$tar->compress(Phar::GZ);
$zip = new PharData($tmp . '/' . $profile . '.zip');
$zip->buildFromDirectory($build . '/src/' . $profile);
$fs->copy($tmp . '/' . $profile . '.tar.gz', $build . '/dist/' . $profile . '-' . $info['version'] . '.tar.gz');
$fs->copy($tmp . '/' . $profile . '.zip', $build . '/dist/' . $profile . '-' . $info['version'] . '.zip');
}