Skip to content

Commit 3e48f73

Browse files
committed
4.9.0
1 parent 3c9c2d6 commit 3e48f73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1195
-593
lines changed

Todolist

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
[ IN PROGRESS ]
22

3-
- (Feature) Add checkboxes to select all the latest snapshots in repos list
4-
- (Feature) Add packages deduplication between snapshots
53

64
[ BUGS ]
75

@@ -18,7 +16,7 @@
1816
- Think about a way to publish debian repos in a more elegant way. Currently: https://<FQDN>/repo/debian/dists/buster/main_prod buster main_prod
1917
- (RPM) See how to accelerate the rpm signing process by using multi-threading
2018
- (Feature) Support Arch Linux packages https://blog.desdelinux.net/en/create-your-local-arch-linux-repository/
21-
- (Feature) Add a way to filter wanted/unwanted packages from a repository sync, with a regex
19+
2220

2321

2422
[ HOSTS / LINUPDATE ]

www/controllers/Common.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -145,46 +145,6 @@ public static function printAlert(string $message, string $alertType = null)
145145
echo '</script>';
146146
}
147147

148-
/**
149-
* Affiche une erreur générique ou personnalisée lorsqu'il y a eu une erreur d'exécution d'une requête dans la base de données
150-
* Ajoute une copie de l'erreur dans le fichier de logs 'exceptions'
151-
*/
152-
public static function dbError(string $exception = null)
153-
{
154-
/**
155-
* Date et heure de l'évènement
156-
*/
157-
$content = PHP_EOL . date("Y-m-d H:i:s") . PHP_EOL;
158-
159-
/**
160-
* Récupération du nom du fichier ayant fait appel à cette fonction
161-
*/
162-
$content .= 'File : ' . debug_backtrace()[0]['file'] . PHP_EOL;
163-
164-
/**
165-
* Si une exception a été catchée, on va l'ajouter au contenu
166-
*/
167-
if (!empty($exception)) {
168-
$content .= 'Error catched ¬' . PHP_EOL . $exception . PHP_EOL;
169-
}
170-
171-
/**
172-
* Ajout du contenu au fichier de log
173-
*/
174-
$content .= '___________________________' . PHP_EOL;
175-
file_put_contents(EXCEPTIONS_LOG, $content, FILE_APPEND);
176-
177-
/**
178-
* Lancement d'une exception qui sera catchée par printAlert
179-
* Si le mode debug est activé alors on affiche l'exception dans le message d'erreur
180-
*/
181-
if (!empty($exception) and DEBUG_MODE === true) {
182-
throw new Exception('An error occured while executing request in database <br>' . $exception . '<br>');
183-
} else {
184-
throw new Exception('An error occured while executing request in database');
185-
}
186-
}
187-
188148
/**
189149
* Colore l'environnement d'une étiquette rouge ou blanche
190150
*/

www/controllers/Host.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ public function getPackageTimeline(string $id, string $packageName)
331331
/**
332332
* Build the timeline to display and send it back to the ajax controller because it is jquery that will take care of displaying it afterwards
333333
*/
334-
$content = '<h4>' . strtoupper($packageName) . ' PACKAGE HISTORY</h4>';
335-
$content .= '<div class="timeline">';
334+
$content = '<div class="timeline">';
336335

337336
/**
338337
* The first block will be displayed on the left in the timeline
@@ -1626,7 +1625,7 @@ public function deleteWsRequest(int $id)
16261625
* Get request log details
16271626
* Request log is a file stored in the websocket-requests logs directory
16281627
*/
1629-
public function getRequestLog(int $id)
1628+
public function getRequestLog(int $id) : string
16301629
{
16311630
$logFile = WS_REQUESTS_LOGS_DIR . '/request-' . $id . '.log';
16321631

@@ -1646,4 +1645,12 @@ public function getRequestLog(int $id)
16461645

16471646
return $content;
16481647
}
1648+
1649+
/**
1650+
* Get request package log details
1651+
*/
1652+
public function getRequestPackageLog(int $id, string $package, string $status) : string|null
1653+
{
1654+
return $this->model->getRequestPackageLog($id, $package, $status);
1655+
}
16491656
}

