Compare commits

...

9 Commits

Author SHA1 Message Date
56ced43f2d maj deps php8.2 2025-02-13 11:55:45 +04:00
10ce93ffd6 bug 2025-02-13 11:45:28 +04:00
6b53078180 runphp: tenir compte des codes de retour 2025-02-13 11:37:22 +04:00
b64221ad84 réorganiser runphp 2025-02-13 11:25:25 +04:00
6a2e879dc4 maj dist 2025-02-12 12:06:01 +04:00
1a42d8adec ajout cv::complen 2025-02-05 06:26:41 +04:00
de3b84441d maj deps 2025-01-30 17:25:02 +04:00
b50d881e7f maj compat nur/sery 2025-01-30 08:25:31 +04:00
756502361f compat avec les nur/sery 2025-01-29 11:27:25 +04:00
26 changed files with 613 additions and 889 deletions

View File

@ -4,8 +4,230 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "356c1dcfe9eee39e9e6eadff4f63cdfe",
"packages": [],
"content-hash": "ab280aa4a5f5c83fa488537530b29759",
"packages": [
{
"name": "symfony/deprecation-contracts",
"version": "v2.5.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "605389f2a7e5625f273b53960dc46aeaf9c62918"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918",
"reference": "605389f2a7e5625f273b53960dc46aeaf9c62918",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "2.5-dev"
}
},
"autoload": {
"files": [
"function.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-25T14:11:13+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.31.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"provide": {
"ext-ctype": "*"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-09T11:45:10+00:00"
},
{
"name": "symfony/yaml",
"version": "v5.4.45",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "a454d47278cc16a5db371fe73ae66a78a633371e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/a454d47278cc16a5db371fe73ae66a78a633371e",
"reference": "a454d47278cc16a5db371fe73ae66a78a633371e",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
"symfony/console": "<5.3"
},
"require-dev": {
"symfony/console": "^5.3|^6.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"bin": [
"Resources/bin/yaml-lint"
],
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/yaml/tree/v5.4.45"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-25T14:11:13+00:00"
}
],
"packages-dev": [
{
"name": "doctrine/instantiator",
@ -79,16 +301,16 @@
},
{
"name": "myclabs/deep-copy",
"version": "1.12.0",
"version": "1.12.1",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c"
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c",
"reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845",
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845",
"shasum": ""
},
"require": {
@ -127,7 +349,7 @@
],
"support": {
"issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.12.0"
"source": "https://github.com/myclabs/DeepCopy/tree/1.12.1"
},
"funding": [
{
@ -135,20 +357,20 @@
"type": "tidelift"
}
],
"time": "2024-06-12T14:39:25+00:00"
"time": "2024-11-08T17:47:46+00:00"
},
{
"name": "nikic/php-parser",
"version": "v5.3.1",
"version": "v5.4.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "8eea230464783aa9671db8eea6f8c6ac5285794b"
"reference": "447a020a1f875a434d62f2a401f53b82a396e494"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b",
"reference": "8eea230464783aa9671db8eea6f8c6ac5285794b",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494",
"reference": "447a020a1f875a434d62f2a401f53b82a396e494",
"shasum": ""
},
"require": {
@ -191,9 +413,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1"
"source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0"
},
"time": "2024-10-08T18:51:32+00:00"
"time": "2024-12-30T11:07:19+00:00"
},
{
"name": "nulib/tests",
@ -201,7 +423,7 @@
"source": {
"type": "git",
"url": "https://git.univ-reunion.fr/sda-php/nulib-tests.git",
"reference": "6ce8257560b42e8fb3eea03eba84d3877c9648ca"
"reference": "9b5c9c295c3dee6fc02ccddbd8a70bca797c8045"
},
"require": {
"php": ">=7.3",
@ -225,7 +447,7 @@
}
],
"description": "fonctions et classes pour les tests",
"time": "2024-03-26T10:56:17+00:00"
"time": "2025-01-30T13:18:31+00:00"
},
{
"name": "phar-io/manifest",
@ -666,16 +888,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.6.21",
"version": "9.6.22",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa"
"reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa",
"reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f80235cb4d3caa59ae09be3adf1ded27521d1a9c",
"reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c",
"shasum": ""
},
"require": {
@ -686,7 +908,7 @@
"ext-mbstring": "*",
"ext-xml": "*",
"ext-xmlwriter": "*",
"myclabs/deep-copy": "^1.12.0",
"myclabs/deep-copy": "^1.12.1",
"phar-io/manifest": "^2.0.4",
"phar-io/version": "^3.2.1",
"php": ">=7.3",
@ -749,7 +971,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.22"
},
"funding": [
{
@ -765,7 +987,7 @@
"type": "tidelift"
}
],
"time": "2024-09-19T10:50:18+00:00"
"time": "2024-12-05T13:48:26+00:00"
},
{
"name": "sebastian/cli-parser",
@ -1787,6 +2009,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"ext-json": "*",
"php": "^7.4"
},
"platform-dev": {

View File

@ -4,5 +4,5 @@
RUNPHP=
# Si RUNPHP n'est pas défini, les variables suivantes peuvent être définies
DIST=d11
#REGISTRY=pubdocker.univ-reunion.fr
DIST=d12
#REGISTRY=pubdocker.univ-reunion.fr/dist

View File

@ -22,7 +22,7 @@ done
if [ -z "$PROJDIR" ]; then
# s'il n'y a pas de projet, --bs est l'action par défaut
[ $# -gt 0 ] || set -- --bs
[ $# -gt 0 ] || set -- --bs --ue
elif [ "$MYNAME" == composer ]; then
set -- composer "$@"
else

View File

@ -15,12 +15,12 @@
}
},
"require": {
"symfony/yaml": "^5.0",
"symfony/yaml": "^7.1",
"ext-json": "*",
"php": "^7.4"
"php": "^8.2"
},
"require-dev": {
"nulib/tests": "7.4",
"nulib/tests": "8.2",
"ext-posix": "*",
"ext-pcntl": "*",
"ext-curl": "*"

44
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "92c82f1783bab891c66fa145a07f88c7",
"content-hash": "ab280aa4a5f5c83fa488537530b29759",
"packages": [
{
"name": "symfony/deprecation-contracts",
@ -25,12 +25,12 @@
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
@ -99,8 +99,8 @@
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
@ -361,16 +361,16 @@
},
{
"name": "nikic/php-parser",
"version": "v5.3.1",
"version": "v5.4.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "8eea230464783aa9671db8eea6f8c6ac5285794b"
"reference": "447a020a1f875a434d62f2a401f53b82a396e494"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b",
"reference": "8eea230464783aa9671db8eea6f8c6ac5285794b",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494",
"reference": "447a020a1f875a434d62f2a401f53b82a396e494",
"shasum": ""
},
"require": {
@ -413,9 +413,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1"
"source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0"
},
"time": "2024-10-08T18:51:32+00:00"
"time": "2024-12-30T11:07:19+00:00"
},
{
"name": "nulib/tests",
@ -423,7 +423,7 @@
"source": {
"type": "git",
"url": "https://git.univ-reunion.fr/sda-php/nulib-tests.git",
"reference": "6ce8257560b42e8fb3eea03eba84d3877c9648ca"
"reference": "9b5c9c295c3dee6fc02ccddbd8a70bca797c8045"
},
"require": {
"php": ">=7.3",
@ -447,7 +447,7 @@
}
],
"description": "fonctions et classes pour les tests",
"time": "2024-03-26T10:56:17+00:00"
"time": "2025-01-30T13:18:31+00:00"
},
{
"name": "phar-io/manifest",
@ -888,16 +888,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.6.21",
"version": "9.6.22",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa"
"reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa",
"reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f80235cb4d3caa59ae09be3adf1ded27521d1a9c",
"reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c",
"shasum": ""
},
"require": {
@ -908,7 +908,7 @@
"ext-mbstring": "*",
"ext-xml": "*",
"ext-xmlwriter": "*",
"myclabs/deep-copy": "^1.12.0",
"myclabs/deep-copy": "^1.12.1",
"phar-io/manifest": "^2.0.4",
"phar-io/version": "^3.2.1",
"php": ">=7.3",
@ -971,7 +971,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.22"
},
"funding": [
{
@ -987,7 +987,7 @@
"type": "tidelift"
}
],
"time": "2024-09-19T10:50:18+00:00"
"time": "2024-12-05T13:48:26+00:00"
},
{
"name": "sebastian/cli-parser",

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
ARG REGISTRY=pubdocker.univ-reunion.fr/dist
FROM $REGISTRY/src/base AS base
FROM $REGISTRY/src/php AS php

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
ARG REGISTRY=pubdocker.univ-reunion.fr/dist
FROM $REGISTRY/src/base AS base
FROM $REGISTRY/src/instantclient AS instantclient

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG REGISTRY=pubdocker.univ-reunion.fr
ARG REGISTRY=pubdocker.univ-reunion.fr/dist
FROM $REGISTRY/src/base AS base
FROM $REGISTRY/src/mariadb AS mariadb
FROM $REGISTRY/src/legacytools AS legacytools

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
ARG REGISTRY=pubdocker.univ-reunion.fr/dist
FROM $REGISTRY/src/base AS base
FROM $REGISTRY/src/php AS php

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
ARG REGISTRY=pubdocker.univ-reunion.fr/dist
FROM $REGISTRY/src/base AS base
FROM $REGISTRY/src/legacytools AS legacytools

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
ARG REGISTRY=pubdocker.univ-reunion.fr/dist
FROM $REGISTRY/src/base AS base
FROM $REGISTRY/src/php AS php

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
ARG REGISTRY=pubdocker.univ-reunion.fr/dist
FROM $REGISTRY/src/base AS base
FROM $REGISTRY/src/legacytools AS legacytools

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG REGISTRY=pubdocker.univ-reunion.fr
ARG REGISTRY=pubdocker.univ-reunion.fr/dist
FROM $REGISTRY/src/base AS base
FROM $REGISTRY/src/postgres AS postgres

View File

@ -222,4 +222,13 @@ class cv {
if ($a > $b) return 1;
return 0;
}
/** comparer la longueur de $a et $b */
static final function complen($a, $b): int {
if (is_array($a)) $la = count($a);
else $la = strlen(strval($a));
if (is_array($b)) $lb = count($b);
else $lb = strlen(strval($b));
return self::compare($la, $lb);
}
}

