support des fichiers .dist
This commit is contained in:
parent
f44d9ef404
commit
8b34d8da6b
62
runphp/build
62
runphp/build
|
@ -6,6 +6,7 @@ RUNPHP="$MYDIR/runphp"
|
||||||
RUNPHP_STANDALONE=
|
RUNPHP_STANDALONE=
|
||||||
PROJDIR=; COMPOSERDIR=; COMPOSERPHAR=; VENDORDIR=; BUILDENV0=; BUILDENV=
|
PROJDIR=; COMPOSERDIR=; COMPOSERPHAR=; VENDORDIR=; BUILDENV0=; BUILDENV=
|
||||||
BUILD_IMAGES=(php-apache mariadb10); export BUILD_FLAVOUR=; DIST=; IMAGENAME=
|
BUILD_IMAGES=(php-apache mariadb10); export BUILD_FLAVOUR=; DIST=; IMAGENAME=
|
||||||
|
DISTFILES=()
|
||||||
source "$RUNPHP" || exit 1
|
source "$RUNPHP" || exit 1
|
||||||
source "$PROJDIR/$VENDORDIR/nulib/php/load.sh" || exit 1
|
source "$PROJDIR/$VENDORDIR/nulib/php/load.sh" || exit 1
|
||||||
require: template
|
require: template
|
||||||
|
@ -55,26 +56,65 @@ function dcrunning() {
|
||||||
|
|
||||||
function build_check_env() {
|
function build_check_env() {
|
||||||
eval "$(template_locals)"
|
eval "$(template_locals)"
|
||||||
|
local updatedenv distfile distname
|
||||||
|
local -a updatedfiles distfiles
|
||||||
|
|
||||||
template_copy_missing "$PROJDIR/$BUILDENV0" && updated=1
|
if template_copy_missing "$PROJDIR/$BUILDENV0"; then
|
||||||
|
updated=1
|
||||||
|
updatedenv=1
|
||||||
|
fi
|
||||||
|
for distfile in "${DISTFILES[@]}"; do
|
||||||
|
if [ -f "$PROJDIR/$distfile" ]; then
|
||||||
|
if template_copy_missing "$PROJDIR/$distfile"; then
|
||||||
|
updated=1
|
||||||
|
setx distname=basename -- "$distfile"
|
||||||
|
distname="${distname#.}"; distname="${distname%.dist}"
|
||||||
|
setx distfile=dirname -- "$distfile"
|
||||||
|
distfile="$distfile/$distname"
|
||||||
|
updatedfiles+=("$distfile")
|
||||||
|
fi
|
||||||
|
elif [ -d "$PROJDIR/$distfile" ]; then
|
||||||
|
local distdir="$PROJDIR/$distfile"
|
||||||
|
setx -a distfiles=find "$distdir" -type f -name ".*.dist"
|
||||||
|
for distfile in "${distfiles[@]}"; do
|
||||||
|
if template_copy_missing "$distfile"; then
|
||||||
|
updated=1
|
||||||
|
setx distname=basename -- "$distfile"
|
||||||
|
distname="${distname#.}"; distname="${distname%.dist}"
|
||||||
|
setx distfile=dirname -- "$distfile"
|
||||||
|
distfile="$distfile/$distname"
|
||||||
|
updatedfiles+=("${distfile#$PROJDIR/}")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
ewarn "$distfile: fichier introuvable"
|
||||||
|
fi
|
||||||
|
done
|
||||||
template_process_userfiles
|
template_process_userfiles
|
||||||
|
|
||||||
if [ -n "$updated" ]; then
|
if [ -n "$updated" ]; then
|
||||||
if [ $(id -u) -ne 0 ]; then
|
enote "IMPORTANT: vous devez paramétrer certains fichiers avant de pouvoir construire les images"
|
||||||
setx userent=getent passwd "$(id -un)"
|
if [ -n "$updatedenv" ]; then
|
||||||
setx userent=qval "$userent"
|
if [ -a $(id -u) -ne 0 ]; then
|
||||||
setx groupent=getent group "$(id -gn)"
|
setx userent=getent passwd "$(id -un)"
|
||||||
setx groupent=qval "$groupent"
|
setx userent=qval "$userent"
|
||||||
sed -i "
|
setx groupent=getent group "$(id -gn)"
|
||||||
|
setx groupent=qval "$groupent"
|
||||||
|
sed -i "
|
||||||
/^#DEVUSER_.*=/s/^#//
|
/^#DEVUSER_.*=/s/^#//
|
||||||
/^DEVUSER_USERENT=/s/=.*/=${userent//\//\\\/}/
|
/^DEVUSER_USERENT=/s/=.*/=${userent//\//\\\/}/
|
||||||
/^DEVUSER_GROUPENT=/s/=.*/=${groupent//\//\\\/}/
|
/^DEVUSER_GROUPENT=/s/=.*/=${groupent//\//\\\/}/
|
||||||
" "$PROJDIR/$BUILDENV"
|
" "$PROJDIR/$BUILDENV"
|
||||||
|
fi
|
||||||
|
enote "\
|
||||||
|
Veuillez vérifier le fichier $BUILDENV
|
||||||
|
${EDITOR:-nano} $BUILDENV"
|
||||||
fi
|
fi
|
||||||
|
[ ${#updatedfiles[*]} -gt 0 ] && enote "\
|
||||||
enote "IMPORTANT: Veuillez faire le paramétrage en éditant le fichier $BUILDENV
|
Le cas échéant, veuillez vérifier ce(s) fichier(s)
|
||||||
${EDITOR:-nano} $BUILDENV
|
${EDITOR:-nano} $(qvals "${updatedfiles[@]}")"
|
||||||
ENSUITE, vous pourrez relancer la commande"
|
enote "ENSUITE, vous pourrez relancer la commande"
|
||||||
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,14 @@ DIST=
|
||||||
# Nom de base de l'image (sans le registry), e.g prefix/
|
# Nom de base de l'image (sans le registry), e.g prefix/
|
||||||
IMAGENAME=
|
IMAGENAME=
|
||||||
|
|
||||||
|
## Fichiers .dist
|
||||||
|
## Lors du build, les fichiers de la forme .name.dist sont copiés vers un
|
||||||
|
## fichier name sauf s'il existe déjà
|
||||||
|
|
||||||
|
# Liste de fichiers (ou de répertoirs à considérer). Pour chaque répertoire, les
|
||||||
|
# fichiers .*.dist dans l'arborescence du répertoire sont recherchés
|
||||||
|
DISTFILES=()
|
||||||
|
|
||||||
#EOF:runphp.userconf:ne pas modifier cette ligne
|
#EOF:runphp.userconf:ne pas modifier cette ligne
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue