Skip to content

Commit 21cbbed

Browse files
authored
Merge pull request #205 from lbr38/devel
4.12.0
2 parents 59f20e8 + 424aa89 commit 21cbbed

File tree

181 files changed

+8652
-4838
lines changed

Some content is hidden

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

181 files changed

+8652
-4838
lines changed

.github/workflows/tasks.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ jobs:
1919
- name: Print PHP version
2020
run: php --version
2121

22+
# TODO : temporaire
23+
# A retirer une fois que 4.12.0 est publiée
24+
- name: Install PHP yaml extension
25+
run: apt-get update -y && apt-get install -y php8.3-yaml
26+
2227
# Copy latest source code to the root directory
2328
- name: Setup latest source code
2429
run: |
@@ -88,6 +93,11 @@ jobs:
8893
- name: Print PHP version
8994
run: php --version
9095

96+
# TODO : temporaire
97+
# A retirer une fois que 4.12.0 est publiée
98+
- name: Install PHP yaml extension
99+
run: apt-get update -y && apt-get install -y php8.3-yaml
100+
91101
# Copy latest source code to the root directory
92102
- name: Setup latest source code
93103
run: |

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ RUN echo "deb https://packages.bespin.ovh/repo/repomanager-php/bookworm/main_pro
3131
RUN apt-get update -y
3232

3333
# Install nginx and PHP 8.3
34-
RUN apt-get install nginx php8.3-fpm php8.3-cli php8.3-sqlite3 php8.3-xml php8.3-curl sqlite3 -y
34+
RUN apt-get install nginx php8.3-fpm php8.3-cli php8.3-sqlite3 php8.3-xml php8.3-curl php8.3-yaml sqlite3 -y
3535

3636
# Clone project in the container
3737
RUN git clone https://github.com/lbr38/repomanager.git /tmp/repomanager

www/config/properties.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
'project_git_repo_raw' => 'https://raw.githubusercontent.com/lbr38/repomanager/stable',
88
'project_update_doc_url' => 'https://github.com/lbr38/repomanager/wiki/01.-Installation-and-update#update-repomanager',
99

10-
// Debian repo default values
11-
'debian_distributions' => array('bookworm' => 'Debian 12', 'bullseye' => 'Debian 11', 'buster' => 'Debian 10', 'stretch' => 'Debian 9', 'jessie' => 'Debian 8', 'wheezy' => 'Debian 7'),
12-
'ubuntu_distributions' => array('noble' => 'Ubuntu 24.04', 'jammy' => 'Ubuntu 22.04', 'hirsute' => 'Ubuntu 21.04', 'groovy' => 'Ubuntu 20.10', 'focal' => 'Ubuntu 20.04', 'eoan' => 'Ubuntu 19.10', 'disco' => 'Ubuntu 19.04', 'cosmic' => 'Ubuntu 18.10', 'bionic' => 'Ubuntu 18.04', 'xenial' => 'Ubuntu 16.04', 'trusty' => 'Ubuntu 14.04'),
13-
'sections' => array('main', 'contrib', 'non-free', 'restricted', 'universe', 'multiverse'),
10+
// RPM release versions default values
11+
'rpm_releasevers' => array('9' => 'RHEL 9 and derivatives', '8' => 'RHEL 8 and derivatives', '7' => 'RHEL 7 and derivatives'),
12+
13+
// DEB distributions default values
14+
'deb_distributions' => array('bookworm' => 'Debian 12', 'bullseye' => 'Debian 11', 'buster' => 'Debian 10', 'stretch' => 'Debian 9', 'jessie' => 'Debian 8', 'wheezy' => 'Debian 7', 'noble' => 'Ubuntu 24.04', 'jammy' => 'Ubuntu 22.04', 'hirsute' => 'Ubuntu 21.04', 'groovy' => 'Ubuntu 20.10', 'focal' => 'Ubuntu 20.04', 'eoan' => 'Ubuntu 19.10', 'disco' => 'Ubuntu 19.04', 'cosmic' => 'Ubuntu 18.10', 'bionic' => 'Ubuntu 18.04', 'xenial' => 'Ubuntu 16.04', 'trusty' => 'Ubuntu 14.04'),
15+
16+
// DEB components default values
17+
'deb_components' => array('main', 'contrib', 'non-free', 'restricted', 'universe', 'multiverse'),
1418

