modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-10-18 15:29:05 +04:00
parent 7e8901a7f6
commit 8b7dab9905
1 changed files with 64 additions and 68 deletions

View File

@ -70,6 +70,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"
@ -78,7 +79,7 @@ if [ -n "$RUNPHP_STANDALONE" ]; then
VENDORDIR=vendor
BUILDENV0=
BUILDENV=
DIST="$RUNPHP_DIST"
DIST="${RUNPHP_DIST:-$DEFAULT_DIST}"
IMAGENAME=nulib/
PRIVAREG=docker.io
@ -93,7 +94,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=
@ -154,31 +155,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
@ -186,27 +179,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
@ -253,7 +237,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
@ -261,6 +244,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
@ -272,8 +264,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
@ -288,11 +281,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
@ -303,8 +299,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=
@ -321,8 +317,6 @@ if [ "$RUNPHP_MODE" != docker ]; then
Pull=
NoCache=
PlainOutput=
Chdir=
Verbose=
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
@ -331,7 +325,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
@ -343,11 +337,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";;
@ -362,8 +352,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
@ -383,14 +371,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
@ -419,21 +413,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;;
@ -470,9 +463,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
@ -527,6 +520,7 @@ OPTIONS
else
############################################################################
# Lancement depuis l'intérieur du container
############################################################################
if [ -n "$DEVUSER_USERENT" ]; then
user="${DEVUSER_USERENT%%:*}"
@ -554,7 +548,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
@ -566,6 +562,6 @@ else
if [ -n "$chdir" ]; then
cd "$chdir" || exit 1
fi
exec "${@:-bash}"
exec "$@"
fi
fi