Skip to content

Commit

Permalink
4.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Nov 1, 2024
1 parent 59f20e8 commit 3c7d01f
Show file tree
Hide file tree
Showing 182 changed files with 8,740 additions and 4,837 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ jobs:
- name: Print PHP version
run: php --version

# TODO : temporaire
# A retirer une fois que 4.12.0 est publiée
- name: Install PHP yaml extension
run: apt-get update -y && apt-get install -y php8.3-yaml

# Copy latest source code to the root directory
- name: Setup latest source code
run: |
Expand Down Expand Up @@ -88,6 +93,11 @@ jobs:
- name: Print PHP version
run: php --version

# TODO : temporaire
# A retirer une fois que 4.12.0 est publiée
- name: Install PHP yaml extension
run: apt-get update -y && apt-get install -y php8.3-yaml

# Copy latest source code to the root directory
- name: Setup latest source code
run: |
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN echo "deb https://packages.bespin.ovh/repo/repomanager-php/bookworm/main_pro
RUN apt-get update -y

# Install nginx and PHP 8.3
RUN apt-get install nginx php8.3-fpm php8.3-cli php8.3-sqlite3 php8.3-xml php8.3-curl sqlite3 -y
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

# Clone project in the container
RUN git clone https://github.com/lbr38/repomanager.git /tmp/repomanager
Expand Down
12 changes: 8 additions & 4 deletions www/config/properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
'project_git_repo_raw' => 'https://raw.githubusercontent.com/lbr38/repomanager/stable',
'project_update_doc_url' => 'https://github.com/lbr38/repomanager/wiki/01.-Installation-and-update#update-repomanager',

// Debian repo default values
'debian_distributions' => array('bookworm' => 'Debian 12', 'bullseye' => 'Debian 11', 'buster' => 'Debian 10', 'stretch' => 'Debian 9', 'jessie' => 'Debian 8', 'wheezy' => 'Debian 7'),
'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'),
'sections' => array('main', 'contrib', 'non-free', 'restricted', 'universe', 'multiverse'),
// RPM release versions default values
'rpm_releasevers' => array('9' => 'RHEL 9 and derivatives', '8' => 'RHEL 8 and derivatives', '7' => 'RHEL 7 and derivatives'),

// DEB distributions default values
'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'),

// DEB components default values
'deb_components' => array('main', 'contrib', 'non-free', 'restricted', 'universe', 'multiverse'),

// DEB default values
'deb_archs' => array('amd64', 'arm64', 'armel', 'armhf', 'i386', 'mips', 'mips64el', 'mipsel', 'ppc64el', 's390x', 'src'),
Expand Down
115 changes: 115 additions & 0 deletions www/controllers/Api/Source/Source.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php

namespace Controllers\Api\Source;

use Exception;
use Datetime;

class Source extends \Controllers\Api\Controller
{
private $source;
private $type;
private $component;
private $nameOrAction;
private $postFiles;

public function execute()
{
$mysource = new \Controllers\Repo\Source\Source();

/**
* Source repositories actions are only allowed for API admins
*/
if (!IS_API_ADMIN) {
throw new Exception('You are not allowed to access this resource.');
}

/**
* Retrieve source repository and actions from URI
*/
if (isset($this->uri[4])) {
$this->type = $this->uri[4];
}
if (isset($this->uri[5])) {
$this->nameOrAction = $this->uri[5];
}

/**
* Retrieve uploaded FILES if any
*/
if (!empty($_FILES)) {
$this->postFiles = $_FILES;
}

/**
* https://repomanager.mydomain.net/api/v2/source/
* Print all source repositories
*/
if (empty($this->type) and $this->method == 'GET') {
return array('results' => $mysource->listAll());
}

/**
* If a source type is specified (deb, rpm)
* https://repomanager.mydomain.net/api/v2/source/$this->type/
*/
if (!empty($this->type)) {
if (!in_array($this->type, array('deb', 'rpm'))) {
throw new Exception('Invalid source type');
}

/**
* If no source name or action is specified, then list all sources of the specified type
*/
if (empty($this->nameOrAction) and $this->method == 'GET') {
return array('results' => $mysource->listAll($this->type));
}

/**
* If a source repo name or an action is specified
*/
if (!empty($this->nameOrAction)) {
/**
* If the action is import, import source repositories from a template file
*/
if ($this->nameOrAction == 'import' and $this->method == 'POST') {
if (empty($this->postFiles)) {
throw new Exception('You must provide a template file');
}

/**
* Only one file is allowed
*/
if (count($this->postFiles) > 1) {
throw new Exception('Please, only provide one file at a time');
}

/**
* The file must be prefixed with name 'template'
*/
if (!isset($this->postFiles['template'])) {
throw new Exception('The file must be prefixed with "template"');
}

/**
* Import source repositories from the template file
*/
$mysource->importYamlFromApi($this->postFiles['template']['tmp_name']);

return array('results' => 'Source repositories imported successfully');
}

/**
* Else, return source repository details by its name
*/
if ($this->nameOrAction != 'import') {
if ($this->method == 'GET') {
return array('results' => $mysource->get($this->type, $this->nameOrAction));
}
}
}
}

throw new Exception('Invalid request');
}
}
12 changes: 12 additions & 0 deletions www/controllers/App/Config/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ public static function get()
define('SERVICE_RUNNING', \Controllers\Service\Service::isRunning());
}