View File

@ -309,8 +309,32 @@ class Stream extends AbstractIterator implements IReader, IWriter {
}
}
/** @var bool faut-il faire un mapping pour la compatibilité avec nur/sery */
const NURSERY_COMPAT_ENABLED = true;
/**
* @var string[] mappings pour la compatibilité avec des fichiers générés par
* nur/sery
*/
const NURSERY_COMPAT_MAPPING = [
'O:22:"nur\sery\php\time\Date":' => 'O:19:"nulib\php\time\Date":',
'O:26:"nur\sery\php\time\DateTime":' => 'O:23:"nulib\php\time\DateTime":',
'O:23:"nur\sery\php\time\Delay":' => 'O:20:"nulib\php\time\Delay":',
];
static function nursery_compat_verifix(string $contents): string {
if (static::NURSERY_COMPAT_ENABLED) {
foreach (self::NURSERY_COMPAT_MAPPING as $from => $to) {
$contents = str_replace($from, $to, $contents);
}
}
return $contents;
}
function unserialize(?array $options=null, bool $close=true, bool $alreadyLocked=false) {
$args = [$this->getContents($close, $alreadyLocked)];
$contents = $this->getContents($close, $alreadyLocked);
$contents = self::nursery_compat_verifix($contents);
$args = [$contents];
if ($options !== null) $args[] = $options;
return unserialize(...$args);
}

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
ARG REGISTRY=pubdocker.univ-reunion.fr/dist
FROM $REGISTRY/src/base AS base
FROM $REGISTRY/src/php AS php

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 mode: dockerfile -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
ARG NDIST=12
ARG REGISTRY=pubdocker.univ-reunion.fr
ARG REGISTRY=pubdocker.univ-reunion.fr/dist
FROM $REGISTRY/src/base AS base
FROM $REGISTRY/src/legacytools AS legacytools

View File

@ -2,7 +2,7 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
MYDIR="$(cd "$(dirname -- "$0")"; pwd)"
RUNPHP="$MYDIR/runphp"
"$RUNPHP" --bs --ue --ci || exit 1
"$RUNPHP" --bs --ue || exit 1
RUNPHP_STANDALONE=
PROJDIR=; COMPOSERDIR=; COMPOSERPHAR=; VENDORDIR=; BUILDENV0=; BUILDENV=
BUILD_IMAGES=(php-apache mariadb10); export BUILD_FLAVOUR=; DIST=; IMAGENAME=

View File

@ -14,8 +14,8 @@ PRIVAREG=
################################################################################
# Ne pas toucher à partir d'ici
REGISTRY=pubdocker.univ-reunion.fr
REGISTRY=pubdocker.univ-reunion.fr/dist
DIST=d12
IMAGENAME=runphp
IMAGENAME=nulib/
#DEVUSER_USERENT=user:x:1000:1000:User,,,:/home/user:/bin/bash
#DEVUSER_GROUPENT=user:x:1000:

View File