1519
// DEB default values
1620
'deb_archs' => array('amd64', 'arm64', 'armel', 'armhf', 'i386', 'mips', 'mips64el', 'mipsel', 'ppc64el', 's390x', 'src'),

www/controllers/Api/Source/Source.php

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?php
2+
3+
namespace Controllers\Api\Source;
4+
5+
use Exception;
6+
use Datetime;
7+
8+
class Source extends \Controllers\Api\Controller
9+
{
10+
private $source;
11+
private $type;
12+
private $component;
13+
private $nameOrAction;
14+
private $postFiles;
15+
16+
public function execute()
17+
{
18+
$mysource = new \Controllers\Repo\Source\Source();
19+
20+
/**
21+
* Source repositories actions are only allowed for API admins
22+
*/
23+
if (!IS_API_ADMIN) {
24+
throw new Exception('You are not allowed to access this resource.');
25+
}
26+
27+
/**
28+
* Retrieve source repository and actions from URI
29+
*/
30+
if (isset($this->uri[4])) {
31+
$this->type = $this->uri[4];
32+
}
33+
if (isset($this->uri[5])) {
34+
$this->nameOrAction = $this->uri[5];
35+
}
36+
37+
/**
38+
* Retrieve uploaded FILES if any
39+
*/
40+
if (!empty($_FILES)) {
41+
$this->postFiles = $_FILES;
42+
}
43+
44+
/**
45+
* https://repomanager.mydomain.net/api/v2/source/
46+
* Print all source repositories
47+
*/
48+
if (empty($this->type) and $this->method == 'GET') {
49+
return array('results' => $mysource->listAll());
50+
}
51+
52+
/**
53+
* If a source type is specified (deb, rpm)
54+
* https://repomanager.mydomain.net/api/v2/source/$this->type/
55+
*/
56+
if (!empty($this->type)) {
57+
if (!in_array($this->type, array('deb', 'rpm'))) {
58+
throw new Exception('Invalid source type');
59+
}
60+
61+
/**
62+
* If no source name or action is specified, then list all sources of the specified type
63+
*/
64+
if (empty($this->nameOrAction) and $this->method == 'GET') {
65+
return array('results' => $mysource->listAll($this->type));
66+
}
67+
68+
/**
69+
* If a source repo name or an action is specified
70+
*/
71+
if (!empty($this->nameOrAction)) {
72+
/**
73+
* If the action is import, import source repositories from a template file
74+
*/
75+
if ($this->nameOrAction == 'import' and $this->method == 'POST') {
76+
if (empty($this->postFiles)) {
77+
throw new Exception('You must provide a template file');
78+
}
79+
80+
/**
81+
* Only one file is allowed
82+
*/
83+
if (count($this->postFiles) > 1) {
84+
throw new Exception('Please, only provide one file at a time');
85+
}
86+
87+
/**
88+
* The file must be prefixed with name 'template'
89+
*/
90+
if (!isset($this->postFiles['template'])) {
91+
throw new Exception('The file must be prefixed with "template"');
92+
}
93+
94+
/**
95+
* Import source repositories from the template file
96+
*/
97+
$mysource->importYamlFromApi($this->postFiles['template']['tmp_name']);
98+
99+
return array('results' => 'Source repositories imported successfully');
100+
}
101+
102+
/**
103+
* Else, return source repository details by its name
104+
*/
105+
if ($this->nameOrAction != 'import') {
106+
if ($this->method == 'GET') {
107+
return array('results' => $mysource->get($this->type, $this->nameOrAction));
108+
}
109+
}
110+
}
111+
}
112+
113+
throw new Exception('Invalid request');
114+
}
115+
}

www/controllers/App/Config/Main.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ public static function get()
160160
define('SERVICE_RUNNING', \Controllers\Service\Service::isRunning());
161161
}
162162

