-
Notifications
You must be signed in to change notification settings - Fork 5
/
createimg.sh
executable file
·63 lines (51 loc) · 1.77 KB
/
createimg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -e
if [ ! -f ./empty_usb.img ]; then
echo "Empty drive not found!"
echo "Decompressing the image..."
tar -pxvzf ./empty_usb.tar.gz
# cp ~/mimosa-build/empty_usb.img ~/empty_usb.img
# rm ~/mimosa-build/empty_usb.img
fi
if [[ ! -d ./archive-items/gambit/bin ]]; then
echo "Missing the Gambit archive... Downloading a default working version."
mkdir ./archive-items/gambit/bin
wget http://www-ens.iro.umontreal.ca/~yvonsamu/gsc.exe -O ./archive-items/gambit/bin/gsc.exe
fi
# Admin routines
admin-mount() {
sudo mount "$@"
}
admin-umount() {
: "${1:?"Expected path"}"
sudo umount "$1"
}
## Creating image
echo "Mount and write the OS onto the FS"
TMPDIR=$(mktemp -d)
cp ./empty_usb.img ./floppy.img
echo "Mounting..."
admin-mount -t vfat ./floppy.img "$TMPDIR" -o loop,uid=$UID
echo "Mounted"
echo "Copying items to the disk..."
cp kernel.bin "$TMPDIR/BOOT.SYS"
# Copy the Scheme file to the archive
mkdir -p ./archive-items/home/sam
cp -a ./scheme/interpreted/. ./archive-items/home/sam/
mv ./archive-items/home/sam/gambini.scm ./archive-items/home/sam/.gambini.scm
cp -a ./archive-items/. "$TMPDIR"
# mkdir /mnt/tmp/folder
# touch /mnt/tmp/folder/fif.tst
# echo "[0] This is a file pretty deep into the directory structure" >> /mnt/tmp/folder/fif.tst
# mkdir /mnt/tmp/folder/dfolder
# touch /mnt/tmp/folder/dfolder/dfif.tst
# echo "[1] This is a file pretty deep into the directory structure" >> /mnt/tmp/folder/dfolder/dfif.tst
# dd if=/dev/zero of=/mnt/tmp/dummy bs=512 count=2048
# cp ~/mimosa-build/copypa.txt /mnt/tmp/copypa.txt
ls -al "$TMPDIR" # List all the files in the img
admin-umount "$TMPDIR"
rmdir "$TMPDIR"
# Write the bootsector
hexdump -C -n 512 ./floppy.img
dd if=bootsect.bin of=floppy.img bs=512 count=2 conv=notrunc
echo "Image created"