runphp fait aussi wrapper

This commit is contained in:
Jephté Clain 2025-06-25 06:39:40 +04:00
parent 599d646372
commit 3e642b84bc
6 changed files with 68 additions and 47 deletions

View File

@ -0,0 +1,14 @@
#!/usr/bin/php
<?php
require __DIR__ . "/../php/vendor/autoload.php";
use nulib\tools\pman\ComposerFile;
use nulib\tools\pman\ComposerPmanFile;
use nulib\ValueException;
$composer = new ComposerFile();
$deps = $composer->getLocalDeps();
foreach ($deps as $dep => $path) {
echo "$path\n";
}

View File

@ -0,0 +1,22 @@
#!/usr/bin/php
<?php
require __DIR__ . "/../php/vendor/autoload.php";
use nulib\tools\pman\ComposerFile;
use nulib\tools\pman\ComposerPmanFile;
use nulib\ValueException;
$composer = new ComposerFile();
$config = new ComposerPmanFile();
if ($argc <= 1) {
throw new ValueException("Il faut spécifier le profil à sélectionner");
}
$profile = $argv[1];
$composer->selectProfile($profile, $config);
if (getenv("PMAN_COMPOSER_DEBUG")) {
$composer->print();
} else {
$composer->write();
}

View File

@ -1,14 +0,0 @@
#!/usr/bin/php
<?php
require __DIR__ . "/../php/vendor/autoload.php";
use nulib\tools\pman\ComposerFile;
use nulib\tools\pman\ComposerPmanFile;
use nulib\ValueException;
$composer = new ComposerFile();
$deps = $composer->getLocalDeps();
foreach ($deps as $dep => $path) {
echo "$path\n";
}

View File

@ -0,0 +1 @@
runphp

View File

@ -1,22 +0,0 @@
#!/usr/bin/php
<?php
require __DIR__ . "/../php/vendor/autoload.php";
use nulib\tools\pman\ComposerFile;
use nulib\tools\pman\ComposerPmanFile;
use nulib\ValueException;
$composer = new ComposerFile();
$config = new ComposerPmanFile();
if ($argc <= 1) {
throw new ValueException("Il faut spécifier le profil à sélectionner");
}
$profile = $argv[1];
$composer->selectProfile($profile, $config);
if (getenv("PMAN_COMPOSER_DEBUG")) {
$composer->print();
} else {
$composer->write();
}

View File

@ -0,0 +1 @@
runphp

View File

@ -20,14 +20,25 @@ while true; do
cd .. cd ..
done done
if [ -z "$PROJDIR" ]; then export RUNPHP_MOUNT=
# s'il n'y a pas de projet, --bs est l'action par défaut if [ "$MYNAME" == composer ]; then
[ $# -gt 0 ] || set -- --bs --ue
elif [ "$MYNAME" == composer ]; then
set -- composer "$@" set -- composer "$@"
elif [[ "$MYNAME" == *.php ]]; then
# frontend pour une commande php
set -- php "$MYDIR/.$MYNAME" "$@"
# s'assurer que NULIBDIR est monté
RUNPHP_MOUNT="$NULIBDIR"
elif [ $# -eq 0 ]; then
# s'il n'y a pas de projet, --bs est l'action par défaut
[ -n "$PROJDIR" ] || set -- --bs --ue
else else
case "$1" in case "$1" in
*.php|*.phar) set -- php "$@";; *.php|*.phar)
set -- php "$@"
# s'assurer que le répertoire du script est monté
setx RUNPHP_MOUNT=dirname "$1"
setx RUNPHP_MOUNT=abspath "$RUNPHP_MOUNT"
;;
esac esac
fi fi

View File

@ -537,26 +537,34 @@ OPTIONS
# monter le répertoire qui contient $PROJDIR # monter le répertoire qui contient $PROJDIR
mount_composer= mount_composer=
mount_runphp=1 mount_standalone=1
mount_mount=1
if [ -z "$PROJDIR" -o "${PROJDIR#$HOME/}" != "$PROJDIR" -o "$PROJDIR" == "$HOME" ]; then if [ -z "$PROJDIR" -o "${PROJDIR#$HOME/}" != "$PROJDIR" -o "$PROJDIR" == "$HOME" ]; then
# bind mount $HOME # bind mount $HOME
args+=(-v "$HOME:$HOME${UseRslave:+:rslave}") args+=(-v "$HOME:$HOME${UseRslave:+:rslave}")
[ -n "$RUNPHP_STANDALONE" ] && if [ -n "$RUNPHP_STANDALONE" -a "${RUNPHP_STANDALONE#$HOME/}" != "$RUNPHP_STANDALONE" ]; then
[ "${RUNPHP_STANDALONE#$HOME/}" != "$RUNPHP_STANDALONE" ] && mount_standalone=
mount_runphp= fi
if [ -n "$RUNPHP_MOUNT" -a "${RUNPHP_MOUNT#$HOME/}" != "$RUNPHP_MOUNT" ]; then
mount_mount=
fi
elif [ -n "$PROJDIR" ]; then elif [ -n "$PROJDIR" ]; then
# bind mount uniquement le répertoire du projet # bind mount uniquement le répertoire du projet
args+=(-v "$PROJDIR:$PROJDIR${UseRslave:+:rslave}") args+=(-v "$PROJDIR:$PROJDIR${UseRslave:+:rslave}")
mount_composer=1 mount_composer=1
[ "$RUNPHP_STANDALONE" == "$PROJDIR" ] && mount_runphp= [ "$RUNPHP_STANDALONE" == "$PROJDIR" ] && mount_standalone=
[ "$RUNPHP_MOUNT" == "$PROJDIR" ] && mount_mount=
fi fi
if [ -n "$mount_composer" -a -d "$HOME/.composer" ]; then if [ -n "$mount_composer" -a -d "$HOME/.composer" ]; then
# monter la configuration de composer # monter la configuration de composer
args+=(-v "$HOME/.composer:$HOME/.composer") args+=(-v "$HOME/.composer:$HOME/.composer")
fi fi
if [ -n "$RUNPHP_STANDALONE" -a -n "$mount_runphp" ]; then if [ -n "$RUNPHP_STANDALONE" -a -n "$mount_standalone" ]; then
args+=(-v "$RUNPHP_STANDALONE:$RUNPHP_STANDALONE") args+=(-v "$RUNPHP_STANDALONE:$RUNPHP_STANDALONE")
fi fi
if [ -n "$RUNPHP_MOUNT" -a -n "$mount_mount" ]; then
args+=(-v "$RUNPHP_MOUNT:$RUNPHP_MOUNT")
fi
args+=(-w "$(pwd)") args+=(-w "$(pwd)")
# lancer avec l'utilisateur courant # lancer avec l'utilisateur courant