From ff367b84625ce2181b3f093d15ce7e794ba7a5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Sat, 19 Sep 2020 22:21:25 +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 --- README.md | 1 + docker/alpine/build.sh | 2 - docker/debian/build.sh | 2 - docker/debian/dockerfile | 9 ---- .../{alpine/dockerfile => dockerfile.alpine} | 4 +- docker/dockerfile.debian | 7 +++ final/makefile | 2 +- make.sh | 52 ++++++++++++++----- makefile | 11 ++++ menu.sh | 34 +++++++++--- 10 files changed, 86 insertions(+), 38 deletions(-) delete mode 100755 docker/alpine/build.sh delete mode 100755 docker/debian/build.sh delete mode 100644 docker/debian/dockerfile rename docker/{alpine/dockerfile => dockerfile.alpine} (53%) create mode 100644 docker/dockerfile.debian diff --git a/README.md b/README.md index 0841369..642bf1f 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ Autres commandes de compilation de COS2000 * `./make.sh debug-boot` debogue le système en mode réel depuis le boot * `./make.sh debug-loader` debogue le système en mode réel depuis le loader * `./make.sh debug-system` debogue le système en mode protégé +* `./make.sh config` change la configuration de la compilation ### Utilisation 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/debian/dockerfile b/docker/debian/dockerfile deleted file mode 100644 index 8096ff2..0000000 --- a/docker/debian/dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM debian:10 - -RUN apt-get update -yq \ -&& apt-get install --no-install-recommends gcc make qemu fusefat fuseext2 gdb ovmf xz-utils psmisc tmux git libc6-dev bsdmainutils tar wget bsdmainutils indent binutils xxd bochs bochs-x bochsbios dos2unix nasm gnome-terminal spice-client-gtk python2.7 qemu-system-x86 -yq \ -&& apt-get clean -y -RUN wget http://ftp.fr.debian.org/debian/pool/main/c/cramfs/cramfsprogs_1.1-6_amd64.deb -O /tmp/cramfsprogs_1.1-6_amd64.deb -RUN dpkg -i /tmp/cramfsprogs_1.1-6_amd64.deb -RUN mkdir /data -WORKDIR /data diff --git a/docker/alpine/dockerfile b/docker/dockerfile.alpine similarity index 53% rename from docker/alpine/dockerfile rename to docker/dockerfile.alpine index 0f0aca1..fd212a7 100644 --- a/docker/alpine/dockerfile +++ b/docker/dockerfile.alpine @@ -3,8 +3,6 @@ RUN echo "http://alpine.42.fr/v3.12/main" > /etc/apk/repositories RUN echo "http://alpine.42.fr/v3.12/community" >> /etc/apk/repositories RUN apk --no-cache update RUN apk --no-cache upgrade -RUN apk --no-cache add font-noto git gcc make qemu qemu-system-i386 dosfstools qemu-system-x86_64 nasm sed gdb ovmf tar wget gzip indent binutils hexdump dos2unix xxd xz tmux git musl-dev gnome-terminal spice-gtk spice-gtk-tools python2 cramfs -RUN mkdir -p /usr/share/qemu/ -RUN ln -s /usr/share/OVMF/OVMF.fd /usr/share/qemu/OVMF.fd +RUN apk --no-cache add font-noto git gcc make qemu qemu-system-i386 dosfstools nasm sed gdb tar wget gzip indent binutils hexdump dos2unix xxd tmux git musl-dev gnome-terminal spice-gtk spice-gtk-tools python2 RUN mkdir /data WORKDIR /data diff --git a/docker/dockerfile.debian b/docker/dockerfile.debian new file mode 100644 index 0000000..ac62636 --- /dev/null +++ b/docker/dockerfile.debian @@ -0,0 +1,7 @@ +FROM debian:10 + +RUN apt-get update -yq \ +&& apt-get install --no-install-recommends gcc make qemu dosfstools gdb psmisc tmux git libc6-dev bsdmainutils tar wget bsdmainutils indent binutils xxd dos2unix nasm gnome-terminal spice-client-gtk python2.7 qemu-system-x86 -yq \ +&& apt-get clean -y +RUN mkdir /data +WORKDIR /data diff --git a/final/makefile b/final/makefile index 3373c2f..67c5033 100755 --- a/final/makefile +++ b/final/makefile @@ -3,7 +3,7 @@ all: cos2000.img cos2000.img: (dd if=/dev/zero of=cos2000.img count=2880 bs=512) (mkfs.msdos -F 12 -n "COS2000" cos2000.img;mkdir ./mnt || true) - (mount cos2000.img ./mnt -o rw) + (mount -t vfat cos2000.img ./mnt -o rw) (cp ../boot/loader.sys ./mnt/) (cp ../system/system.sys ./mnt/;sync) (umount ./mnt) 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 a4a6469..d01b59a 100755 --- a/makefile +++ b/makefile @@ -8,6 +8,7 @@ clean: (cd boot; make clean) (cd lib;make clean) (cd final;make clean) + rm -f configuration sync backup: clean @@ -49,3 +50,13 @@ boot/boot12.bin: lib/libs.o: (cd lib; make) + +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 63bcbe2..e198669 100755 --- a/menu.sh +++ b/menu.sh @@ -32,6 +32,7 @@ echo "7 Tuer tout les processus" echo "8 Nettoyer les sources" echo "9 Voir le disque en hexadécimal" echo "c Changer la version de developpement" +echo "o Changer les options de développement" echo "0 Quitter" echo "------------------------------------------" echo "Choisissez l'action à réaliser..." @@ -48,20 +49,38 @@ case "${answer}" in 7) ./make.sh killer;; 8) ./make.sh clean;; 9) ./make.sh view|more;; -c) echo "Version disponibles:" +o*) ./make.sh config +./make.sh tool +;; +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 checkout $CHOOSE + git clean -fd + git reset --hard + git pull -f + ./make.sh tool +fi read ;; esac @@ -70,3 +89,4 @@ esac done +