forked from bastibl/instant-gnuradio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-iso.sh
executable file
·86 lines (62 loc) · 2.51 KB
/
gen-iso.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
set -eux
export WORK=~/work
export CD=~/cd
export FORMAT=squashfs
export FS_DIR=casper
sudo rm -rf ${WORK} ${CD}
sudo mkdir -p ${CD}/{${FS_DIR},boot/grub} ${WORK}/rootfs
sudo apt-get update
sudo apt-get -y install grub2 xorriso squashfs-tools
sudo rsync -av --one-file-system --exclude=/proc/* --exclude=/dev/* \
--exclude=/sys/* --exclude=/tmp/* --exclude=/lost+found \
--exclude=/boot/grub/* \
--exclude=/root/* \
--exclude=/var/backup/* \
--exclude=/var/cache/* \
--exclude=/var/crash/* \
--exclude=/var/lock/* \
--exclude=/var/log/* \
--exclude=/var/metrics/* \
--exclude=/var/run/* \
--exclude=/var/tmp/* \
--exclude=/var/mail/* \
--exclude=/var/spool/* \
--exclude=/media/* \
--exclude=/etc/fstab --exclude=/etc/mtab --exclude=/etc/hosts \
--exclude=/etc/timezone --exclude=/etc/shadow* --exclude=/etc/gshadow* \
--exclude=/etc/X11/xorg.conf* --exclude=${CD} --exclude=${WORK} \
--exclude=/home/gnuradio/instant-gnuradio.iso \
--exclude=/home/gnuradio/chroot-iso.sh \
--exclude=/home/gnuradio/gen-iso.sh \
/ ${WORK}/rootfs
sudo rm -rf ${WORK}/rootfs/etc/skel
sudo mv ${WORK}/rootfs/home/gnuradio ${WORK}/rootfs/etc/skel
sudo mount --bind /dev/ ${WORK}/rootfs/dev
sudo mount -t proc proc ${WORK}/rootfs/proc
sudo mount -t sysfs sysfs ${WORK}/rootfs/sys
sudo mount -o bind /run ${WORK}/rootfs/run
########### ENTER CHROOT ################
sudo cp ~/chroot-iso.sh ${WORK}/rootfs/
sudo chroot ${WORK}/rootfs /bin/bash /chroot-iso.sh
########### LEAVE CHROOT ###############
export kversion=`cd ${WORK}/rootfs/boot && ls -1 vmlinuz-* | tail -1 | sed 's@vmlinuz-@@'`
sudo cp -vp ${WORK}/rootfs/boot/vmlinuz-${kversion} ${CD}/${FS_DIR}/vmlinuz
sudo cp -vp ${WORK}/rootfs/boot/initrd.img-${kversion} ${CD}/${FS_DIR}/initrd.img
sudo cp -vp ${WORK}/rootfs/boot/memtest86+.bin ${CD}/boot
sudo umount ${WORK}/rootfs/proc
sudo umount ${WORK}/rootfs/sys
sudo umount ${WORK}/rootfs/dev
sudo umount ${WORK}/rootfs/run
sudo mksquashfs ${WORK}/rootfs ${CD}/${FS_DIR}/filesystem.${FORMAT} -noappend
echo -n $(sudo du -s --block-size=1 ${WORK}/rootfs | tail -1 | awk '{print $1}') | sudo tee ${CD}/${FS_DIR}/filesystem.size
find ${CD} -type f -print0 | sudo xargs -0 md5sum | sed "s@${CD}@.@" | grep -v md5sum.txt | sudo tee ${CD}/md5sum.txt
cat << EOF | sudo tee ${CD}/boot/grub/grub.cfg
set default="0"
set timeout=10
menuentry "Instant GNU Radio" {
linux /casper/vmlinuz boot=casper liveimg noprompt noeject --
initrd /casper/initrd.img
}
EOF
sudo grub-mkrescue -o ~/instant-gnuradio.iso ${CD}