Merge branch 'master' of ssh://barnulf.net:2255/epita/epitls_vm
This commit is contained in:
commit
0d9dc6c780
1 changed files with 0 additions and 0 deletions
73
src/build.sh
Executable file
73
src/build.sh
Executable file
|
@ -0,0 +1,73 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
cd "$(dirname "$(realpath "$0")")"
|
||||
|
||||
alias log='echo [build.sh]'
|
||||
|
||||
|
||||
VBOX_VERSION=$(VBoxManage --version | cut -d 'r' -f 1)
|
||||
ETH_DEV=$(route | grep '^default' | grep -o '[^ ]*$')
|
||||
VM_NAME="epitls_build"
|
||||
|
||||
|
||||
log "updating environment"
|
||||
sudo rm -fr tmp
|
||||
mkdir -p tmp output
|
||||
if ! [ -f output/guest_add.iso ]
|
||||
then wget -O output/guest_add.iso "https://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso"
|
||||
fi
|
||||
|
||||
|
||||
AURS="zerofree"
|
||||
|
||||
|
||||
log "creating package db"
|
||||
rm -fr /tmp/custom-db
|
||||
mkdir /tmp/custom-db
|
||||
for aur in $AURS
|
||||
do
|
||||
git clone "https://aur.archlinux.org/$aur.git" "/tmp/custom-db/$aur"
|
||||
( cd "/tmp/custom-db/$aur" && makepkg; )
|
||||
mv /tmp/custom-db/$aur/$aur-* /tmp/custom-db/
|
||||
repo-add /tmp/custom-db/custom.db.tar.gz /tmp/custom-db/$aur-*.pkg.tar.zst
|
||||
done
|
||||
|
||||
|
||||
log "creating iso"
|
||||
sudo mkarchiso -v -w $PWD/tmp/wdir -r -o $PWD/output $PWD/profile
|
||||
rm -f output/install.iso
|
||||
mv output/archlinux-*.iso output/install.iso
|
||||
|
||||
|
||||
if VBoxManage showvminfo $VM_NAME 2> /dev/null
|
||||
then log "disposing old VM"
|
||||
VBoxManage unregistervm $VM_NAME --delete-all
|
||||
fi
|
||||
|
||||
|
||||
log "creating VM"
|
||||
VBoxManage createvm --name=$VM_NAME --ostype=ArchLinux_64 --register
|
||||
VBoxManage modifyvm $VM_NAME --cpus=4 --memory=4096 --vram=12 --firmware=efi
|
||||
VBoxManage modifyvm $VM_NAME --nic1=bridged --bridgeadapter1=$ETH_DEV
|
||||
VBoxManage createhd --filename=$PWD/tmp/drive.vdi --size=$((1024 * 20)) --variant=Standard
|
||||
VBoxManage storagectl $VM_NAME --name=SATA --add sata --bootable on
|
||||
VBoxManage storageattach $VM_NAME --storagectl=SATA --port=0 --device=0 --type=hdd --medium=$PWD/tmp/drive.vdi
|
||||
VBoxManage storagectl $VM_NAME --name=IDE --add ide
|
||||
VBoxManage storageattach $VM_NAME --storagectl=IDE --port=0 --device=0 --type=dvddrive --medium=$PWD/output/install.iso
|
||||
VBoxManage storageattach $VM_NAME --storagectl=IDE --port=1 --device=1 --type=dvddrive --medium=$PWD/output/guest_add.iso
|
||||
|
||||
|
||||
log "running VM with iso"
|
||||
virtualboxvm --startvm $VM_NAME --dvd $PWD/output/install.iso
|
||||
|
||||
|
||||
log "exporting VM"
|
||||
VBoxManage storageattach $VM_NAME --storagectl=IDE --port=0 --device=0 --medium=none # removes iso after run
|
||||
VBoxManage storageattach $VM_NAME --storagectl=IDE --port=1 --device=1 --medium=none # removes iso after run
|
||||
VBoxManage modifyhd $PWD/tmp/drive.vdi -compact
|
||||
rm -f $PWD/output/epitls.ova
|
||||
VBoxManage export $VM_NAME --output=$PWD/output/epitls.ova --vsys=0 --vmname=epitls --description="VM pour le développement à EPITA Toulouse."
|
||||
|
||||
|
||||
log "disposing VM"
|
||||
VBoxManage unregistervm $VM_NAME --delete-all
|
Loading…
Add table
Add a link
Reference in a new issue