dk: support répertoire/fichier source
This commit is contained in:
		
							parent
							
								
									1d7e2d0949
								
							
						
					
					
						commit
						9fad9924ef
					
				
							
								
								
									
										59
									
								
								dk
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								dk
									
									
									
									
									
								
							| @ -272,7 +272,8 @@ OPTIONS build | |||||||
|             APPS=()               # applications à mettre à jour par défaut |             APPS=()               # applications à mettre à jour par défaut | ||||||
|             PROFILE_APPS=()       # ou... spécifique au profil 'PROFILE' |             PROFILE_APPS=()       # ou... spécifique au profil 'PROFILE' | ||||||
|             app_URL=              # url du dépôt |             app_URL=              # url du dépôt | ||||||
|             app_DEVEL_SRCDIR=     # répertoire source en mode devel |             app_DEVEL_SRCDIR=     # répertoire source du dépôt en mode devel | ||||||
|  |             app_SRC=              # répertoire/fichier source (si URL pas renseigné) | ||||||
|             app_DEST=             # répertoire dans lequel faire le checkout |             app_DEST=             # répertoire dans lequel faire le checkout | ||||||
|             app_PROFILE_ORIGIN=   # origine spécifique au profil 'PROFILE' |             app_PROFILE_ORIGIN=   # origine spécifique au profil 'PROFILE' | ||||||
|             app_ORIGIN=           # ou... origine par défaut de la branche |             app_ORIGIN=           # ou... origine par défaut de la branche | ||||||
| @ -298,6 +299,11 @@ OPTIONS deploy | |||||||
|         (c'est à dire ne pas utiliser l'option --with-registry-auth) |         (c'est à dire ne pas utiliser l'option --with-registry-auth) | ||||||
| 
 | 
 | ||||||
