build: autocompilation avec choix des révisions et configuration de la compilation

This commit is contained in:
Nicolas Hordé 2020-09-19 22:21:25 +02:00
parent 14fe26752f
commit ff367b8462
10 changed files with 86 additions and 38 deletions

View File

@ -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

View File

@ -1,2 +0,0 @@
#!/bin/bash
docker build . -t cos2000-compiler-alpine

View File

@ -1,2 +0,0 @@
#!/bin/bash
docker build . -t cos2000-compiler

View File

@ -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

View File

@ -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

7
docker/dockerfile.debian Normal file
View File

@ -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

View File

@ -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)

50
make.sh
View File

@ -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
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

View File

@ -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

26
menu.sh
View File

@ -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
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é $ALL..."
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