@ -1,5 +1,4 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
default_profile "${DKBUILD_PROFILE:-prod}"
# Source des paquets et proxy
setenv APT_PROXY=
@ -9,20 +8,5 @@ setenv SEC_MIRROR=default
# Timezone du serveur
setenv TIMEZONE=Europe/Paris
if profile prod test; then
setenv REGISTRY=pubdocker.univ-reunion.fr
setenv PRIVAREG=pridocker.univ-reunion.fr
host_mappings=(
pridocker.univ-reunion.fr:10.85.1.56
pubdocker.univ-reunion.fr:10.85.1.57
repos.univ-reunion.fr:10.85.1.57
git.univ-reunion.fr:10.85.1.55
)
default docker host-mappings="${host_mappings[*]}"
elif profile devel; then
setenv REGISTRY=docker.devel.self
setenv PRIVAREG=docker.devel.self
else
setenv REGISTRY=pubdocker.univ-reunion.fr
setenv PRIVAREG=
fi
setenv REGISTRY=pubdocker.univ-reunion.fr/dist
setenv PRIVAREG=

View File

@ -5,4 +5,4 @@ RUNPHP=
# Si RUNPHP n'est pas défini, les variables suivantes peuvent être définies
#DIST=d12
#REGISTRY=pubdocker.univ-reunion.fr
#REGISTRY=pubdocker.univ-reunion.fr/dist

View File