163+
/**
164+
* Source repositories lists dir
165+
*/
166+
// Default source repositories lists dir (from github)
167+
if (!defined('DEFAULT_SOURCES_REPOS_LISTS_DIR')) {
168+
define('DEFAULT_SOURCES_REPOS_LISTS_DIR', ROOT . '/templates/source-repositories');
169+
}
170+
// Custom source repositories lists dir (made by the user)
171+
if (!defined('CUSTOM_SOURCES_REPOS_LISTS_DIR')) {
172+
define('CUSTOM_SOURCES_REPOS_LISTS_DIR', DATA_DIR . '/templates/source-repositories');
173+
}
174+
163175
/**
164176
* Load system constants
165177
*/

www/controllers/App/Config/Notification.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public static function get()
3838
$message = '<span>A new release is available: ';
3939
}
4040

41-
$message .= '<a href="https://github.com/lbr38/repomanager/releases/latest" target="_blank" rel="noopener noreferrer" title="See changelog"><code>' . GIT_VERSION . '</code><img src="/assets/icons/external-link.svg" class="icon" /></a>';
42-
$message .= '<br><br><span>Please update your docker image by following the steps documented <b><a href="' . PROJECT_UPDATE_DOC_URL . '"><code>here</code></a></b></span>';
41+
$message .= '<a href="https://github.com/lbr38/repomanager/releases/latest" target="_blank" rel="noopener noreferrer" title="See changelog"><code>' . GIT_VERSION . '</code> <img src="/assets/icons/external-link.svg" class="icon" /></a>';
42+
$message .= '<br><br><span>Please update your docker image by following the steps documented <b><a href="' . PROJECT_UPDATE_DOC_URL . '" target="_blank" rel="noopener noreferrer"><code>here</code></b> <img src="/assets/icons/external-link.svg" class="icon" /></a></span>';
4343

4444
$NOTIFICATION_MESSAGES[] = array('Title' => 'Update available', 'Message' => $message);
4545
$NOTIFICATION++;

www/controllers/App/Config/Settings.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function get()
6868
define('EMAIL_RECIPIENT', explode(',', $settings['EMAIL_RECIPIENT']));
6969
} else {
7070
define('EMAIL_RECIPIENT', array());
71-
$__LOAD_SETTINGS_MESSAGES[] = '<code>Default contact</code> setting is not defined. At least one email address should be defined.';
71+
$__LOAD_SETTINGS_MESSAGES[] = '<code>DEFAULT CONTACT</code> setting is not defined. At least one email address should be defined.';
7272
}
7373
}
7474

@@ -175,7 +175,7 @@ public static function get()
175175
* Print a message only if RPM repositories are enabled.
176176
*/
177177
if (RPM_REPO == 'true') {
178-
$__LOAD_SETTINGS_MESSAGES[] = "<code>Default release version</code> setting is not defined.";
178+
$__LOAD_SETTINGS_MESSAGES[] = "<code>DEFAULT RELEASE VERSION</code> setting is not defined.";
179179
}
180180
}
181181
}
@@ -264,7 +264,7 @@ public static function get()
264264
define('STATS_ENABLED', $settings['STATS_ENABLED']);
265265
} else {
266266
define('STATS_ENABLED', '');
267-
$__LOAD_SETTINGS_MESSAGES[] = "<code>Enable repositories statistics</code> setting is not defined.";
267+
$__LOAD_SETTINGS_MESSAGES[] = "<code>ENABLE REPOSITORIES STATISTICS</code> setting is not defined.";
268268
}
269269
}
270270

@@ -301,7 +301,7 @@ public static function get()
301301
define('MANAGE_HOSTS', $settings['MANAGE_HOSTS']);
302302
} else {
303303
define('MANAGE_HOSTS', '');
304-
$__LOAD_SETTINGS_MESSAGES[] = "<code>Manage hosts</code> setting is not defined.";
304+
$__LOAD_SETTINGS_MESSAGES[] = "<code>MANAGE HOSTS</code> setting is not defined.";
305305
}
306306
}
307307