/**
* Source repositories lists dir
*/
// Default source repositories lists dir (from github)
if (!defined('DEFAULT_SOURCES_REPOS_LISTS_DIR')) {
define('DEFAULT_SOURCES_REPOS_LISTS_DIR', ROOT . '/templates/source-repositories');
}
// Custom source repositories lists dir (made by the user)
if (!defined('CUSTOM_SOURCES_REPOS_LISTS_DIR')) {
define('CUSTOM_SOURCES_REPOS_LISTS_DIR', DATA_DIR . '/templates/source-repositories');
}

/**
* Load system constants
*/
Expand Down
4 changes: 2 additions & 2 deletions www/controllers/App/Config/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public static function get()
$message = '<span>A new release is available: ';
}

$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>';
$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>';
$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>';
$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>';

$NOTIFICATION_MESSAGES[] = array('Title' => 'Update available', 'Message' => $message);
$NOTIFICATION++;
Expand Down
10 changes: 5 additions & 5 deletions www/controllers/App/Config/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function get()
define('EMAIL_RECIPIENT', explode(',', $settings['EMAIL_RECIPIENT']));
} else {
define('EMAIL_RECIPIENT', array());
$__LOAD_SETTINGS_MESSAGES[] = '<code>Default contact</code> setting is not defined. At least one email address should be defined.';
$__LOAD_SETTINGS_MESSAGES[] = '<code>DEFAULT CONTACT</code> setting is not defined. At least one email address should be defined.';
}
}

Expand Down Expand Up @@ -175,7 +175,7 @@ public static function get()
* Print a message only if RPM repositories are enabled.
*/
if (RPM_REPO == 'true') {
$__LOAD_SETTINGS_MESSAGES[] = "<code>Default release version</code> setting is not defined.";
$__LOAD_SETTINGS_MESSAGES[] = "<code>DEFAULT RELEASE VERSION</code> setting is not defined.";
}
}
}
Expand Down Expand Up @@ -264,7 +264,7 @@ public static function get()
define('STATS_ENABLED', $settings['STATS_ENABLED']);
} else {
define('STATS_ENABLED', '');
$__LOAD_SETTINGS_MESSAGES[] = "<code>Enable repositories statistics</code> setting is not defined.";
$__LOAD_SETTINGS_MESSAGES[] = "<code>ENABLE REPOSITORIES STATISTICS</code> setting is not defined.";
}
}

Expand Down Expand Up @@ -301,7 +301,7 @@ public static function get()
define('MANAGE_HOSTS', $settings['MANAGE_HOSTS']);
} else {
define('MANAGE_HOSTS', '');
$__LOAD_SETTINGS_MESSAGES[] = "<code>Manage hosts</code> setting is not defined.";
$__LOAD_SETTINGS_MESSAGES[] = "<code>MANAGE HOSTS</code> setting is not defined.";
}
}

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

Expand Down
71 changes: 0 additions & 71 deletions www/controllers/App/Config/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,76 +124,5 @@ public static function get()
define('__QUERY_STRING__', '');
}
}

/**
* Retrieve OS name and version
*/
if (!is_readable('/etc/os-release')) {
echo 'Error: cannot determine OS release';
die;
}

$os = file_get_contents('/etc/os-release');
$listIds = preg_match_all('/.*=/', $os, $matchListIds);
$listIds = $matchListIds[0];
$listVal = preg_match_all('/=.*/', $os, $matchListVal);
$listVal = $matchListVal[0];

array_walk($listIds, function (&$v, $k) {
$v = strtolower(str_replace('=', '', $v));
});

array_walk($listVal, function (&$v, $k) {
$v = preg_replace('/=|"/', '', $v);
});

if (!defined('OS_INFO')) {
define('OS_INFO', array_combine($listIds, $listVal));
}

unset($os, $listIds, $listVal);

/**
* Puis à partir de l'array OS_INFO on détermine la famille d'os, son nom et sa version
*/
if (!empty(OS_INFO['id_like'])) {
if (preg_match('(rhel|centos|fedora)', OS_INFO['id_like']) === 1) {
if (!defined('OS_FAMILY')) {
define('OS_FAMILY', "Redhat");
}
}
if (preg_match('(debian|ubuntu|kubuntu|xubuntu|armbian|mint)', OS_INFO['id_like']) === 1) {
if (!defined('OS_FAMILY')) {
define('OS_FAMILY', "Debian");
}
}
} else if (!empty(OS_INFO['id'])) {
if (preg_match('(rhel|centos|fedora)', OS_INFO['id']) === 1) {
if (!defined('OS_FAMILY')) {
define('OS_FAMILY', "Redhat");
}
}
if (preg_match('(debian|ubuntu|kubuntu|xubuntu|armbian|mint)', OS_INFO['id']) === 1) {
if (!defined('OS_FAMILY')) {
define('OS_FAMILY', "Debian");
}
}
}

if (!defined('OS_FAMILY')) {
die('Error: system is not compatible');
}

if (!defined('OS_NAME')) {
define('OS_NAME', trim(OS_INFO['name']));
}

if (!defined('OS_ID')) {
define('OS_ID', trim(OS_INFO['id']));
}

if (!defined('OS_VERSION')) {
define('OS_VERSION', trim(OS_INFO['version_id']));
}
}
}
3 changes: 2 additions & 1 deletion www/controllers/App/Structure/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public static function create()
TEMP_DIR,
HOSTS_DIR,
DB_UPDATE_DONE_DIR,
DATA_DIR . '/ssl'
CUSTOM_SOURCES_REPOS_LISTS_DIR . '/rpm',
CUSTOM_SOURCES_REPOS_LISTS_DIR . '/deb',
);

foreach ($dirs as $dir) {
Expand Down
Loading

0 comments on commit 3c7d01f

Please sign in to comment.