@ -33,7 +33,7 @@ BUILDENV0=
BUILDENV=
# Listes des images que le script build construit automatiquement
BUILD_IMAGES=()
BUILD_IMAGES=(php-apache mariadb10)
BUILD_FLAVOUR=
## En ce qui concerne DIST et IMAGENAME, les valeurs dans BUILDENV prennent le
@ -117,9 +117,12 @@ function eerror() { eecho "ERROR: $*"; }
function die() { [ $# -gt 0 ] && eerror "$*"; exit 1; }
function is_defined() { [ -n "$(declare -p "$1" 2>/dev/null)" ]; }
function in_path() { [ -n "$1" -a -x "$(which "$1" 2>/dev/null)" ]; }
function composer() {
cd "$PROJDIR/$COMPOSERDIR" || exit 1
if [ -n "$COMPOSERPHAR" -a -x "$PROJDIR/$COMPOSERPHAR" ]; then
if [ -n "$PROJDIR" -a -n "$COMPOSERDIR" ]; then
cd "$PROJDIR/$COMPOSERDIR" || exit 1
fi
if [ -n "$PROJDIR" -a -n "$COMPOSERPHAR" -a -x "$PROJDIR/$COMPOSERPHAR" ]; then
"$PROJDIR/$COMPOSERPHAR" "$@"
elif in_path composer; then
command composer "$@"
@ -130,11 +133,40 @@ function composer() {
else
die "impossible de trouver composer"
fi
if [ -z "$RUNPHP_STANDALONE" -a -f composer.lock ]; then
if [ -n "$PROJDIR" -a -z "$RUNPHP_STANDALONE" -a -f composer.lock ]; then
cp composer.lock "$PROJDIR/.composer.lock.runphp"
fi
}
function ensure_image() {
function host_parse_args() {
# analyser les arguments et calculer les opérations à lancer: bootstrap,
# composer install et/ou commande
# faut-il lancer bootstrap?
Bootstrap=auto
# faut-il installer les dépendances?
Composer=
# commande à lancer
Cmd=()
if [ "$1" == --runphp-bootstrap -o "$1" == --bs ]; then
Bootstrap=1
shift
elif [ "$1" == --runphp-exec ]; then
Bootstrap=
shift
elif [ "$1" == --runphp-install -o "$1" == --ci ]; then
Composer=ci
shift
elif [ "$1" == --runphp-update -o "$1" == --cu ]; then
Composer=cu
shift
fi
Cmd=("$@")
}
function host_ensure_image() {
# calculer le nom de l'image runphp
local dfdir suffix dockerfiles dockerfile
local privareg imagename
if [ -z "$Image" ]; then
@ -161,7 +193,9 @@ function ensure_image() {
Image="$privareg/$imagename$suffix:$DIST"
fi
}
function check_image() {
function host_check_image() {
# vérifier que l'image runphp existe
local image="$Image"
for prefix in docker.io/library/ docker.io; do
if [ "${image#$prefix}" != "$image" ]; then
@ -172,43 +206,25 @@ function check_image() {
[ -n "$(docker image ls --no-trunc --format '{{.Repository}}:{{.Tag}}' "$image" 2>/dev/null)" ]
}
## Arguments initiaux
function host_check_projdir() {
# vérifier le projet pour voir s'il faut installer les dépendances
[ -n "$RUNPHP_STANDALONE" ] && return
Bootstrap=
ComposerInstall=
if [ "$1" == --runphp-bootstrap -o "$1" == --bs ]; then
Bootstrap=1
shift
elif [ "$1" == --runphp-exec ]; then
Bootstrap=
shift
elif [ "$1" == --runphp-install -o "$1" == --ci ]; then
ComposerInstall=1
shift
fi
ForcedBootstrap=
if [ -z "$Bootstrap" -a -z "$RUNPHP_STANDALONE" ]; then
# si vendor/ n'existe pas, alors on doit faire bootstrap
local install
if [ ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
ForcedBootstrap=1
install=1
elif [ ! -f "$PROJDIR/.composer.lock.runphp" ]; then
ForcedBootstrap=1
install=1
elif ! diff -q "$PROJDIR/$COMPOSERDIR/composer.lock" "$PROJDIR/.composer.lock.runphp" >&/dev/null; then
ForcedBootstrap=1
install=1
fi
if [ -n "$ForcedBootstrap" ]; then
[ "$RUNPHP_MODE" != docker ] && eecho "== bootstrapping runphp"
Bootstrap=1
ComposerInstall=1
if [ -n "$install" ]; then
eecho "== bootstrapping runphp"
[ -n "$Composer" ] || Composer=ci
fi
fi
if [ "$RUNPHP_MODE" != docker ]; then
############################################################################
# Lancement depuis l'extérieur du container
############################################################################
}
function host_init_env() {
## Charger ~/.dkbuild.env
APT_PROXY=
@ -259,7 +275,7 @@ if [ "$RUNPHP_MODE" != docker ]; then
[ -n "$SEC_MIRROR" ] || SEC_MIRROR=default
[ -n "$TIMEZONE" ] || TIMEZONE=Europe/Paris
[ -n "$PRIVAREG" ] || PRIVAREG=
[ -n "$REGISTRY" ] || REGISTRY=pubdocker.univ-reunion.fr
[ -n "$REGISTRY" ] || REGISTRY=pubdocker.univ-reunion.fr/dist
## Charger la configuration
@ -281,162 +297,151 @@ if [ "$RUNPHP_MODE" != docker ]; then
UseRslave=1
fi
# Toujours vérifier l'existence de l'image
Image=
if [ -z "$Bootstrap" ]; then
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
for config in "${Configs[@]}"; do
source "$config" || exit 1
done
after_source_buildenv
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
source "$PROJDIR/$BUILDENV" || exit 1
after_source_buildenv
elif [ -n "$BUILDENV0" -a -f "$PROJDIR/$BUILDENV0" ]; then
source "$PROJDIR/$BUILDENV0" || exit 1
after_source_buildenv
fi
ensure_image
check_image || Bootstrap=1
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
Configs=("$PROJDIR/$BUILDENV")
elif [ -n "$BUILDENV0" -a -f "$PROJDIR/$BUILDENV0" ]; then
Configs=("$PROJDIR/$BUILDENV0")
else
Configs=()
fi
for config in "${Configs[@]}"; do
source "$config" || exit 1
done
after_source_buildenv
Chdir=
Verbose="$RUNPHP_VERBOSE"
if [ -n "$Bootstrap" ]; then
## Mode bootstrap de l'image ###########################################
# Ici, on a déterminé que l'image doit être construite
}
BUILD_ARGS=(
DIST NDIST
REGISTRY
APT_PROXY
APT_MIRROR
SEC_MIRROR
TIMEZONE
)
function host_docker_build() {
BUILD_ARGS=(
DIST NDIST
REGISTRY
APT_PROXY
APT_MIRROR
SEC_MIRROR
TIMEZONE
)
SOPTS=+d:9876543210:c:UjDx:z:r:p
LOPTS=help,dist:,d19,d18,d17,d16,d15,d14,d13,d12,d11,d10,config:,ue,unless-exists,pull,nc,no-cache,po,plain-output,apt-proxy:,timezone:,privareg:,push,ci,no-use-rslave
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
SOPTS=+d:9876543210:c:UjDx:z:r:p
LOPTS=help,dist:,d19,d18,d17,d16,d15,d14,d13,d12,d11,d10,config:,ue,unless-exists,pull,nc,no-cache,po,plain-output,apt-proxy:,timezone:,privareg:,push,ci,no-use-rslave
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
Dist=
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
Configs=("$PROJDIR/$BUILDENV")
elif [ -n "$BUILDENV0" -a -f "$PROJDIR/$BUILDENV0" ]; then
Configs=("$PROJDIR/$BUILDENV0")
else
Configs=()
fi
UnlessExists=
Pull=
NoCache=
PlainOutput=
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
--help)
eecho "\
Dist=
UnlessExists=
Pull=
NoCache=
PlainOutput=
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
--help)
eecho "\
runphp: construire l'image docker
USAGE
$MYNAME --bootstrap [options...]
$MYNAME --bs [options...]
OPTIONS
-c, --config build.env
--unless-exists
-d, --dist DIST
--ue, --unless-exists
-U, --pull
-j, --no-cache
-D, --plain-output
-j, --nc, --no-cache
-D, --po, --plain-output
-x, --apt-proxy APT_PROXY
-z, --timezone TIMEZONE
-r, --privareg PRIVAREG
-p, --push
paramètres pour la consruction de l'image"
exit 0
;;
-d|--dist) shift; Dist="$1";;
-[0-9]) Dist="d1${1#-}";;
--d*) Dist="${1#--}";;
-c|--config) shift; Configs+="$1";;
--ue|--unless-exists) UnlessExists=1;;
-U|--pull) Pull=1;;
-j|--nc|--no-cache) NoCache=1;;
-D|--po|--plain-output) PlainOutput=1;;
-x|--apt-proxy) shift; APT_PROXY="$1";;
-z|--timezone) shift; TIMEZONE="$1";;
-r|--privareg) shift; PRIVAREG="$1";;
-p|--push) Push=1;;
--ci) ComposerInstall=1;;
--no-use-rslave) UseRslave=;;
*) die "$1: option non configurée";;
esac
shift
done
paramètres pour la consruction de l'image
--ci
--cu
lancer composer install (resp. update) après bootstrap
--no-use-rslave
paramètre montage des volumes"
exit 0
;;
-c|--config) shift; Configs+=("$1");;
-d|--dist) shift; Dist="$1";;
-[0-9]) Dist="d1${1#-}";;
--d*) Dist="${1#--}";;
--ue|--unless-exists) UnlessExists=1;;
-U|--pull) Pull=1;;
-j|--nc|--no-cache) NoCache=1;;
-D|--po|--plain-output) PlainOutput=1;;
-x|--apt-proxy) shift; APT_PROXY="$1";;
-z|--timezone) shift; TIMEZONE="$1";;
-r|--privareg) shift; PRIVAREG="$1";;
-p|--push) Push=1;;
--ci) Composer=ci;;
--cu) Composer=cu;;
--no-use-rslave) UseRslave=;;
*) die "$1: option non configurée";;
esac
shift
done
Cmd=("$@")
for config in "${Configs[@]}"; do
if [ "$config" == none ]; then
Configs=()
break
fi
done
if [ ${#Configs[*]} -gt 0 ]; then
for config in "${Configs[@]}"; do
if [ "$config" == none ]; then
Configs=()
break
fi
source "$config" || exit 1
done
if [ ${#Configs[*]} -gt 0 ]; then
for config in "${Configs[@]}"; do
source "$config" || exit 1
done
after_source_buildenv
after_source_buildenv
fi
[ -n "$Dist" ] && DIST="$Dist"
Image=
host_ensure_image
host_check_image && exists=1 || exists=
if [ -z "$UnlessExists" -o -z "$exists" ]; then
eecho "== Building $Image"
args=(
-f "$Dockerfile"
${Pull:+--pull}
${NoCache:+--no-cache}
${BuildPlain:+--progress plain}
-t "$Image"
)
for arg in "${BUILD_ARGS[@]}"; do
args+=(--build-arg "$arg=${!arg}")
done
for arg in "${!PROXY_VARS[@]}"; do
args+=(--build-arg "$arg=${PROXY_VARS[$arg]}")
done
for host in "${HOST_MAPPINGS[@]}"; do
args+=(--add-host "$host")
done
mkdir -p /tmp/runphp-build
docker build "${args[@]}" /tmp/runphp-build || exit 1
if [ -n "$Push" -a -n "$PRIVAREG" ]; then
eecho "== Pushing $Image"
docker push "$Image" || exit 1
fi
[ -n "$Dist" ] && DIST="$Dist"
fi
}
ensure_image
check_image && exists=1 || exists=
if [ -z "$UnlessExists" -o -z "$exists" ]; then
eecho "== Building $Image"
args=(
-f "$Dockerfile"
${Pull:+--pull}
${NoCache:+--no-cache}
${BuildPlain:+--progress plain}
-t "$Image"
)
for arg in "${BUILD_ARGS[@]}"; do
args+=(--build-arg "$arg=${!arg}")
done
for arg in "${!PROXY_VARS[@]}"; do
args+=(--build-arg "$arg=${PROXY_VARS[$arg]}")
done
for host in "${HOST_MAPPINGS[@]}"; do
args+=(--add-host "$host")
done
mkdir -p /tmp/runphp-build
docker build "${args[@]}" /tmp/runphp-build || exit 1
function host_docker_run() {
# lancer une commande avec docker
SOPTS=+w:
LOPTS=help,chdir:,no-use-rslave
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
if [ -n "$Push" -a -n "$PRIVAREG" ]; then
eecho "== Pushing $Image"
docker push "$Image" || exit 1
fi
fi
if [ -z "$RUNPHP_STANDALONE" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
# Forcer l'installation des dépendances si nécessaire
ComposerInstall=1
fi
[ -z "$ComposerInstall" -o -n "$UnlessExists" ] && exit 0
else
## Mode exécution de commande ##########################################
# Ici, on a déterminé qu'il faut lancer une commande
SOPTS=+w:
LOPTS=help,chdir:,no-use-rslave
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
--help)
eecho "\
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
--help)
eecho "\
runphp: lancer une commande dans un environnement PHP déterminé
USAGE
@ -455,23 +460,17 @@ courant est forcé au répertoire du projet composer
OPTIONS
-w, --chdir CHDIR
aller dans le répertoire spécifié avant de lancer la commande"
exit 0
;;
-w|--chdir) shift; Chdir="$1";;
--no-use-rslave) UseRslave=;;
*) die "$1: option non configurée";;
esac
shift
done
if [ -z "$RUNPHP_STANDALONE" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
# Forcer l'installation des dépendances si nécessaire
ComposerInstall=1
fi
fi
## Lancer la commande
aller dans le répertoire spécifié avant de lancer la commande
--no-use-rslave
paramètre montage des volumes"
exit 0
;;
-w|--chdir) shift; Chdir="$1";;
--no-use-rslave) UseRslave=;;
*) die "$1: option non configurée";;
esac
shift
done
args=(
run -it --rm
@ -500,7 +499,7 @@ OPTIONS
[ -n "$RUNPHP_STANDALONE" ] &&
[ "${RUNPHP_STANDALONE#$HOME/}" != "$RUNPHP_STANDALONE" ] &&
mount_runphp=
else
elif [ -n "$PROJDIR" ]; then
# bind mount uniquement le répertoire du projet
args+=(-v "$PROJDIR:$PROJDIR${UseRslave:+:rslave}")
mount_composer=1
@ -529,15 +528,13 @@ OPTIONS
"$Image"
exec "$0" ${Chdir:+-w "$Chdir"}
)
[ -n "$ComposerInstall" ] && set -- ci
[ -n "$Verbose" ] && eecho "\$ docker ${args[*]} $*"
exec docker "${args[@]}" "$@"
else
############################################################################
# Lancement depuis l'intérieur du container
############################################################################
docker "${args[@]}" "$@"
}
function container_exec() {
# lancer la commande $@. cette fonction doit être lancée dans le container
# docker
if [ -n "$DEVUSER_USERENT" ]; then
user="${DEVUSER_USERENT%%:*}"
export DEVUSER_USERENT=
@ -564,14 +561,16 @@ else
shift
done
if [ -z "$1" ]; then
if [ $# -eq 0 ]; then
die "no command specified"
elif [ "$1" == ci ]; then
eecho "== installing composer dependencies"
composer i
shift
composer i "$@"
elif [ "$1" == cu ]; then
eecho "== upgrading composer dependencies"
composer u
shift
composer u "$@"
elif [ "$1" == composer ]; then
"$@"
else
@ -580,4 +579,38 @@ else
fi
exec "$@"
fi
}
################################################################################
if [ "$RUNPHP_MODE" != docker ]; then
# Lancement depuis l'extérieur du container
host_parse_args "$@"
host_init_env
Image=
if [ "$Bootstrap" == auto ]; then
host_ensure_image
host_check_image && Bootstrap= || Bootstrap=1
fi
if [ -n "$Bootstrap" ]; then
host_docker_build "${Cmd[@]}" || exit $?
else
host_ensure_image
fi
host_check_projdir
if [ -n "$Composer" ]; then
host_docker_run "$Composer" || exit $?
fi
if [ ${#Cmd[*]} -gt 0 ]; then
host_docker_run "${Cmd[@]}" || exit $?
fi
else
# Lancement depuis l'intérieur du container
container_exec "$@"
fi
exit 0

View File

@ -1,18 +0,0 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
# Script permettant de lancer une commande dans docker et/ou de bootstrapper
# l'utilisation de nulib dans un projet PHP
# Les fichiers suivants doivent être copiés à un endroit quelconque du projet:
# - runphp (ce script, à générer avec update-runphp.sh)
# - Dockerfile.runphp
# Les fichiers suivants peuvent être intégrés dans le projet comme exemples:
# - dot-build.env.dist (à renommer en .build.env.dist)
# - dot-dkbuild.env.dist (indiquer qu'il faut le copier en ~/.dkbuild.env)
# Par défaut, ce script assume que runphp est copié dans le répertoire sbin/
# du projet, et que le fichier composer.json et le répertoire vendor/ sont à la
# racine du projet. Le cas échéant, modifier les valeurs ci-dessous
(return 0 2>/dev/null) && _sourced=1 || _sourced=
###############################################################################
# Modifier les valeurs suivantes si nécessaire
#SOF:runphp.userconf:ne pas modifier cette ligne

View File

@ -1,534 +0,0 @@
#EOF:runphp.userconf:ne pas modifier cette ligne
################################################################################
# Ne pas modifier à partir d'ici
if [ -n "$_sourced" ]; then
if [ "${0#-}" != "$0" ]; then
# sourcé depuis la ligne de commande
MYSELF="${BASH_SOURCE[1]}"
else
# sourcé depuis un script
MYSELF="${BASH_SOURCE[0]}"
fi
MYDIR="$(cd "$(dirname -- "$MYSELF")"; pwd)"
MYNAME="$(basename -- "$MYSELF")"
else
MYDIR="$(cd "$(dirname -- "$0")"; pwd)"
MYNAME="$(basename -- "$0")"
fi
if [ -f "$MYDIR/runphp.userconf.local" ]; then
source "$MYDIR/runphp.userconf.local"
fi
DEFAULT_DIST=d12
if [ -n "$RUNPHP_STANDALONE" ]; then
PROJDIR="$RUNPHP_PROJDIR"
COMPOSERDIR=.
COMPOSERPHAR=
VENDORDIR=vendor
BUILDENV0=
BUILDENV=
DIST="${RUNPHP_DIST:-$DEFAULT_DIST}"
IMAGENAME=nulib/
PRIVAREG=docker.io
REGISTRY="$RUNPHP_REGISTRY"
[ -n "$RUNPHP_BUILD_FLAVOUR" ] && BUILD_FLAVOUR="$RUNPHP_BUILD_FLAVOUR"
else
[ -n "$PROJDIR" ] || PROJDIR="$(dirname -- "$MYDIR")"
[ "${PROJDIR#/}" != "$PROJDIR" ] || PROJDIR="$(cd "$MYDIR/$PROJDIR"; pwd)"
[ -n "$COMPOSERDIR" ] || COMPOSERDIR=.
[ -n "$COMPOSERPHAR" ] || COMPOSERPHAR=sbin/composer.phar
[ -n "$VENDORDIR" ] || VENDORDIR=vendor
[ -n "$BUILDENV0" ] || BUILDENV0=.build.env.dist
[ -n "$BUILDENV" ] || BUILDENV=build.env
[ -n "$DIST" ] || DIST="$DEFAULT_DIST"
[ -n "$IMAGENAME" ] || IMAGENAME=nulib/
[ "$COMPOSERPHAR" == none ] && COMPOSERPHAR=
[ "$BUILDENV0" == none ] && BUILDENV0=
[ "$BUILDENV" == none ] && BUILDENV=
fi
[ "$BUILD_FLAVOUR" == none ] && BUILD_FLAVOUR=
function after_source_buildenv() {
NDIST="${DIST#d}"
}
after_source_buildenv
[ -n "$_sourced" ] && return 0
function eecho() { echo "$*" 1>&2; }
function eerror() { eecho "ERROR: $*"; }
function die() { [ $# -gt 0 ] && eerror "$*"; exit 1; }
function is_defined() { [ -n "$(declare -p "$1" 2>/dev/null)" ]; }
function in_path() { [ -n "$1" -a -x "$(which "$1" 2>/dev/null)" ]; }
function composer() {
cd "$PROJDIR/$COMPOSERDIR" || exit 1
if [ -n "$COMPOSERPHAR" -a -x "$PROJDIR/$COMPOSERPHAR" ]; then
"$PROJDIR/$COMPOSERPHAR" "$@"
elif in_path composer; then
command composer "$@"
elif [ -x /usr/bin/composer ]; then
/usr/bin/composer "$@"
elif [ -x /usr/local/bin/composer ]; then
/usr/local/bin/composer "$@"
else
die "impossible de trouver composer"
fi
if [ -z "$RUNPHP_STANDALONE" -a -f composer.lock ]; then
cp composer.lock "$PROJDIR/.composer.lock.runphp"
fi
}
function ensure_image() {
local dfdir suffix dockerfiles dockerfile
local privareg imagename
if [ -z "$Image" ]; then
[ -n "$RUNPHP_STANDALONE" ] && dfdir="$RUNPHP_STANDALONE/runphp" || dfdir="$MYDIR"
dockerfiles=(
"_local:$dfdir/Dockerfile.runphp.local"
"${BUILD_FLAVOUR//+/_}:$dfdir/Dockerfile.runphp$BUILD_FLAVOUR"
":$dfdir/Dockerfile.runphp"
)
for dockerfile in "${dockerfiles[@]}"; do
suffix="${dockerfile%:*}"
dockerfile="${dockerfile##*:}"
[ -f "$dockerfile" ] && break
done
Dockerfile="$dockerfile"
[[ "$IMAGENAME" == */ ]] && imagename=runphp || imagename="${IMAGENAME%/*}/runphp"
privareg="$PRIVAREG"
if [ "$imagename" == runphp ]; then
[ -z "$privareg" -o "$privareg" == docker.io ] && privareg=docker.io/library
else
[ -z "$privareg" ] && privareg=docker.io
fi
Image="$privareg/$imagename$suffix:$DIST"
fi
}
function check_image() {
local image="$Image"
for prefix in docker.io/library/ docker.io; do
if [ "${image#$prefix}" != "$image" ]; then
image="${image#$prefix}"
break
fi
done
[ -n "$(docker image ls --no-trunc --format '{{.Repository}}:{{.Tag}}' "$image" 2>/dev/null)" ]
}
## Arguments initiaux
Bootstrap=
ComposerInstall=
if [ "$1" == --runphp-bootstrap -o "$1" == --bs ]; then
Bootstrap=1
shift
elif [ "$1" == --runphp-exec ]; then
Bootstrap=
shift
elif [ "$1" == --runphp-install -o "$1" == --ci ]; then
ComposerInstall=1
shift
fi
ForcedBootstrap=
if [ -z "$Bootstrap" -a -z "$RUNPHP_STANDALONE" ]; then
# si vendor/ n'existe pas, alors on doit faire bootstrap
if [ ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
ForcedBootstrap=1
elif [ ! -f "$PROJDIR/.composer.lock.runphp" ]; then
ForcedBootstrap=1
elif ! diff -q "$PROJDIR/$COMPOSERDIR/composer.lock" "$PROJDIR/.composer.lock.runphp" >&/dev/null; then
ForcedBootstrap=1
fi
if [ -n "$ForcedBootstrap" ]; then
[ "$RUNPHP_MODE" != docker ] && eecho "== bootstrapping runphp"
Bootstrap=1
ComposerInstall=1
fi
fi
if [ "$RUNPHP_MODE" != docker ]; then
############################################################################
# Lancement depuis l'extérieur du container
############################################################################
## Charger ~/.dkbuild.env
APT_PROXY=
APT_MIRROR=
SEC_MIRROR=
TIMEZONE=
PRIVAREG=
REGISTRY=
PROFILE=
HOST_MAPPINGS=()
function default_profile() {
PROFILE="$1"
}
function profile() {
local profile
for profile in "$@"; do
[ "$profile" == "$PROFILE" ] && return 0
done
return 1
}
function setenv() {
eval "export $1"
}
function default() {
local command="$1"; shift
local nv n v
case "$command" in
docker)
for nv in "$@"; do
[[ "$nv" == *=* ]] || continue
n="${nv%%=*}"
v="${nv#*=}"
case "$n" in
host-mappings)
read -a ns <<<"$v"
for v in "${ns[@]}"; do
HOST_MAPPINGS+=("$v")
done
;;
esac
done
;;
esac
}
[ -f ~/.dkbuild.env ] && source ~/.dkbuild.env
[ -n "$APT_PROXY" ] || APT_PROXY=
[ -n "$APT_MIRROR" ] || APT_MIRROR=default
[ -n "$SEC_MIRROR" ] || SEC_MIRROR=default
[ -n "$TIMEZONE" ] || TIMEZONE=Europe/Paris
[ -n "$PRIVAREG" ] || PRIVAREG=
[ -n "$REGISTRY" ] || REGISTRY=pubdocker.univ-reunion.fr
## Charger la configuration
# Recenser les valeur de proxy
declare -A PROXY_VARS
for var in {HTTPS,ALL,NO}_PROXY {http,https,all,no}_proxy; do
is_defined "$var" && PROXY_VARS[${var,,}]="${!var}"
done
# Paramètres de montage
if [ -n "$RUNPHP_NO_USE_RSLAVE" ]; then
UseRslave=
elif [ -n "$RUNPHP_USE_RSLAVE" ]; then
UseRslave=1
elif [ -e /proc/sys/fs/binfmt_misc/WSLInterop ]; then
# pas de mount propagation sous WSL
UseRslave=
else
UseRslave=1
fi
# Toujours vérifier l'existence de l'image
Image=
if [ -z "$Bootstrap" ]; then
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
for config in "${Configs[@]}"; do
source "$config" || exit 1
done
after_source_buildenv
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
source "$PROJDIR/$BUILDENV" || exit 1
after_source_buildenv
elif [ -n "$BUILDENV0" -a -f "$PROJDIR/$BUILDENV0" ]; then
source "$PROJDIR/$BUILDENV0" || exit 1
after_source_buildenv
fi
ensure_image
check_image || Bootstrap=1
fi
Chdir=
Verbose="$RUNPHP_VERBOSE"
if [ -n "$Bootstrap" ]; then
## Mode bootstrap de l'image ###########################################
# Ici, on a déterminé que l'image doit être construite
BUILD_ARGS=(
DIST NDIST
REGISTRY
APT_PROXY
APT_MIRROR
SEC_MIRROR
TIMEZONE
)
SOPTS=+d:9876543210:c:UjDx:z:r:p
LOPTS=help,dist:,d19,d18,d17,d16,d15,d14,d13,d12,d11,d10,config:,ue,unless-exists,pull,nc,no-cache,po,plain-output,apt-proxy:,timezone:,privareg:,push,ci,no-use-rslave
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
Dist=
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
Configs=("$PROJDIR/$BUILDENV")
elif [ -n "$BUILDENV0" -a -f "$PROJDIR/$BUILDENV0" ]; then
Configs=("$PROJDIR/$BUILDENV0")
else
Configs=()
fi
UnlessExists=
Pull=
NoCache=
PlainOutput=
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
--help)
eecho "\
runphp: construire l'image docker
USAGE
$MYNAME --bootstrap [options...]
OPTIONS
-c, --config build.env
--unless-exists
-U, --pull
-j, --no-cache
-D, --plain-output
-x, --apt-proxy APT_PROXY
-z, --timezone TIMEZONE
-r, --privareg PRIVAREG
-p, --push
paramètres pour la consruction de l'image"
exit 0
;;
-d|--dist) shift; Dist="$1";;
-[0-9]) Dist="d1${1#-}";;
--d*) Dist="${1#--}";;
-c|--config) shift; Configs+="$1";;
--ue|--unless-exists) UnlessExists=1;;
-U|--pull) Pull=1;;
-j|--nc|--no-cache) NoCache=1;;
-D|--po|--plain-output) PlainOutput=1;;
-x|--apt-proxy) shift; APT_PROXY="$1";;
-z|--timezone) shift; TIMEZONE="$1";;
-r|--privareg) shift; PRIVAREG="$1";;
-p|--push) Push=1;;
--ci) ComposerInstall=1;;
--no-use-rslave) UseRslave=;;
*) die "$1: option non configurée";;
esac
shift
done
for config in "${Configs[@]}"; do
if [ "$config" == none ]; then
Configs=()
break
fi
done
if [ ${#Configs[*]} -gt 0 ]; then
for config in "${Configs[@]}"; do
source "$config" || exit 1
done
after_source_buildenv
fi
[ -n "$Dist" ] && DIST="$Dist"
ensure_image
check_image && exists=1 || exists=
if [ -z "$UnlessExists" -o -z "$exists" ]; then
eecho "== Building $Image"
args=(
-f "$Dockerfile"
${Pull:+--pull}
${NoCache:+--no-cache}
${BuildPlain:+--progress plain}
-t "$Image"
)
for arg in "${BUILD_ARGS[@]}"; do
args+=(--build-arg "$arg=${!arg}")
done
for arg in "${!PROXY_VARS[@]}"; do
args+=(--build-arg "$arg=${PROXY_VARS[$arg]}")
done
for host in "${HOST_MAPPINGS[@]}"; do
args+=(--add-host "$host")
done
mkdir -p /tmp/runphp-build
docker build "${args[@]}" /tmp/runphp-build || exit 1
if [ -n "$Push" -a -n "$PRIVAREG" ]; then
eecho "== Pushing $Image"
docker push "$Image" || exit 1
fi
fi
if [ -z "$RUNPHP_STANDALONE" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
# Forcer l'installation des dépendances si nécessaire
ComposerInstall=1
fi
[ -z "$ComposerInstall" -o -n "$UnlessExists" ] && exit 0
else
## Mode exécution de commande ##########################################
# Ici, on a déterminé qu'il faut lancer une commande
SOPTS=+w:
LOPTS=help,chdir:,no-use-rslave
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
--help)
eecho "\
runphp: lancer une commande dans un environnement PHP déterminé
USAGE
$MYNAME ci|cu|composer
$MYNAME [options] command [args...]
COMMANDES COMPOSER
ci
cu
installer/mettre à jour les dépendances du projet avec composer
composer [args...]
lancer composer avec les arguments spécifiés.
pour les commandes ci-dessus, l'option --chdir est ignorée: le répertoire
courant est forcé au répertoire du projet composer
OPTIONS
-w, --chdir CHDIR
aller dans le répertoire spécifié avant de lancer la commande"
exit 0
;;
-w|--chdir) shift; Chdir="$1";;
--no-use-rslave) UseRslave=;;
*) die "$1: option non configurée";;
esac
shift
done
if [ -z "$RUNPHP_STANDALONE" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
# Forcer l'installation des dépendances si nécessaire
ComposerInstall=1
fi
fi
## Lancer la commande
args=(
run -it --rm
--name "runphp-$(basename -- "$1")-$$"
-e RUNPHP_MODE=docker
)
for arg in "${!PROXY_VARS[@]}"; do
args+=(-e "$arg=${PROXY_VARS[$arg]}")
done
if [ -n "$RUNPHP_STANDALONE" ]; then
args+=(
-e "RUNPHP_STANDALONE=$RUNPHP_STANDALONE"
-e "RUNPHP_PROJDIR=$PROJDIR"
)
fi
for host in "${HOST_MAPPINGS[@]}"; do
args+=(--add-host "$host")
done
# monter le répertoire qui contient $PROJDIR
mount_composer=
mount_runphp=1
if [ -z "$PROJDIR" -o "${PROJDIR#$HOME/}" != "$PROJDIR" -o "$PROJDIR" == "$HOME" ]; then
# bind mount $HOME
args+=(-v "$HOME:$HOME${UseRslave:+:rslave}")
[ -n "$RUNPHP_STANDALONE" ] &&
[ "${RUNPHP_STANDALONE#$HOME/}" != "$RUNPHP_STANDALONE" ] &&
mount_runphp=
else
# bind mount uniquement le répertoire du projet
args+=(-v "$PROJDIR:$PROJDIR${UseRslave:+:rslave}")
mount_composer=1
[ "$RUNPHP_STANDALONE" == "$PROJDIR" ] && mount_runphp=
fi
if [ -n "$mount_composer" -a -d "$HOME/.composer" ]; then
# monter la configuration de composer
args+=(-v "$HOME/.composer:$HOME/.composer")
fi
if [ -n "$RUNPHP_STANDALONE" -a -n "$mount_runphp" ]; then
args+=(-v "$RUNPHP_STANDALONE:$RUNPHP_STANDALONE")
fi
args+=(-w "$(pwd)")
# lancer avec l'utilisateur courant
if [ $(id -u) -ne 0 ]; then
# si c'est un utilisateur lambda, il faut monter les informations
# nécessaires. composer est déjà monté via $HOME
args+=(
-e DEVUSER_USERENT="$(getent passwd "$(id -un)")"
-e DEVUSER_GROUPENT="$(getent group "$(id -gn)")"
)
fi
args+=(
"$Image"
exec "$0" ${Chdir:+-w "$Chdir"}
)
[ -n "$ComposerInstall" ] && set -- ci
[ -n "$Verbose" ] && eecho "\$ docker ${args[*]} $*"
exec docker "${args[@]}" "$@"
else
############################################################################
# Lancement depuis l'intérieur du container
############################################################################
if [ -n "$DEVUSER_USERENT" ]; then
user="${DEVUSER_USERENT%%:*}"
export DEVUSER_USERENT=
export DEVUSER_GROUPENT=
if in_path su-exec; then
exec su-exec "$user" "$0" "$@"
else
exec runuser -u "$user" -- "$0" "$@"
fi
fi
SOPTS=+w:
LOPTS=chdir:
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
chdir=
action=
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
-w|--chdir) shift; chdir="$1";;
*) die "$1: option non configurée";;
esac
shift
done
if [ -z "$1" ]; then
die "no command specified"
elif [ "$1" == ci ]; then
eecho "== installing composer dependencies"
composer i
elif [ "$1" == cu ]; then
eecho "== upgrading composer dependencies"
composer u
elif [ "$1" == composer ]; then
"$@"
else
if [ -n "$chdir" ]; then
cd "$chdir" || exit 1
fi
exec "$@"
fi
fi