@@ -310,7 +310,7 @@ public static function get()
310310
define('MANAGE_PROFILES', $settings['MANAGE_PROFILES']);
311311
} else {
312312
define('MANAGE_PROFILES', '');
313-
$__LOAD_SETTINGS_MESSAGES[] = "<code>Manage profiles</code> setting is not defined.";
313+
$__LOAD_SETTINGS_MESSAGES[] = "<code>MANAGE PROFILES</code> setting is not defined.";
314314
}
315315
}
316316

www/controllers/App/Config/System.php

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -124,76 +124,5 @@ public static function get()
124124
define('__QUERY_STRING__', '');
125125
}
126126
}
127-
128-
/**
129-
* Retrieve OS name and version
130-
*/
131-
if (!is_readable('/etc/os-release')) {
132-
echo 'Error: cannot determine OS release';
133-
die;
134-
}
135-
136-
$os = file_get_contents('/etc/os-release');
137-
$listIds = preg_match_all('/.*=/', $os, $matchListIds);
138-
$listIds = $matchListIds[0];
139-
$listVal = preg_match_all('/=.*/', $os, $matchListVal);
140-
$listVal = $matchListVal[0];
141-
142-
array_walk($listIds, function (&$v, $k) {
143-
$v = strtolower(str_replace('=', '', $v));
144-
});
145-
146-
array_walk($listVal, function (&$v, $k) {
147-
$v = preg_replace('/=|"/', '', $v);
148-
});
149-
150-
if (!defined('OS_INFO')) {
151-
define('OS_INFO', array_combine($listIds, $listVal));
152-
}
153-
154-
unset($os, $listIds, $listVal);
155-
156-
/**
157-
* Puis à partir de l'array OS_INFO on détermine la famille d'os, son nom et sa version
158-
*/
159-
if (!empty(OS_INFO['id_like'])) {
160-
if (preg_match('(rhel|centos|fedora)', OS_INFO['id_like']) === 1) {
161-
if (!defined('OS_FAMILY')) {
162-
define('OS_FAMILY', "Redhat");
163-
}
164-
}
165-
if (preg_match('(debian|ubuntu|kubuntu|xubuntu|armbian|mint)', OS_INFO['id_like']) === 1) {
166-
if (!defined('OS_FAMILY')) {
167-
define('OS_FAMILY', "Debian");
168-
}
169-
}
170-
} else if (!empty(OS_INFO['id'])) {
171-
if (preg_match('(rhel|centos|fedora)', OS_INFO['id']) === 1) {
172-
if (!defined('OS_FAMILY')) {
173-
define('OS_FAMILY', "Redhat");
174-
}
175-
}
176-
if (preg_match('(debian|ubuntu|kubuntu|xubuntu|armbian|mint)', OS_INFO['id']) === 1) {
177-
if (!defined('OS_FAMILY')) {
178-
define('OS_FAMILY', "Debian");
179-
}
180-
}
181-
}
182-
183-
if (!defined('OS_FAMILY')) {
184-
die('Error: system is not compatible');
185-
}
186-
187-
if (!defined('OS_NAME')) {
188-
define('OS_NAME', trim(OS_INFO['name']));
189-
}
190-
191-
if (!defined('OS_ID')) {
192-
define('OS_ID', trim(OS_INFO['id']));
193-
}
194-
195-
if (!defined('OS_VERSION')) {
196-
define('OS_VERSION', trim(OS_INFO['version_id']));
197-
}
198127
}
199128
}

www/controllers/App/Structure/Directory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public static function create()
2323
TEMP_DIR,
2424
HOSTS_DIR,
2525
DB_UPDATE_DONE_DIR,
26-
DATA_DIR . '/ssl'
26+
CUSTOM_SOURCES_REPOS_LISTS_DIR . '/rpm',
27+
CUSTOM_SOURCES_REPOS_LISTS_DIR . '/deb',
2728
);
2829

2930
foreach ($dirs as $dir) {

0 commit comments

Comments
 (0)