Skip to content
This repository was archived by the owner on Aug 9, 2021. It is now read-only.

Commit a3d07c2

Browse files
committed
feat(market): fdroid market
Signed-off-by: Thierry Bugier <[email protected]>
1 parent 10e4ed2 commit a3d07c2

32 files changed

+2276
-694
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ script:
3939
- if [ "${TRAVIS_PHP_VERSION:0:3}" = "$CS" ] && [ "$GLPI_BRANCH" = "$AFTER_SUCCESS_BRANCH" ]; then COVERAGE="--nccfc CommonTreeDropdown CommonDropdown CommonDBTM CommonGLPI"; else COVERAGE="-ncc"; fi
4040
- if [ -e ../../scripts/cliinstall.php ] ; then php ../../scripts/cliinstall.php --db=$OLDDBNAME --user=root --tests ; fi
4141
- if [ -e ../../tools/cliinstall.php ] ; then php ../../tools/cliinstall.php --db=$OLDDBNAME --user=root --tests ; fi
42-
- php ../fusioninventory/scripts/cli_install.php --tests
42+
- php ../fusioninventory/scripts/cli_install.php --tests --as-user glpi
4343
- mysql -u root $OLDDBNAME < tests/plugin_flyvemdm_empty_2.0.0-rc.1.sql
4444
- mysql -u root $OLDDBNAME < tests/plugin_flyvemdm_config_2.0.0-rc.1.sql
45-
- php tools/cli_install.php --test
45+
- php tools/cli_install.php --tests
4646
- rm ../../tests/config_db.php
4747
- if [ -e ../../scripts/cliinstall.php ] ; then php ../../scripts/cliinstall.php --db=$DBNAME --user=root --tests ; fi
4848
- if [ -e ../../tools/cliinstall.php ] ; then php ../../tools/cliinstall.php --db=$DBNAME --user=root --tests ; fi
49-
- php ../fusioninventory/scripts/cli_install.php --tests
49+
- php ../fusioninventory/scripts/cli_install.php --tests --as-user glpi
5050
- vendor/bin/atoum -ft -bf tests/bootstrap.php -d tests/suite-install -ncc
5151
- #php scripts/mqtt.php --tests > /dev/null 2>&1 &
5252
- vendor/bin/atoum -ft -bf tests/bootstrap.php -d tests/suite-integration -mcn 1 $COVERAGE

RoboFile.php

+84-77
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,26 @@ class RoboFile extends Glpi\Tools\RoboFile {
5858
'save.sql',
5959
];
6060

61+
protected static $toArchive = [
62+
'*.md',
63+
'*.js',
64+
'*.php',
65+
'composer.*',
66+
'package.json',
67+
'tools',
68+
'scripts',
69+
'inc',
70+
'pics',
71+
'css',
72+
'tpl',
73+
'locales',
74+
'images',
75+
'install',
76+
'front',
77+
'lib',
78+
'ajax',
79+
];
80+
6181
protected static $tagPrefix = 'v';
6282

6383
protected static $pluginXmlFile = 'plugin.xml';
@@ -205,56 +225,34 @@ public function archiveBuild($release = 'release') {
205225
throw new Exception("$version is not semver compliant. See http://semver.org/");
206226
}
207227