View File

@ -1,29 +0,0 @@
# répertoire du projet. ce chemin doit être absolu. s'il est relatif, il est
# exprimé par rapport au répertoire de ce script
PROJDIR=
# composer: répertoire du projet composer (celui qui contient le fichier
# composer.json), chemin de composer.phar et répertoire vendor. ces chemins
# doivent être relatifs à $PROJDIR
COMPOSERDIR=
COMPOSERPHAR=
VENDORDIR=
# fichier de configuration pour le build
BUILDENV0=
BUILDENV=
# Listes des images que le script build construit automatiquement
BUILD_IMAGES=(php-apache mariadb10)
BUILD_FLAVOUR=
## En ce qui concerne DIST et IMAGENAME, les valeurs dans BUILDENV prennent le
## dessus. si BUILDENV *n'est pas* utilisé, ces valeurs peuvent être spécifiées
## ici
# version de debian à utiliser pour l'image
# d12=php8.2, d11=php7.4, d10=php7.3
DIST=
# Nom de base de l'image (sans le registry), e.g prefix/
IMAGENAME=

View File

@ -2,6 +2,44 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/../load.sh" || exit 1
function parse_runphp() {
local runphp="$1" preamble="$2" conf="$3" postamble="$4"
local conf0
ac_set_tmpfile conf0
# extraire la configuration depuis le fichier
<"$runphp" awk -v preamble="$preamble" -v conf="$conf0" -v postamble="$postamble" '
BEGIN { out = preamble }
{
if ($0 ~ /SOF:runphp.userconf:/) {
if (out != "") print >out
out = conf
} else if ($0 ~ /EOF:runphp.userconf:/) {
out = postamble
if (out != "") print >out
} else {
if (out != "") print >out
}
}
'
# mettre en forme le fichier conf: pas de lignes vides avant et après
<"$conf0" >"$conf" awk '
BEGIN { p = 0; have_pending = 0; pending = "" }
$0 != "" { p = 1 }
p == 1 {
if ($0 != "") {
if (have_pending) print pending
print
have_pending = 0
pending = ""
} else {
if (!have_pending) have_pending = 1
else pending = pending "\n"
}
}
'
ac_clean "$conf0"
}
projdir=
args=(
"Mettre à jour le script runphp"
@ -16,58 +54,51 @@ if [ -n "$projdir" ]; then
fi
runphp="${1:-.}"
[ -d "$runphp" ] && runphp="$runphp/runphp"
if [ -d "$runphp" ]; then
runphp="$runphp/runphp"
elif [ ! -e "$runphp" ]; then
[ "${runphp%/runphp}" != "$runphp" ] || runphp="$runphp/runphp"
fi
setx runphp=abspath "$runphp"
setx rundir=dirname -- "$runphp"
[ "$rundir" == "$MYDIR" ] && exit 0
[ -d "$rundir" ] || mkdir -p "$rundir"
# Tout d'abord, isoler chaque partie du fichier local
ac_set_tmpfile preamble
ac_set_tmpfile conf
ac_set_tmpfile postamble
parse_runphp "$MYDIR/runphp" "$preamble" "$conf" "$postamble"
# Puis analyser le fichier destination
if [ -f "$runphp" ]; then
ac_set_tmpfile userconf
<"$runphp" awk '
# extraire la configuration depuis le fichier
BEGIN { p = 0 }
/SOF:runphp.userconf:/ { p = 1; next }
/EOF:runphp.userconf:/ { p = 0; next }
p == 1 { print }
' | awk '
# mettre en forme le fichier: pas de lignes vides avant et après
BEGIN { p = 0; have_pending = 0; pending = "" }
$0 != "" { p = 1 }
p == 1 {
if ($0 != "") {
if (have_pending) print pending
print
have_pending = 0
pending = ""
} else {
if (!have_pending) have_pending = 1
else pending = pending "\n"
}
}
' >"$userconf"
parse_runphp "$runphp" "" "$userconf" ""
initial_config=
elif [ -n "$projdir" ]; then
# forcer BUILDENV0=..env.dist et BUILDENV=.env pour les projets de
# l'université de la Réunion
initial_config=1
ac_set_tmpfile userconf
sed <"$MYDIR/runphp.userconf" >"$userconf" '
sed <"$conf" >"$userconf" '
/^BUILDENV0=/s/=.*/=..env.dist/
/^BUILDENV=/s/=.*/=.env/
'
initial_config=1
else
userconf="$conf"
initial_config=1
userconf="$MYDIR/runphp.userconf"
fi
# (Re)construire le fichier destination
(
cat "$MYDIR/runphp.1preamble"
cat "$preamble"
echo
cat "$userconf"
echo
cat "$MYDIR/runphp.2postamble"
cat "$postamble"
) >"$runphp"
[ -x "$runphp" ] || chmod +x "$runphp"