forked from sugarcrmlabs/DbConfigPasswordCrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack.php
executable file
·86 lines (70 loc) · 2.09 KB
/
pack.php
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
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env php
<?php
// config variables
$id = 'db_password_crypt';
$name = 'Db Config Password Crypt';
$built_in_version = '7.8.0.0';
$author = 'Enrico Simonetti, SugarCRM Inc.';
$regex_matches = '^7.8.[\d]+.[\d]+$';
// end config variables
if (empty($argv[1])) {
die("Use $argv[0] [version]\n");
}
$version = $argv[1];
$id .= '_'. $version;
$zipFile = "releases/module_{$id}.zip";
if (file_exists($zipFile)) {
die("Release $zipFile already exists!\n");
}
$manifest = array(
'id' => $id,
'built_in_version' => $built_in_version,
'name' => $name,
'description' => $name,
'version' => $version,
'author' => $author,
'is_uninstallable' => true,
'published_date' => date("Y-m-d H:i:s"),
'type' => 'module',
'acceptable_sugar_versions' => array(
'exact_matches' => array(
),
'regex_matches' => array(
$regex_matches,
),
),
);
$installdefs = array('copy' => array());
echo "Creating {$zipFile} ... \n";
$zip = new ZipArchive();
$zip->open($zipFile, ZipArchive::CREATE);
$basePath = realpath('src/');
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($basePath, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
if ($file->isFile()) {
$fileReal = $file->getRealPath();
if(!in_array($file->getFilename(), array('.DS_Store'))) {
$fileRelative = '' . str_replace($basePath.'/', '', $fileReal);
echo " [*] $fileRelative \n";
$zip->addFile($fileReal, $fileRelative);
if(!in_array($file->getFilename(), array('LICENSE'))) {
$installdefs['copy'][] = array(
'from' => '<basepath>/' . $fileRelative,
'to' => $fileRelative,
);
}
}
}
}
$manifestContent = sprintf(
"<?php\n\$manifest = %s;\n\$installdefs = %s;\n",
var_export($manifest, true),
var_export($installdefs, true)
);
$zip->addFromString('manifest.php', $manifestContent);
$zip->close();
echo "done\n";
exit(0);