Skip to content

Commit fd079b6

Browse files
authored
Build Tools fix (#162)
* Build Tools fix * Fix tabs to spaces * eslint is failing * Another eslint failure * No idea why eslint is failing, its valid javascript * Done with eslint.
1 parent e9eb2fb commit fd079b6

16 files changed

+816
-37
lines changed

.github/scripts/DCO.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Developer's Certificate of Origin 1.1
2+
3+
By making a contribution to this project, I certify that:
4+
5+
(a) The contribution was created in whole or in part by me and I
6+
have the right to submit it under the open source license
7+
indicated in the file; or
8+
9+
(b) The contribution is based upon previous work that, to the best
10+
of my knowledge, is covered under an appropriate open source
11+
license and I have the right under that license to submit that
12+
work with modifications, whether created in whole or in part
13+
by me, under the same open source license (unless I am
14+
permitted to submit under a different license), as indicated
15+
in the file; or
16+
17+
(c) The contribution was provided directly to me by some other
18+
person who certified (a), (b) or (c) and I have not modified
19+
it.
20+
21+
(d) I understand and agree that this project and the contribution
22+
are public and that a record of the contribution (including all
23+
personal information I submit with it, including my sign-off) is
24+
maintained indefinitely and may be redistributed consistent with
25+
this project or the open source license(s) involved.

.github/scripts/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# [SimpleDesk](simpledesk.net)
2+
3+
This is a SimpleDesk Build Tools Repository.
4+
The software is licensed under [BSD 3-clause license](http://www.opensource.org/licenses/BSD-3-Clause).
5+
6+
Contributions to documentation are licensed under [CC-by-SA 3](https://creativecommons.org/licenses/by-sa/3.0). Third party libraries or sets of images, are under their own licenses.
7+
8+
##Notes:
9+
10+
This repository contains all tools used by Travis CI and other automated scripts.
11+
12+
Feel free to fork this repository and make your desired changes.
13+
14+
Please see the [Developer's Certificate of Origin](https://github.com/SimpleDesk/buildTools/blob/master/DCO.txt) in the repository:
15+
by signing off your contributions, you acknowledge that you can and do license your submissions under the license of the project.
16+
17+
##How to contribute:
18+
* fork the repository. If you are not used to Github, please check out [fork a repository](https://help.github.com/fork-a-repo).
19+
* branch your repository, to commit the desired changes.
20+
* sign-off your commits, to acknowledge your submission under the license of the project.
21+
* It is enough to include in your commit comment "Signed-off by: " followed by your name and email address (for example: `Signed-off-by: SleePy <[email protected]>`)
22+
* an easy way to do so, is to define an alias for the git commit command, which includes -s switch (reference: [How to create Git aliases](https://git.wiki.kernel.org/index.php/Aliases))
23+
* send a pull request to us.
24+
25+
Please, feel free to play around. That's what we're doing. ;)
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
/**************************************************************
3+
* Simple Desk Project - www.simpledesk.net *
4+
***************************************************************
5+
* An advanced help desk modification built on SMF *
6+
***************************************************************
7+
* *
8+
* * Copyright 2022 - SimpleDesk.net *
9+
* *
10+
* This file and its contents are subject to the license *
11+
* included with this distribution, license.txt, which *
12+
* states that this software is New BSD Licensed. *
13+
* Any questions, please contact SimpleDesk.net *
14+
* *
15+
***************************************************************
16+
* File Info: build_release_package *
17+
**************************************************************/
18+
19+
// The path such as /usr/bin/git
20+
$git_path = '/usr/bin/git';
21+
22+
// The path to tar & zip
23+
$tar_path = '/usr/bin/tar';
24+
$zip_path = '/usr/bin/zip';
25+
26+
/***************************************/
27+
/***** END OF CONFIGURATION CHANGES ****/
28+
29+
global $args;
30+
parseArgs();
31+
32+
// Debugging?
33+
if (isset($_SERVER['USER'], $args) && !empty($args['debug']))
34+
error_reporting(E_ALL);
35+
36+
if (empty($args) || empty($args['src']) || empty($args['dst']))
37+
die('missing critical settings');
38+
39+
// Get in the trunk.
40+
chdir($args['src']);
41+
42+
if (!empty($args['skip-pull']))
43+
{
44+
$out = shell_exec($git_path . ' pull');
45+
46+
// No comprenda senior.
47+
if (strpos($out, 'From git://github.com') === false && strpos($out, 'Already up-to-date.') === false)
48+
die('GIT build returned an unexpected output: ' . $out);
49+
}
50+
51+
// Try to find our version.
52+
$pkg_file = file_get_contents('package-info.xml');
53+
preg_match('~<version>([^<]+)</version>~i', $pkg_file, $v);
54+
55+
if (empty($v))
56+
die('Unknown Version');
57+
58+
$version = strtr(
59+
ucFirst(trim($v[1])),
60+
array(
61+
' ' => '-',
62+
'Rc' => 'RC',
63+
)
64+
);
65+
66+
$package_file_base = 'SimpleDesk-' . $version;
67+
68+
// Build baby, build!
69+
70+
if (file_exists($args['dst'] . '/SimpleDesk_' . $version . '.tgz'))
71+
unlink($args['dst'] . '/SimpleDesk_' . $version . '.tgz');
72+
shell_exec($tar_path . ' --no-xattrs --no-acls --no-mac-metadata --no-fflags --exclude=\'.git\' --exclude=\'install-testdata.php\' --exclude=\'error_log\' --exclude=\'.gitignore\' --exclude=\'.gitattributes\' --exclude=\'.travis.yml\' --exclude=\'buildTools\' --exclude=\'node_modules\' --exclude=\'.DS_Store\' -czf ' . $args['dst'] . '/' . $package_file_base . '.tgz *');
73+
74+
// Zip it, zip it good.
75+
if (file_exists($args['dst'] . '/SimpleDesk_' . $version . '.zip'))
76+
unlink($args['dst'] . '/SimpleDesk_' . $version . '.zip');
77+
shell_exec($zip_path . ' --exclude=\'.git\' --exclude=\'install-testdata.php\' --exclude=\'error_log\' --exclude=\'.gitignore\' --exclude=\'.gitattributes\' --exclude=\'.travis.yml\' --exclude=\'buildTools/*\' --exclude=\'node_modules/*\' --exclude=\'*' . '/.DS_Store\' -1 ' . $args['dst'] . '/' . $package_file_base . '.zip -r *');
78+
79+
// Undo the damage we did to the package file
80+
shell_exec($git_path . ' checkout -- package-info.xml');
81+
82+
// FINALLY, we are done.
83+
exit;
84+
85+
function parseArgs()
86+
{
87+
global $args;
88+
89+
if (!isset($_SERVER['argv']))
90+
$_SERVER['argv'] = array();
91+
92+
// If its empty, force help.
93+
if (empty($_SERVER['argv'][1]))
94+
$_SERVER['argv'][1] = '--help';
95+
96+
// Lets get the path_to and path_from
97+
foreach ($_SERVER['argv'] as $i => $arg)
98+
{
99+
// Trim spaces.
100+
$arg = trim($arg);
101+
102+
if (preg_match('~^--src=(.+)$~', $arg, $match) != 0)
103+
$args['src'] = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
104+
elseif (preg_match('~^--dst=(.+)$~', $arg, $match) != 0)
105+
$args['dst'] = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
106+
elseif ($arg == '--debug')
107+
$args['debug'] = 1;
108+
elseif ($arg == '--help')
109+
{
110+
echo 'Build Tool
111+
Usage: /path/to/php ' . realpath(__FILE__) . ' -- [OPTION]...
112+
113+
--src Path to SD (' . realpath($_SERVER['PWD']) . ').
114+
--dst Output directory for files (' . realpath($_SERVER['PWD'] . '/..') . ')
115+
--debug Output debugging information.';
116+
die;
117+
}
118+
119+
if (empty($args['src']))
120+
$args['src'] = realpath($_SERVER['PWD']);
121+
if (empty($args['dst']))
122+
$args['dst'] = realpath($args['src'] . '/..');
123+
124+
// We have extra params.
125+
if (preg_match('~^--(.+)=(.+)$~', $arg, $match) != 0 && !array_key_exists($match[1], $_POST))
126+
$_POST[$match[1]] = $match[2];
127+
}
128+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**************************************************************
3+
* Simple Desk Project - www.simpledesk.net *
4+
***************************************************************
5+
* An advanced help desk modification built on SMF *
6+
***************************************************************
7+
* *
8+
* * Copyright 2022 - SimpleDesk.net *
9+
* *
10+
* This file and its contents are subject to the license *
11+
* included with this distribution, license.txt, which *
12+
* states that this software is New BSD Licensed. *
13+
* Any questions, please contact SimpleDesk.net *
14+
* *
15+
***************************************************************
16+
* SimpleDesk Version: 2.1 Beta 1 *
17+
* File Info: check-eof-master.php *
18+
**************************************************************/
19+
20+
// Stuff we will ignore.
21+
$ignoreFiles = array(
22+
'\.github/',
23+
'/buildTools/',
24+
);
25+
26+
$curDir = '.';
27+
if (isset($_SERVER['argv'], $_SERVER['argv'][1]))
28+
$curDir = $_SERVER['argv'][1];
29+
30+
$foundBad = false;
31+
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($curDir, FilesystemIterator::UNIX_PATHS)) as $currentFile => $fileInfo)
32+
{
33+
// Only check PHP
34+
if ($fileInfo->getExtension() !== 'php')
35+
continue;
36+
37+
foreach ($ignoreFiles as $if)
38+
if (preg_match('~' . $if . '~i', $currentFile))
39+
continue 2;
40+
41+
$result = trim(shell_exec('php .github/scripts/check-eof.php ' . $currentFile . ' 2>&1'));
42+
43+
if (!preg_match('~Error:([^$]+)~', $result))
44+
continue;
45+
46+
$foundBad = true;
47+
fwrite(STDERR, $result . "\n");
48+
}
49+
50+
if (!empty($foundBad))
51+
exit(1);

.github/scripts/check-eof.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**************************************************************
3+
* Simple Desk Project - www.simpledesk.net *
4+
***************************************************************
5+
* An advanced help desk modification built on SMF *
6+
***************************************************************
7+
* *
8+
* * Copyright 2022 - SimpleDesk.net *
9+
* *
10+
* This file and its contents are subject to the license *
11+
* included with this distribution, license.txt, which *
12+
* states that this software is New BSD Licensed. *
13+
* Any questions, please contact SimpleDesk.net *
14+
* *
15+
***************************************************************
16+
* SimpleDesk Version: 2.1 Beta 1 *
17+
* File Info: check-eof.php *
18+
**************************************************************/
19+
20+
// Stuff we will ignore.
21+
$ignoreFiles = array(
22+
'\.github/',
23+
'\.buildTools/',
24+
);
25+
26+
// No file? Thats bad.
27+
if (!isset($_SERVER['argv'], $_SERVER['argv'][1]))
28+
fatalError('Error: No File specified' . "\n");
29+
30+
// The file has to exist.
31+
$currentFile = $_SERVER['argv'][1];
32+
if (!file_exists($currentFile))
33+
fatalError('Error: File does not exist' . "\n");
34+
35+
// Is this ignored?
36+
foreach ($ignoreFiles as $if)
37+
if (preg_match('~' . $if . '~i', $currentFile))
38+
die;
39+
40+
// Less efficent than opening a file with fopen, but we want to be sure to get the right end of the file. file_get_contents
41+
$file = fopen($currentFile, 'r');
42+
43+
// Error?
44+
if ($file === false)
45+
fatalError('Error: Unable to open file ' . $currentFile . "\n");
46+
47+
// Seek the end minus some bytes.
48+
fseek($file, -100, SEEK_END);
49+
$contents = fread($file, 100);
50+
51+
// There is some white space here.
52+
if (preg_match('~}\s+$~', $contents, $matches))
53+
fatalError('Error: End of File contains extra spaces in ' . $currentFile . "\n");
54+
// It exists! Leave.
55+
elseif (preg_match('~}$~', $contents, $matches))
56+
die();
57+
58+
// There is some white space here.
59+
if (preg_match('~\';\s+$~', $contents, $matches))
60+
fatalError('Error: End of File Strings contains extra spaces in ' . $currentFile . "\n");
61+
// It exists! Leave.
62+
elseif (preg_match('~\';$~', $contents, $matches))
63+
die();
64+
65+
function fatalError($msg)
66+
{
67+
fwrite(STDERR, $msg);
68+
die;
69+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**************************************************************
3+
* Simple Desk Project - www.simpledesk.net *
4+
***************************************************************
5+
* An advanced help desk modification built on SMF *
6+
***************************************************************
7+
* *
8+
* * Copyright 2022 - SimpleDesk.net *
9+
* *
10+
* This file and its contents are subject to the license *
11+
* included with this distribution, license.txt, which *
12+
* states that this software is New BSD Licensed. *
13+
* Any questions, please contact SimpleDesk.net *
14+
* *
15+
***************************************************************
16+
* SimpleDesk Version: 2.1 Beta 1 *
17+
* File Info: check-license-master.php *
18+
**************************************************************/
19+
20+
// Stuff we will ignore.
21+
$ignoreFiles = array(
22+
'\.github/',
23+
'/buildTools/',
24+
);
25+
26+
$curDir = '.';
27+
if (isset($_SERVER['argv'], $_SERVER['argv'][1]))
28+
$curDir = $_SERVER['argv'][1];
29+
30+
$foundBad = false;
31+
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($curDir, FilesystemIterator::UNIX_PATHS)) as $currentFile => $fileInfo)
32+
{
33+
// Only check PHP
34+
if ($fileInfo->getExtension() !== 'php')
35+
continue;
36+
37+
foreach ($ignoreFiles as $if)
38+
if (preg_match('~' . $if . '~i', $currentFile))
39+
continue 2;
40+
41+
$result = trim(shell_exec('php .github/scripts/check-license.php ' . $currentFile . ' 2>&1'));
42+
43+
if (!preg_match('~Error:([^$]+)~', $result))
44+
continue;
45+
46+
$foundBad = true;
47+
fwrite(STDERR, $result . "\n");
48+
}
49+
50+
if (!empty($foundBad))
51+
exit(1);

0 commit comments

Comments
 (0)