This repository was archived by the owner on Dec 20, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmake-grml-plus
More file actions
executable file
·177 lines (157 loc) · 6.05 KB
/
make-grml-plus
File metadata and controls
executable file
·177 lines (157 loc) · 6.05 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash
echo "grml-plus installation script"
echo "(c) 2013-2017 Michael Schierl"
echo "Licensed under GPLv2 or later"
echo "============================="
set -e
if [ -z "$1" ]; then
echo "Usage: ./make-grml-plus [device]" >&2
exit 1
fi
DEVICE=$1
MBR=`echo $1 | sed 's/[0-9]//g'`
if [ ! -b $DEVICE -o ! -b $MBR ]; then
echo "Error: Either $DEVICE or $MBR is not a valid block device." >&2
exit 1
fi
if [ ! "`grub-probe -d $DEVICE -t fs`" == "fat" ]; then
echo "Error: $DEVICE is not formatted with the fat filesystem." >&2
exit 1
fi
if [ ! "`grub-probe -d $DEVICE -t partmap`" == "msdos" ]; then
echo "Error: $MBR does not contain a MBR style partition table." >&2
exit 1
fi
echo "Mounting $DEVICE to /tmp/grml-plus/mnt."
mkdir -p /tmp/grml-plus/mnt
umount /tmp/grml-plus/mnt 2>/dev/null || true
mount $DEVICE /tmp/grml-plus/mnt
echo "DEVICE=$DEVICE" >/tmp/grml-plus/devicename
cd `dirname $0`/data
DATADIR=`pwd`
cd /tmp/grml-plus/mnt
mkdir -p grml-plus/grub/i386-pc
if [ -f grml-plus/grub/i386-pc/loopback.mod ]; then
echo "loopback.mod found; assuming that Grub2 is already installed."
echo "Remove that file to re-install Grub2 in MBR."
else
echo "Installing Grub2 in MBR."
grub-mkdevicemap -m ../origdevice.map
grep "^`grub-probe -t drive -m ../origdevice.map -d $MBR` " \
../origdevice.map | sed 's/^([^()]*) /(hd0) /' \
>../device.map
echo "Device map used for GRUB2:"
cat ../device.map
GRUBDEV=`grub-probe -t drive -m ../device.map -d $DEVICE`
echo "GRUB device used: $GRUBDEV"
grub-mkimage -d /usr/lib/grub/i386-pc -O i386-pc -o ../core.img \
-p ${GRUBDEV}/grml-plus/grub biosdisk fat part_msdos
grub-bios-setup -d . -m ../device.map -c ../core.img \
-b ../../../usr/lib/grub/i386-pc/boot.img $MBR
echo "Patching GRUB2 MBR for enhanced compatibility."
perl $DATADIR/patch-grub-mbr.pl $MBR
echo "GRUB2 installation to MBR finished."
cp /usr/lib/grub/i386-pc/{bitmap,bitmap_scale,boot,bufio,crypto,extcmd,font,fshelp,gfxterm,gzio,iso9660,loopback,normal,terminal,video,test,gettext}.mod grml-plus/grub/i386-pc
fi
if [ ! -f grml-plus/kon-boot.img.gz ]; then
echo "Adding Kon-Boot (if you have a commercial version, feel free to replace the free version)."
wget -P .. -nc 'https://www.dropbox.com/s/f5i4g9vlmwoxrtp/kon-boot1.1-free.zip?dl=1'
mkdir ../konboot
unzip -P kon-boot '../kon-boot1.1-free.zip?dl=1' -d ../konboot
unzip ../konboot/kon-boot1.1-free/FD0-konboot-v1.1-2in1.zip \
-d ../konboot
gzip -c ../konboot/FD0-konboot-v1.1-2in1/FD0-konboot-v1.1-2in1.img \
>grml-plus/kon-boot.img.gz
rm -R ../konboot
fi
if [ ! -f grml-plus/allinone.img ]; then
echo "Adding patched All-In-One Boot Floppy image."
cp /lib/live/mount/medium/boot/addons/allinone.img ../allinone.img
mkdir -p ../allinone
mount ../allinone.img ../allinone -t msdos -o loop
rm ../allinone/tools/lucifer.exe
mkdir -p ../patchbase
cp ../allinone/boot/grub/{intro.tct,taiobf.lst} ../patchbase
patch -d ../patchbase -p3 <$DATADIR/allinone.patch
cp ../patchbase/{intro.tct,taiobf.lst} ../allinone/boot/grub
cp /lib/live/mount/medium/boot/addons/memdisk ../allinone/boot/memdisk
cp grml-plus/kon-boot.img.gz ../allinone/boot/kon-boot.imz
wget -P .. -nc http://download.plop.at/files/bootmngr/plpbt-5.0.14.zip
unzip ../plpbt-5.0.14.zip -d ../plpbt
cp ../plpbt/plpbt-5.0.14/plpbt.bin ../allinone/boot/plpbt.bin
rm -R ../plpbt
mkdir -p ../allinone/boot/grub2/kbd
mkdir -p ../kbds
tar xCJf ../kbds $DATADIR/kbds.tar.xz
cp ../kbds/kbds/*.gkb ../allinone/boot/grub2/kbd
umount ../allinone
cp ../allinone.img grml-plus/allinone.img
fi
if [ ! -f grml-plus/rawwritewin.exe ]; then
echo "Adding RawWriteWin.exe."
wget -P .. -nc http://www.chrysocome.net/downloads/rawwritewin-0.7.zip
unzip ../rawwritewin-0.7.zip -d ../rawwrite
cp ../rawwrite/rawwritewin.exe grml-plus/rawwritewin.exe
rm -R ../rawwrite
fi
if [ "`dpkg --print-architecture`" = "amd64" -a ! -f grml-plus/hdt.img ]; then
echo "WARNING: Unable to compile hdt.img"
touch grml-plus/hdt.img
fi
if [ ! -f grml-plus/hdt.img ]; then
echo "Adding HDT."
wget -P .. -nc https://www.kernel.org/pub/linux/utils/boot/syslinux/6.xx/syslinux-6.03.zip
unzip ../syslinux-6.03.zip -d ../syslinux
cd ../syslinux/com32/hdt
cp ../../bios/com32/hdt/hdt.c32 .
cp ../../bios/mtools/syslinux ../../mtools
cp ../../bios/com32/menu/menu.c32 ../menu
cp ../../bios/com32/chain/chain.c32 ../chain
sed -i 's/hdt.elf.*//;s/.*LDFLAGS.*//' Makefile
cp /lib/live/mount/medium/boot/addons/pci.ids floppy
gzip --best floppy/pci.ids
topdir=../.. MAKEDIR=../../mk make hdt.img
for i in ../../bios/com32/*/lib*.c32 ../../bios/com32/*/*/lib*.c32; do
MTOOLSRC=floppy/mtools.conf mcopy $i a:
done
cd ../../../mnt
cp ../syslinux/com32/hdt/hdt.img grml-plus/hdt.img
fi
if [ ! -f grml-plus/grub/memtest86.bin ]; then
echo "Adding Memtest86."
wget -P .. -nc http://memtest86.com/downloads/memtest86-4.3.7-iso.zip
mkdir -p ../memtest86/mnt
unzip ../memtest86-4.3.7-iso.zip -d ../memtest86
mount ../memtest86/Memtest86-4.3.7.iso ../memtest86/mnt -o ro,loop
cp ../memtest86/mnt/isolinux/memtest grml-plus/grub/memtest86.bin
umount ../memtest86/mnt
rm -R ../memtest86
fi
if [ ! -f grml-plus/grub/memtest86plus.bin ]; then
echo "Adding Memtest86+."
wget -P .. -nc 'http://memtest.org/download/5.01/memtest86+-5.01.zip'
mkdir ../memtest86plus
unzip ../memtest86+-*.zip -d ../memtest86plus
cp ../memtest86plus/*.bin grml-plus/grub/memtest86plus.bin
rm -R ../memtest86plus
fi
echo "Updating .cfg files."
GRML_ISO=
for i in grml-plus/grml*.iso; do test -f $i && GRML_ISO=`basename $i`; done
if [ -z "$GRML_ISO" ]; then
echo
echo "***********************************************************"
echo "*** WARNING: grml-plus/grml*.iso not found. Your device ***"
echo "*** will probably not be bootable! ***"
echo "***********************************************************"
echo
else
sed "s/%GRML_ISO%/${GRML_ISO}/g" <$DATADIR/grub.cfg \
>grml-plus/grub/grub.cfg
fi
cp $DATADIR/extras.cfg grml-plus/grub
cp $DATADIR/grml-*.sh grml-plus
echo "Cleaning up."
cd $DATADIR/..
umount /tmp/grml-plus/mnt
echo "Done. Enjoy your new grml-plus USB drive or add some extras!"