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