www/controllers/Log/Log.php

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,49 @@ public function getUnread(string $type = null, int $limit = 0)
2525
* Log a message
2626
* Only log if a similar log message is not already logged
2727
*/
28-
public function log(string $type, string $component, string $message)
28+
public function log(string $type, string $component, string $message, string $details = '')
2929
{
30-
/**
31-
* Get all unread log
32-
*/
33-
$logs = $this->getUnread($type);
34-
35-
if (!empty($logs)) {
30+
try {
3631
/**
37-
* Loop through all logs
32+
* Get all unread log
3833
*/
39-
foreach ($logs as $log) {
34+
$logs = $this->getUnread($type);
35+
36+
if (!empty($logs)) {
4037
/**
41-
* If a similar log message is already logged, quit
38+
* Loop through all logs
4239
*/
43-
if ($log['Component'] == $component && $log['Message'] == $message) {
44-
return;
40+
foreach ($logs as $log) {
41+
/**
42+
* If a similar log message is already logged, quit
43+
*/
44+
if ($log['Component'] == $component && $log['Message'] == $message && $log['Details'] == $details) {
45+
return;
46+
}
4547
}
4648
}
47-
}
49+
50+
/**
51+
* Log the message
52+
*/
53+
$this->model->log($type, $component, $message, $details);
4854

4955
/**
50-
* Log the message
56+
* If the log could not be saved in database, log the error in error_log
5157
*/
52-
$this->model->log($type, $component, $message);
58+
} catch (\Exception $e) {
59+
error_log('Here is a database error while trying to save log: ' . $e . PHP_EOL);
60+
61+
62+
/**
63+
* If the log cannot be saved then log directly in error_log
64+
*/
65+
if (!empty($details)) {
66+
error_log('Here is a the original error that could not be saved in database: ' . $message . ': ' . $details . PHP_EOL);
67+
} else {
68+
error_log('Here is a the original error that could not be saved in database: ' . $message . PHP_EOL);
69+
}
70+
}
5371
}
5472

5573
/**

www/controllers/Repo/Mirror/Deb.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,50 @@ private function downloadDebPackages($url)
646646
*/
647647
$this->logOutput('<span class="opacity-80-cst">(' . $packageCounter . '/' . $totalPackages . ') ➙ ' . $debPackageLocation . ' ... </span>');
648648

649+
/**
650+
* If a list of package(s) to include has been provided, check if the package is in the list
651+
* If not, skip the package
652+
*/
653+
if (!empty($this->packagesToInclude)) {
654+
$isIn = false;
655+
656+
foreach ($this->packagesToInclude as $packageToInclude) {
657+
if (preg_match('/' . $packageToInclude . '/', $debPackageName)) {
658+
$isIn = true;
659+
}
660+
}
661+
662+
/**
663+
* If package is not in the list of packages to include, skip it
664+
*/
665+
if (!$isIn) {
666+
$this->logOutput('<span class="opacity-80-cst">not in the list of packages to include (ignoring)</span>' . PHP_EOL);
667+
continue;
668+
}
669+
}
670+
671+
/**
672+
* If a list of package(s) to exclude has been provided, check if the package is in the list
673+
* If so, skip the package
674+
*/
675+
if (!empty($this->packagesToExclude)) {
676+
$isIn = false;
677+
678+
foreach ($this->packagesToExclude as $packageToExclude) {
679+
if (preg_match('/' . $packageToExclude . '/', $debPackageName)) {
680+
$isIn = true;
681+
}
682+
}
683+
684+
/**
685+
* If package is in the list of packages to exclude, skip it
686+
*/
687+
if ($isIn) {
688+
$this->logOutput('<span class="opacity-80-cst">in the list of packages to exclude (ignoring)</span>' . PHP_EOL);
689+
continue;
690+
}
691+
}
692+
649693
/**
650694
* Check that package naming respects the Debian package naming convention
651695
* It must ends with _<arch>.deb, if not then rename it

www/controllers/Repo/Mirror/Mirror.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class Mirror
3131
protected $sslCustomCaCertificate;
3232
protected $curlHandle;
3333
protected $previousSnapshotDirPath;
34+
protected $packagesToInclude = [];
35+
protected $packagesToExclude = [];
3436

3537
public function setUrl(string $url)
3638
{
@@ -97,6 +99,16 @@ public function setPreviousSnapshotDirPath(string $path)
9799
$this->previousSnapshotDirPath = $path;
98100
}
99101

102+
public function setPackagesToInclude(array $packages)
103+
{
104+
$this->packagesToInclude = $packages;
105+
}
106+
107+
public function setPackagesToExclude(array $packages)
108+
{
109+
$this->packagesToExclude = $packages;
110+
}
111+
100112
public function getPackagesToSign()
101113
{
102114
return $this->packagesToSign;

www/controllers/Repo/Mirror/Rpm.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,50 @@ private function downloadRpmPackages(string $url)
693693
*/
694694
$this->logOutput('<span class="opacity-80-cst">(' . $packageCounter . '/' . $totalPackages . ') ➙ ' . $rpmPackageLocation . ' ... </span>');
695695

696+
/**
697+
* If a list of package(s) to include has been provided, check if the package is in the list
698+
* If not, skip the package
699+
*/
700+
if (!empty($this->packagesToInclude)) {
701+
$isIn = false;
702+
703+
foreach ($this->packagesToInclude as $packageToInclude) {
704+
if (preg_match('/' . $packageToInclude . '/', $rpmPackageName)) {
705+
$isIn = true;
706+
}
707+
}
708+
709+
/**
710+
* If package is not in the list of packages to include, skip it
711+
*/
712+
if (!$isIn) {
713+
$this->logOutput('<span class="opacity-80-cst">not in the list of packages to include (ignoring)</span>' . PHP_EOL);
714+
continue;
715+
}
716+
}
717+
718+
/**
719+
* If a list of package(s) to exclude has been provided, check if the package is in the list
720+
* If so, skip the package
721+
*/
722+
if (!empty($this->packagesToExclude)) {
723+
$isIn = false;
724+
725+
foreach ($this->packagesToExclude as $packageToExclude) {
726+
if (preg_match('/' . $packageToExclude . '/', $rpmPackageName)) {
727+
$isIn = true;
728+
}
729+
}
730+
731+
/**
732+
* If package is in the list of packages to exclude, skip it
733+
*/
734+
if ($isIn) {
735+
$this->logOutput('<span class="opacity-80-cst">in the list of packages to exclude (ignoring)</span>' . PHP_EOL);
736+
continue;
737+
}
738+
}
739+
696740
/**
697741
* Check that package architecture is valid
698742
*/

0 commit comments

Comments
 (0)