| VARIABLES de update-apps.conf | VARIABLES de update-apps.conf | ||||||
|  |     SRC | ||||||
|  |         répertoire/fichier source, si URL n'est pas défini. si ce chemin est | ||||||
|  |         relatif, il doit être exprimé par rapport au répertoire du projet. | ||||||
|  |         IMPORTANT: dans ce cas, DEST n'est pas le répertoire de base du | ||||||
|  |         checkout, mais le répertoire destination pour la synchro | ||||||
|     DEVEL_SRCDIR |     DEVEL_SRCDIR | ||||||
|         répertoire source pour le mode devel. attention, il s'agit du répertoire |         répertoire source pour le mode devel. attention, il s'agit du répertoire | ||||||
|         du projet, alors que DEFAULT_DEVEL_SRCDIR est le répertoire de base par |         du projet, alors que DEFAULT_DEVEL_SRCDIR est le répertoire de base par | ||||||
| @ -318,6 +324,7 @@ VARIABLES de update-apps.conf | |||||||
|         projet. Les variables suivantes sont disponibles: |         projet. Les variables suivantes sont disponibles: | ||||||
|             URL=                  # url du dépôt |             URL=                  # url du dépôt | ||||||
|             DEVEL_SRCDIR=         # répertoire source en mode devel |             DEVEL_SRCDIR=         # répertoire source en mode devel | ||||||
|  |             SRC=                  # répertoire/fichier source (si URL pas renseigné) | ||||||
|             DEST=                 # répertoire dans lequel faire le checkout |             DEST=                 # répertoire dans lequel faire le checkout | ||||||
|             ORIGIN=               # origine de la branche |             ORIGIN=               # origine de la branche | ||||||
|             BRANCH=               # branche sélectionnée dans le dépôt |             BRANCH=               # branche sélectionnée dans le dépôt | ||||||
| @ -654,8 +661,8 @@ function build_update_apps() { | |||||||
|     DEFAULT_ORIGIN="$UPDATE_APPS_ORIGIN" |     DEFAULT_ORIGIN="$UPDATE_APPS_ORIGIN" | ||||||
|     [ -z "$DEFAULT_ORIGIN" ] && DEFAULT_ORIGIN=origin |     [ -z "$DEFAULT_ORIGIN" ] && DEFAULT_ORIGIN=origin | ||||||
|     DEFAULT_BRANCH="$UPDATE_APPS_BRANCH" |     DEFAULT_BRANCH="$UPDATE_APPS_BRANCH" | ||||||
|     #XXX à terme, on déploiera la branche master en prod |     #XXX à terme, ne déployer en prod que la branche master | ||||||
|     [ -z "$DEFAULT_BRANCH" -a "$PROFILE" == prod ] && DEFAULT_BRANCH=develop #master |     [ -z "$DEFAULT_BRANCH" -a "$PROFILE" == prod ] && DEFAULT_BRANCH=develop #XXX master | ||||||
|     [ -z "$DEFAULT_BRANCH" ] && DEFAULT_BRANCH=develop |     [ -z "$DEFAULT_BRANCH" ] && DEFAULT_BRANCH=develop | ||||||
|     DEFAULT_DEVEL_SRCDIR="$HOME/wop/php" |     DEFAULT_DEVEL_SRCDIR="$HOME/wop/php" | ||||||
|     DEFAULT_COMPOSER_ACTION=install |     DEFAULT_COMPOSER_ACTION=install | ||||||
| @ -685,17 +692,20 @@ function build_update_apps() { | |||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|     etitle "Mise à jour des dépendances" |     etitle "Mise à jour des dépendances" | ||||||
|     local app var URL DEVEL_SRCDIR DEST ORIGIN BRANCH TYPE after_update after_updates composer_action |     local app var URL SRC DEVEL_SRCDIR DEST ORIGIN BRANCH TYPE after_update after_updates composer_action | ||||||
|     for app in "${APPS[@]}"; do |     for app in "${APPS[@]}"; do | ||||||
|         etitle "$app" |         etitle "$app" | ||||||
| 
 | 
 | ||||||
|         var="${app//-/_}" |         var="${app//-/_}" | ||||||
| 
 | 
 | ||||||
|         URL="${var}_URL"; URL="${!URL}" |         URL="${var}_URL"; URL="${!URL}" | ||||||
|         [ -n "$URL" ] || { |         if [ -z "$URL" ]; then | ||||||
|             ewarn "$app: vous devez définir l'url" |             SRC="${var}_SRC"; SRC="${!SRC}" | ||||||
|             eend; return 1 |             if [ -z "$SRC" ]; then | ||||||
|         } |                 ewarn "$app: vous devez définir ${var}_URL ou ${var}_SRC" | ||||||
|  |                 eend; return 1 | ||||||
|  |             fi | ||||||
|  |         fi | ||||||
| 
 | 
 | ||||||
|         DEVEL_SRCDIR="${var}_DEVEL_SRCDIR"; DEVEL_SRCDIR="${!DEVEL_SRCDIR}" |         DEVEL_SRCDIR="${var}_DEVEL_SRCDIR"; DEVEL_SRCDIR="${!DEVEL_SRCDIR}" | ||||||
|         [ -n "$DEVEL_SRCDIR" ] || DEVEL_SRCDIR="$DEFAULT_DEVEL_SRCDIR/${URL##*/}" |         [ -n "$DEVEL_SRCDIR" ] || DEVEL_SRCDIR="$DEFAULT_DEVEL_SRCDIR/${URL##*/}" | ||||||
| @ -715,8 +725,9 @@ function build_update_apps() { | |||||||
|         # calculer le type maintenant, on en a besoin pour le mode devel |         # calculer le type maintenant, on en a besoin pour le mode devel | ||||||
|         TYPE="${var}_TYPE"; TYPE="${!TYPE}" |         TYPE="${var}_TYPE"; TYPE="${!TYPE}" | ||||||
| 
 | 
 | ||||||
|         DEST="$DEST/$app" |  | ||||||
|         if [ -n "$BUILD_UPDATE_DEVEL" ]; then |         if [ -n "$BUILD_UPDATE_DEVEL" ]; then | ||||||
|  |             DEST="$DEST/$app" | ||||||
|  | 
 | ||||||
|             # synchronisation en mode devel |             # synchronisation en mode devel | ||||||
|             local -a rsync_opts; rsync_opts=(-a --delete --exclude .git/ --delete-excluded) |             local -a rsync_opts; rsync_opts=(-a --delete --exclude .git/ --delete-excluded) | ||||||
|             estep "Synchro $DEVEL_SRCDIR --> $DEST" |             estep "Synchro $DEVEL_SRCDIR --> $DEST" | ||||||
| @ -741,7 +752,9 @@ function build_update_apps() { | |||||||
|                     rsync "${rsync_opts[@]}" --exclude /vendor/ "$DEFAULT_DEVEL_SRCDIR/$pname/" "$depdir" |                     rsync "${rsync_opts[@]}" --exclude /vendor/ "$DEFAULT_DEVEL_SRCDIR/$pname/" "$depdir" | ||||||
|                 done |                 done | ||||||
|             fi |             fi | ||||||
|         else |         elif [ -n "$URL" ]; then | ||||||
|  |             DEST="$DEST/$app" | ||||||
|  | 
 | ||||||
|             if [ -d "$DEST" -a -d "$DEST/.git" ]; then |             if [ -d "$DEST" -a -d "$DEST/.git" ]; then | ||||||
|                 # mise à jour |                 # mise à jour | ||||||
|                 estep "Maj dépôt $URL:$BRANCH --> $DEST" |                 estep "Maj dépôt $URL:$BRANCH --> $DEST" | ||||||
| @ -758,6 +771,28 @@ function build_update_apps() { | |||||||
|                 git clone -o "$ORIGIN" -b "$BRANCH" "$URL" "$DEST" || { eend; return 1; } |                 git clone -o "$ORIGIN" -b "$BRANCH" "$URL" "$DEST" || { eend; return 1; } | ||||||
|             fi |             fi | ||||||
| 
 | 
 | ||||||
|  |             if [ -z "$TYPE" ]; then | ||||||
|  |                 # possible de détecter le type quand on a le projet | ||||||
|  |                 # en cas de maj ici, mettre à jour aussi le code ci-dessus et ci-dessous | ||||||
|  |                 if [ -f "$DEST/composer.json" ]; then TYPE=composer | ||||||
|  |                 else TYPE=none | ||||||
|  |                 fi | ||||||
|  |             fi | ||||||
|  | 
 | ||||||
|  |         elif [ -n "$SRC" ]; then | ||||||
|  |             if [ -d "$SRC" ]; then | ||||||
|  |                 local -a rsync_opts; rsync_opts=(-a --delete --exclude .git/ --delete-excluded) | ||||||
|  |                 estep "Synchro $SRC/ --> $DEST" | ||||||
|  |                 rsync "${rsync_opts[@]}" "$SRC/" "$DEST/" || { eend; return 1; } | ||||||
|  |             elif [ -f "$SRC" ]; then | ||||||
|  |                 local -a rsync_opts; rsync_opts=(-a) | ||||||
|  |                 estep "Synchro $SRC --> $DEST" | ||||||
|  |                 rsync "${rsync_opts[@]}" "$SRC" "$DEST/" || { eend; return 1; } | ||||||
|  |             else | ||||||
|  |                 eerror "$app: $SRC: répertoire/fichier introuvable" | ||||||
|  |                 eend; return 1 | ||||||
|  |             fi | ||||||
|  | 
 | ||||||
|             if [ -z "$TYPE" ]; then |             if [ -z "$TYPE" ]; then | ||||||
|                 # possible de détecter le type quand on a le projet |                 # possible de détecter le type quand on a le projet | ||||||
|                 # en cas de maj ici, mettre à jour aussi le code ci-dessus |                 # en cas de maj ici, mettre à jour aussi le code ci-dessus | ||||||
| @ -765,6 +800,10 @@ function build_update_apps() { | |||||||
|                 else TYPE=none |                 else TYPE=none | ||||||
|                 fi |                 fi | ||||||
|             fi |             fi | ||||||
|  | 
 | ||||||
|  |         else | ||||||
|  |             # ne devrait pas se produire | ||||||
|  |             die "ni URL ni SRC ne sont définis" | ||||||
|         fi |         fi | ||||||
| 
 | 
 | ||||||
|         after_updates="${var}_AFTER_UPDATE" |         after_updates="${var}_AFTER_UPDATE" | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user