modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-10-18 15:28:55 +04:00
parent 438b63f8e0
commit 7e8901a7f6
4 changed files with 72 additions and 75 deletions

View File

@ -61,13 +61,12 @@ if [ -f "$PROJDIR/.runphp.conf" ]; then
[ -n "$RUNPHP" ] && exec "$PROJDIR/$RUNPHP" "$@"
elif [ -f "$PROJDIR/sbin/runphp" ]; then
exec "$PROJDIR/sbin/runphp" "$@"
elif [ -f "$PROJDIR/runphp" ]; then
exec "$PROJDIR/runphp" "$@"
fi
[ -n "$DIST" ] || DIST=d12
[ -x "$MYDIR/$DIST/runphp" ] || die "$DIST: distribution non supportée"
export RUNPHP_STANDALONE=1
export RUNPHP_STANDALONE="$NULIBDIR"
export RUNPHP_PROJDIR="$PROJDIR"
export RUNPHP_REGISTRY="$REGISTRY"
export RUNPHP_DIST="$DIST"
"$MYDIR/$DIST/runphp" "$@"
exec "$MYDIR/../runphp/runphp" "$@"

View File

@ -261,8 +261,6 @@ if [ "$RUNPHP_MODE" != docker ]; then
[ -n "$PRIVAREG" ] || PRIVAREG=
[ -n "$REGISTRY" ] || REGISTRY=pubdocker.univ-reunion.fr
## Construire l'image
if [ -n "$RUNPHP_NO_USE_RSLAVE" ]; then
UseRslave=
elif [ -n "$RUNPHP_USE_RSLAVE" ]; then
@ -294,6 +292,8 @@ if [ "$RUNPHP_MODE" != docker ]; then
fi
if [ -n "$bootstrap" ]; then
## Mode bootstrap de l'image ###########################################
BUILD_ARGS=(
DIST NDIST
REGISTRY
@ -426,6 +426,8 @@ OPTIONS
[ -n "$BootstrapOnly" ] && exit 0
else
## Mode exécution de commande ##########################################
SOPTS=+w:v
LOPTS=help,chdir:,verbose,no-use-rslave
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"

View File

@ -21,6 +21,7 @@ if [ -f "$MYDIR/runphp.userconf.local" ]; then
source "$MYDIR/runphp.userconf.local"
fi
DEFAULT_DIST=d12
if [ -n "$RUNPHP_STANDALONE" ]; then
PROJDIR="$RUNPHP_PROJDIR"
@ -29,7 +30,7 @@ if [ -n "$RUNPHP_STANDALONE" ]; then
VENDORDIR=vendor
BUILDENV0=
BUILDENV=
DIST="$RUNPHP_DIST"
DIST="${RUNPHP_DIST:-$DEFAULT_DIST}"
IMAGENAME=nulib/
PRIVAREG=docker.io
@ -44,7 +45,7 @@ else
[ -n "$VENDORDIR" ] || VENDORDIR=vendor
[ -n "$BUILDENV0" ] || BUILDENV0=.build.env.dist
[ -n "$BUILDENV" ] || BUILDENV=build.env
[ -n "$DIST" ] || DIST=d12
[ -n "$DIST" ] || DIST="$DEFAULT_DIST"
[ -n "$IMAGENAME" ] || IMAGENAME=nulib/
[ "$COMPOSERPHAR" == none ] && COMPOSERPHAR=
@ -105,31 +106,23 @@ function check_image() {
[ -n "$(docker image ls --no-trunc --format '{{.Repository}}:{{.Tag}}' "$image" 2>/dev/null)" ]
}
bootstrap=
BootstrapOnly=1
ComposerInstall=
ForcedBootstrap=
parse_opts=1
args=()
for arg in "$@"; do
if [ -z "$parse_opts" ]; then
args+=("$arg")
elif [ "$arg" == --bootstrap -o "$arg" == --bs ]; then
bootstrap=1
elif [ "$arg" == --exec ]; then
BootstrapOnly=
elif [ "$arg" == --composer-install -o "$arg" == --ci ]; then
ComposerInstall=1
elif [[ "$arg" == -* ]]; then
args+=("$arg")
else
args+=("$arg")
parse_opts=
fi
done
set -- "${args[@]}"
## Arguments initiaux
if [ -z "$RUNPHP_STANDALONE" -a -z "$bootstrap" ]; then
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
@ -137,27 +130,18 @@ if [ -z "$RUNPHP_STANDALONE" -a -z "$bootstrap" ]; then
ForcedBootstrap=1
elif ! diff -q "$PROJDIR/$COMPOSERDIR/composer.lock" "$PROJDIR/.composer.lock.runphp" >&/dev/null; then
ForcedBootstrap=1
elif [ -n "$bootstrap" -a -n "$BootstrapOnly" ]; then
# bootstrap inutile
exit 0
fi
if [ -n "$ForcedBootstrap" ]; then
[ "$RUNPHP_MODE" != docker ] && eecho "== runphp is needed: bootstrapping"
bootstrap=1
BootstrapOnly=
[ "$RUNPHP_MODE" != docker ] && eecho "== bootstrapping runphp"
Bootstrap=1
ComposerInstall=1
fi
fi
if [ "$RUNPHP_MODE" != docker ]; then
############################################################################
# Lancement depuis l'extérieur du container
# 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
############################################################################
## Charger ~/.dkbuild.env
@ -204,7 +188,6 @@ if [ "$RUNPHP_MODE" != docker ]; then
esac
}
[ -f ~/.dkbuild.env ] && source ~/.dkbuild.env
[ -n "$APT_PROXY" ] || APT_PROXY=
[ -n "$APT_MIRROR" ] || APT_MIRROR=default
[ -n "$SEC_MIRROR" ] || SEC_MIRROR=default
@ -212,6 +195,15 @@ if [ "$RUNPHP_MODE" != docker ]; then
[ -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
@ -223,8 +215,9 @@ if [ "$RUNPHP_MODE" != docker ]; then
UseRslave=1
fi
# Toujours vérifier l'existence de l'image
IMAGE=
if [ -z "$bootstrap" ]; then
if [ -z "$Bootstrap" ]; then
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
for config in "${Configs[@]}"; do
@ -239,11 +232,14 @@ if [ "$RUNPHP_MODE" != docker ]; then
after_source_buildenv
fi
ensure_image
check_image || bootstrap=1
check_image || Bootstrap=1
fi
if [ -n "$bootstrap" ]; then
Chdir=
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
@ -254,8 +250,8 @@ if [ "$RUNPHP_MODE" != docker ]; then
TIMEZONE
)
SOPTS=+d:9876543210:c:UjDx:z:r:pw:v
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,chdir:,verbose,no-use-rslave
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,no-use-rslave
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
Dist=
@ -272,8 +268,6 @@ if [ "$RUNPHP_MODE" != docker ]; then
Pull=
NoCache=
PlainOutput=
Chdir=
Verbose=
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
@ -282,7 +276,7 @@ if [ "$RUNPHP_MODE" != docker ]; then
runphp: construire l'image docker
USAGE
$MYNAME --bootstrap [options...] [--exec command [args...]]
$MYNAME --bootstrap [options...]
OPTIONS
-c, --config build.env
@ -294,11 +288,7 @@ OPTIONS
-z, --timezone TIMEZONE
-r, --privareg PRIVAREG
-p, --push
paramètres pour la consruction de l'image
-w, --chdir CHDIR
aller dans le répertoire spécifié avant de lancer la commande
-v, --verbose
afficher plus d'informations"
paramètres pour la consruction de l'image"
exit 0
;;
-d|--dist) shift; Dist="$1";;
@ -313,8 +303,6 @@ OPTIONS
-z|--timezone) shift; TIMEZONE="$1";;
-r|--privareg) shift; PRIVAREG="$1";;
-p|--push) Push=1;;
-w|--chdir) shift; Chdir="$1";;
-v|--verbose) Verbose=1;;
--no-use-rslave) UseRslave=;;
*) die "$1: option non configurée";;
esac
@ -334,14 +322,20 @@ OPTIONS
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"
if [ -n "$RUNPHP_STANDALONE" ]; then
DFDIR="$RUNPHP_STANDALONE"
else
DFDIR="$MYDIR"
fi
dockerfiles=(
"$MYDIR/Dockerfile.runphp.local"
"$MYDIR/Dockerfile.runphp$BUILD_FLAVOUR"
"$MYDIR/Dockerfile.runphp"
"$DFDIR/Dockerfile.runphp.local"
"$DFDIR/Dockerfile.runphp$BUILD_FLAVOUR"
"$DFDIR/Dockerfile.runphp"
)
for dockerfile in "${dockerfiles[@]}"; do
[ -f "$dockerfile" ] && break
@ -370,21 +364,20 @@ OPTIONS
docker push "$IMAGE" || exit 1
fi
fi
if [ -n "$ComposerInstall" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
BootstrapOnly=
ForcedBootstrap=1
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
[ -n "$BootstrapOnly" ] && exit 0
[ -z "$ComposerInstall" ] && exit 0
else
## Mode exécution de commande ##########################################
# Ici, on a déterminé qu'il faut lancer une commande
SOPTS=+w:v
LOPTS=help,chdir:,verbose,no-use-rslave
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
Chdir=
Verbose=
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
@ -421,9 +414,9 @@ OPTIONS
shift
done
if [ -n "$ComposerInstall" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
if [ -z "$RUNPHP_STANDALONE" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
# Forcer l'installation des dépendances si nécessaire
ForcedBootstrap=1
ComposerInstall=1
fi
fi
@ -478,6 +471,7 @@ OPTIONS
else
############################################################################
# Lancement depuis l'intérieur du container
############################################################################
if [ -n "$DEVUSER_USERENT" ]; then
user="${DEVUSER_USERENT%%:*}"
@ -505,7 +499,9 @@ else
shift
done
if [ "$1" == ci ]; then
if [ -z "$1" ]; then
die "no command specified"
elif [ "$1" == ci ]; then
eecho "== installing composer dependencies"
composer i
elif [ "$1" == cu ]; then
@ -517,6 +513,6 @@ else
if [ -n "$chdir" ]; then
cd "$chdir" || exit 1
fi
exec "${@:-bash}"
exec "$@"
fi
fi