From 4cf187aabdc07f3a1cbb5a17ac709b45e918ac59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Sat, 19 Sep 2020 20:40:15 +0200 Subject: [PATCH] =?UTF-8?q?build:=20autocompilation=20avec=20choix=20des?= =?UTF-8?q?=20r=C3=A9visions=20et=20configuration=20de=20la=20compilation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/alpine/build.sh | 2 - docker/debian/build.sh | 2 - .../{alpine/dockerfile => dockerfile.alpine} | 0 .../{debian/dockerfile => dockerfile.debian} | 0 make.sh | 52 ++++++++++++++----- makefile | 8 +++ menu.sh | 41 +++++++++++---- 7 files changed, 77 insertions(+), 28 deletions(-) delete mode 100755 docker/alpine/build.sh delete mode 100755 docker/debian/build.sh rename docker/{alpine/dockerfile => dockerfile.alpine} (100%) rename docker/{debian/dockerfile => dockerfile.debian} (100%) diff --git a/docker/alpine/build.sh b/docker/alpine/build.sh deleted file mode 100755 index 23bca2e..0000000 --- a/docker/alpine/build.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -docker build . -t cos2000-compiler-alpine diff --git a/docker/debian/build.sh b/docker/debian/build.sh deleted file mode 100755 index 1b46d05..0000000 --- a/docker/debian/build.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -docker build . -t cos2000-compiler diff --git a/docker/alpine/dockerfile b/docker/dockerfile.alpine similarity index 100% rename from docker/alpine/dockerfile rename to docker/dockerfile.alpine diff --git a/docker/debian/dockerfile b/docker/dockerfile.debian similarity index 100% rename from docker/debian/dockerfile rename to docker/dockerfile.debian diff --git a/make.sh b/make.sh index b9290e0..6a69794 100755 --- a/make.sh +++ b/make.sh @@ -1,23 +1,47 @@ #!/bin/bash + +function tool { + echo "*** Fabrication des outils de compilation par Docker (version ${VERSION} config ${CONFIGURATION})" + docker build - -t $COMPILER < ./docker/dockerfile.${CONFIGURATION} +} + +function configuration { + echo "*** Création du fichier de configuration" + echo -en "compilation=alpine\nvideo=vesa" > ./configuration +} + echo "Autorisation de docker à se connecter à l'écran :0" xhost +local:docker -DOCKER=$(docker -v| grep build) -ALPINE=$(docker image ls| grep cos2000-compiler-alpine) -COMPILER=$(docker image ls| grep cos2000-compiler) PWD=$(pwd) +FILE=${PWD}/configuration +if [ ! -f "$FILE" ]; then + configuration +fi +DOCKER=$(docker -v| grep build) if [ "${DOCKER}" == "" ]; then echo "Docker n'est pas installé..." echo "*** installation si sous gestionnaire de paquet debian (.deb)" sudo apt-get install docker - exit -elif [ "${ALPINE}" != "" ]; then - echo "*** lancement de la version Alpine Linux" - docker run --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --privileged -v ${PWD}:/data cos2000-compiler-alpine make $1 -elif [ "${COMPILER}" != "" ]; then - echo "*** lancement de la version Debian" - docker run --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --privileged -v ${PWD}:/data cos2000-compiler make $1 -else - echo "Docker est installé mais aucune image docker n'est fonctionnelle..." - echo "*** compilation de l'image docker" - docker build ${PWD}/docker/alpine -t cos2000-compiler-alpine + exit +fi +CONFIGURATION=$(sed -rn 's/^compilation=([^\n]+)$/\1/p' ./configuration) +VERSION=$(git rev-parse --short HEAD) +COMPILER=cos2000-compiler-${CONFIGURATION}-${VERSION} +if [ "$1" == "tool" ]; then + tool + exit +fi +if [ "$1" == "configuration" ]; then + configuration + exit +fi +PRESENT=$(docker image ls| grep $COMPILER) +if [ "${PRESENT}" == "" ]; then + tool +fi +echo "*** lancement de la version ${VERSION}" +if [ "$1" == "config" ]; then + docker run --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --privileged -v ${PWD}:/data $COMPILER make $1 +else + docker run --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --privileged -v ${PWD}:/data $COMPILER make $1 fi diff --git a/makefile b/makefile index 7c28fbe..ba9c9ac 100755 --- a/makefile +++ b/makefile @@ -183,3 +183,11 @@ qemu64: killer $(WAIT2S) $(SPICE) +config: + @echo "*** Options de compilation" + @echo "Quelle distribution utiliser avec Docker comme environnement de compilation ?" + @echo "Alpine Linux ou Debian [A*/D]" + @read line; if [ $$line = "D" ]; then sed -i -r 's/compilation=.*/compilation=debian/' configuration ; else sed -i -r 's/compilation=.*/compilation=alpine/' configuration ; fi + @echo "Quel mode vidéo préférez vous utiliser ?" + @echo "VESA ou VGA [E*/G]" + @read line; if [ $$line = "G" ]; then sed -i -r 's/video=.*/video=vga/' configuration ; else sed -i -r 's/video=.*/video=vesa/' configuration ; fi diff --git a/menu.sh b/menu.sh index 6de44ca..66a6d16 100755 --- a/menu.sh +++ b/menu.sh @@ -3,7 +3,7 @@ PWD=$(pwd) FILE=${PWD}/README.md if [ ! -f "$FILE" ]; then echo "Les sources ne sont pas complets..." - echo "* Récupération des sources" + echo "*** Récupération des sources" VERSION=$(git --version|grep version) if [ "${VERSION}" == "" ]; then echo "Git n'est pas installé, veuillez l'installer et relancer le script" @@ -15,6 +15,10 @@ if [ ! -f "$FILE" ]; then git reset --hard rm -rf ../menu.sh fi +FILE=${PWD}/configuration +if [ ! -f "$FILE" ]; then + ./make.sh configuration +fi while true do clear @@ -28,17 +32,18 @@ echo "2u Emulation de COS2000 (uefi)" echo "3l Débuguage de COS2000 (legacy)" echo "3u Débuguage de COS2000 (uefi)" echo "4l Débuguage de COS2000 boot en mode réel (legacy)" -echo "4u Débuguage de COS2000 boot en mode réel (legacy)" +echo "4u Débuguage de COS2000 boot en mode réel (uefi)" echo "5 Réalisez une sauvegarde" echo "6 Tuer tout les processus" echo "7 Nettoyer les sources" echo "8 Voir le disque en hexadécimal" echo "9 Voir le système en hexadécimal" -echo "c Changer la version de developpement" +echo "c Changer la version de développement" +echo "o Changer les options de développement" echo "0 Quitter" echo "------------------------------------------" echo "Choisissez l'action à réaliser..." -read answer +read -p"?" answer clear case "${answer}" in 0*) exit;; @@ -54,20 +59,36 @@ case "${answer}" in 7*) ./make.sh clean;; 8*) ./make.sh view-dsk|more;; 9*) ./make.sh view-sys|more;; +o*) ./make.sh config;; c*) echo "Version disponibles:" SELECT=$(git branch|grep "*"|tr -d "* ") NUM=1 +echo "XX Hash d'une révision particulière" while read LINE do echo "${NUM} ${LINE}" (( NUM++ )) done < <(git branch -lr|tr -d "* "|grep -v HEAD|sed s/".*origin\/"//) -read ANSWER -CHOOSE=$(git branch -lr|tr -d "* "|grep -v HEAD|sed s/".*origin\/"//|tr "\n" " "|cut -d " " -f${ANSWER}) -echo "vous avez selectionné $ALL..." -git checkout $CHOOSE -git clean -fd -git reset --hard +read -p"?" ANSWER +COUNT=$(echo -n ${ANSWER}|wc -c) +if [ "${COUNT}" == "1" ]; then + CHOOSE=$(git branch -lr|tr -d "* "|grep -v HEAD|sed s/".*origin\/"//|tr "\n" " "|cut -d " " -f${ANSWER}) + echo "vous avez selectionné une branche $CHOOSE..." +else + EXIST=$(git show ${ANSWER}) + if [ "${EXIST}" != "" ]; then + CHOOSE=${ANSWER} + echo "vous avez selectionné une révision ${choose}..." + fi +fi +if [ "${CHOOSE}" != "" ]; then + echo "*** Application de la version ${CHOOSE}" + git pull + git checkout $CHOOSE + git clean -fd + git reset --hard + ./make.sh tool +fi read ;; esac