208-
$tag = self::$tagPrefix . $version;
228+
if (!$this->checkUpgrade('head')) {
229+
throw new Exception("Bad upgrade code");
230+
}
231+
209232
if ($release != 'release') {
233+
// check the release constant
210234
if ($this->getIsRelease() === 'true') {
211235
throw new Exception('The Official release constant must be false');
212236
}
213237

214-
// update version in package.json
215-
$this->sourceUpdatePackageJson($version);
216-
217-
$this->updateChangelog();
218-
219-
$diff = $this->gitDiff(['package.json']);
220-
$diff = implode("\n", $diff);
221-
if ($diff != '') {
222-
$this->taskGitStack()
223-
->stopOnFail()
224-
->add('package.json')
225-
->commit('docs: bump version package.json')
226-
->run();
227-
}
228-
$this->taskGitStack()
229-
->stopOnFail()
230-
->add('CHANGELOG.md')
231-
->commit('docs(changelog): update changelog')
232-
->run();
233-
234-
// Update locales
235-
$this->localesGenerate();
236-
$this->taskGitStack()
237-
->stopOnFail()
238-
->add('locales/*')
239-
->commit('docs(locales): update translations')
240-
->run();
241-
242238
$rev = 'HEAD';
243239
} else {
244240
// check a tag exists for the version
245-
if ($this->getIsRelease() !== 'true') {
246-
throw new Exception('The Official release constant must be true');
247-
}
248-
241+
$tag = self::$tagPrefix . $version;
249242
if (!$this->tagExists($tag)) {
250243
throw new Exception("The tag $tag does not exists");
251244
}
252245

253-
//check the current head matches the tag
246+
// check the current head matches the tag
254247
if (!$this->isTagMatchesCurrentCommit(self::$tagPrefix . $version)) {
255248
throw new Exception("HEAD is not pointing to the tag of the version to build");
256249
}
257250

251+
// check the release constant
252+
if ($this->getIsRelease() !== 'true') {
253+
throw new Exception('The Official release constant must be true');
254+
}
255+
258256
// check the version is declared in plugin.xml
259257
$versionTag = $this->getVersionTagFromXML($version);
260258
if (!is_array($versionTag)) {
@@ -264,18 +262,53 @@ public function archiveBuild($release = 'release') {
264262
$rev = $tag;
265263
}
266264

265+
// Update locales
266+
$this->localesGenerate();
267+
268+
if ($release == 'release') {
269+
270+
// commit locales update
271+
$this->taskGitStack()
272+
->stopOnFail()
273+
->add('locales/*.po')
274+
->add('locales/*.mo')
275+
->add("locales/$pluginName.pot")
276+
->commit('docs(locales): update translations')
277+
->run();
278+
279+
// bump version in package.json
280+
$this->sourceUpdatePackageJson($version);
281+
282+
// updte changelog
283+
$this->updateChangelog();
284+
$diff = $this->gitDiff(['package.json']);
285+
$diff = implode("\n", $diff);
286+
if ($diff != '') {
287+
$this->taskGitStack()
288+
->stopOnFail()
289+
->add('package.json')
290+
->commit('docs: bump version package.json')
291+
->run();
292+
}
293+
$this->taskGitStack()
294+
->stopOnFail()
295+
->add('CHANGELOG.md')
296+
->commit('docs(changelog): update changelog')
297+
->run();
298+
}
299+
267300
// Build archive
268301
$pluginName = $this->getPluginName();
269302
$pluginPath = $this->getPluginPath();
270303
$archiveWorkdir = "$pluginPath/output/dist/archive_workdir";
271-
$archiveFile = "$pluginPath/output/dist/glpi-" . $this->getPluginName() . "-$version.tar.bz2";
304+
$archiveFile = "$pluginPath/output/dist/glpi-$pluginName-$version.tar.bz2";
272305
$this->taskDeleteDir($archiveWorkdir)->run();
273306
mkdir($archiveWorkdir, 0777, true);
274-
$filesToArchive = implode(' ', $this->getFileToArchive($rev));
275-
$this->_exec("git archive --prefix=$pluginName/ $rev $filesToArchive | tar x -C '$archiveWorkdir'");
276-
$this->_exec("composer install --no-dev --working-dir='$archiveWorkdir/flyvemdm'");
307+
$filesToArchive = implode(' ', static::$toArchive);
308+
$this->_exec("git archive --prefix=$pluginName/ $rev $filesToArchive | tar x -C '$archiveWorkdir' ");
309+
$this->_exec("composer install --no-dev --working-dir='$archiveWorkdir/$pluginName'");
277310
$this->taskPack($archiveFile)
278-
->addDir('/flyvemdm', "$archiveWorkdir/flyvemdm")
311+
->addDir("/$pluginName", "$archiveWorkdir/$pluginName")
279312
->run();
280313
}
281314

@@ -367,41 +400,6 @@ protected function getTrackedFiles($version = null) {
367400
return $output;
368401
}
369402

370-
/**
371-
* Enumerates all files to save in the distribution archive
372-
*
373-
* @param $version
374-
* @return array
375-
*/
376-
protected function getFileToArchive($version) {
377-
$filesToArchive = $this->getTrackedFiles($version);
378-
379-
// prepare banned items for regex
380-
$patterns = [];
381-
foreach ($this->getBannedFiles() as $bannedItem) {
382-
$pattern = "#" . preg_quote("$bannedItem", "#") . "#";
383-
$pattern = str_replace("\\?", ".", $pattern);
384-
$pattern = str_replace("\\*", ".*", $pattern);
385-
$patterns[] = $pattern;
386-
}
387-
388-
// remove banned files from the list
389-
foreach ($patterns as $pattern) {
390-
$filteredFiles = [];
391-
foreach ($filesToArchive as $file) {
392-
if (preg_match($pattern, $file) == 0) {
393-
//Include the tracked file
394-
$filteredFiles[] = $file;
395-
}
396-
}
397-
398-
// Repeat filtering from result with next banned files pattern
399-
$filesToArchive = $filteredFiles;
400-
}
401-
402-
return $filesToArchive;
403-
}
404-
405403
/**
406404
* Returns all tags of the GIT repository
407405
*
@@ -493,7 +491,7 @@ protected function getVersionTagFromXML($versionToSearch) {
493491
protected function getCurrentCommitHash() {
494492
exec('git rev-parse HEAD', $output, $retCode);
495493
if ($retCode != '0') {
496-
throw new Exception("failed to get curent commit hash");
494+
throw new Exception("failed to get current commit hash");
497495
}
498496
return $output[0];
499497
}
@@ -675,11 +673,20 @@ protected function gitDiff(array $files, $version1 = '', $version2 = '') {
675673
/**
676674
*/
677675
protected function updateChangelog() {
678-
exec("node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s", $output, $retCode);
676+
exec("node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s", $output, $retCode);
679677
if ($retCode > 0) {
680678
throw new Exception("Failed to update the changelog");
681679
}
682680

683-
return true;
681+
return true;
682+
}
683+
684+
private function checkUpgrade($rev) {
685+
$fileContent = $this->getFileFromGit('install/upgrade_to_develop.php', $rev);
686+
if ($fileContent != '') {
687+
throw new Exception ('upgrade_to_develop.php must be renamed !');
688+
return false;
689+
}
690+
return true;
684691
}
685692
}

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"minimum-stability": "dev",
33
"prefer-stable": true,
4-
"title": "Flyve MDM",
4+
"name": "Flyve MDM",
55
"description": "Flyve MDM plugin for GLPI",
66
"type": "project",
7-
"licence": "AGPL-3.0-or-later",
7+
"license": "AGPL-3.0-or-later",
88
"keywords": [
99
"glpi",
1010
"flyve",

front/fdroidapplication.form.php

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* LICENSE
4+
*
5+
* Copyright © 2016-2018 Teclib'
6+
* Copyright © 2010-2018 by the FusionInventory Development Team.
7+
*
8+
* This file is part of Flyve MDM Plugin for GLPI.
9+
*
10+
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
11+
* device management software.
12+
*
13+
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
14+
* modify it under the terms of the GNU Affero General Public License as published
15+
* by the Free Software Foundation, either version 3 of the License, or
16+
* (at your option) any later version.
17+
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
23+
* ------------------------------------------------------------------------------
24+
* @author Thierry Bugier
25+
* @copyright Copyright © 2018 Teclib
26+
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
27+
* @link https://github.com/flyve-mdm/glpi-plugin
28+
* @link https://flyve-mdm.com/
29+
* ------------------------------------------------------------------------------
30+
*/
31+
32+
include ('../../../inc/includes.php');
33+
$plugin = new Plugin();
34+
if (!$plugin->isActivated('flyvemdm')) {
35+
Html::displayNotFoundError();
36+
}
37+
38+
Session::checkRight('flyvemdm:flyvemdm', PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE);
39+
40+
if (!isset($_GET['id'])) {
41+
$_GET['id'] = '';
42+
}
43+
44+
if (!isset($_GET['withtemplate'])) {
45+
$_GET['withtemplate'] = '';
46+
}
47+
48+
$fdroidApplication = new PluginFlyvemdmFDroidApplication();
49+
if (isset($_POST['import'])) {
50+
unset($_POST['_skip_checks']);
51+
$fdroidApplication->update(['id' => $_POST['id'], 'import_status' => 'to_import']);
52+
Html::back();
53+
} else {
54+
$fdroidApplication->check($_GET['id'], READ);
55+
Html::header(
56+
PluginFlyvemdmFDroidApplication::getTypeName(Session::getPluralNumber()),
57+
'',
58+
'admin',
59+
PluginFlyvemdmMenu::class,
60+
'fdroid application'
61+
);
62+
63+
$menu = new PluginFlyvemdmMenu();
64+
$menu->displayMenu('mini');
65+
66+
$fdroidApplication->display([
67+
'id' => $_GET['id'],
68+
'withtemplate' => $_GET['withtemplate']
69+
]);
70+
71+
// Footer
72+
if (strstr($_SERVER['PHP_SELF'], 'popup')) {
73+
Html::popFooter();
74+
} else {
75+
Html::footer();
76+
}
77+
}

front/fdroidapplication.php

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* LICENSE
4+
*
5+
* Copyright © 2016-2018 Teclib'
6+
* Copyright © 2010-2018 by the FusionInventory Development Team.
7+
*
8+
* This file is part of Flyve MDM Plugin for GLPI.
9+
*
10+
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
11+
* device management software.
12+
*
13+
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
14+
* modify it under the terms of the GNU Affero General Public License as published
15+
* by the Free Software Foundation, either version 3 of the License, or
16+
* (at your option) any later version.
17+
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
23+
* ------------------------------------------------------------------------------
24+
* @author Thierry Bugier
25+
* @copyright Copyright © 2018 Teclib
26+
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
27+
* @link https://github.com/flyve-mdm/glpi-plugin
28+
* @link https://flyve-mdm.com/
29+
* ------------------------------------------------------------------------------
30+
*/
31+
32+
include ('../../../inc/includes.php');
33+
$plugin = new Plugin();
34+
if (!$plugin->isActivated('flyvemdm')) {
35+
Html::displayNotFoundError();
36+
}
37+
38+
Session::checkRight("flyvemdm:flyvemdm", PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE);
39+
Session::checkRight("flyvemdm:fdroidapplication", READ);
40+
41+
Html::header(
42+
PluginFlyvemdmFDroidApplication::getTypeName(Session::getPluralNumber()),
43+
'',
44+
'admin',
45+
PluginFlyvemdmMenu::class,
46+
'fdroid application'
47+
);
48+
49+
$menu = new PluginFlyvemdmMenu();
50+
$menu->displayMenu('mini');
51+
52+
Search::show(PluginFlyvemdmFDroidApplication::class);
53+
54+
Html::footer();

0 commit comments

Comments
 (0)