1 |
beyerle@PS |
1 |
#!/bin/bash
|
|
|
2 |
# Insert/remove files (modules) into/from CD filesystem (iso)
|
|
|
3 |
# Author: Tomas M. <http://www.linux-live.org>
|
|
|
4 |
#
|
|
|
5 |
|
|
|
6 |
if [ "$2" = "" ]; then
|
|
|
7 |
echo
|
|
|
8 |
echo "Add or remove files from ISO filesystem specified by 'source'"
|
|
|
9 |
echo "Usage: $0 [ options ] iso_source /path/new.iso"
|
|
|
10 |
echo
|
|
|
11 |
echo " The options are"
|
|
|
12 |
echo " -r <file|dir> ... remove a file from the ISO"
|
|
|
13 |
echo " (path is relative to the ISO root)"
|
|
|
14 |
echo " -a <path_in_iso=file|dir> ... add a file to the ISO, save it to 'path_in_iso'"
|
|
|
15 |
echo " (path_in_iso is relative to the ISO root"
|
|
|
16 |
echo " and if ommited, defaults to root /)"
|
|
|
17 |
echo
|
|
|
18 |
echo " For example, to remove vmlinuz from the ISO and place new slax.ico to the root"
|
|
|
19 |
echo " (from the file /home/tom/slax.ico), execute the following command:"
|
|
|
20 |
echo " $0 -r /vmlinuz -a /slax.ico=/home/tom/slax.ico /slax-orig.iso /new.iso"
|
|
|
21 |
echo
|
|
|
22 |
exit
|
|
|
23 |
fi
|
|
|
24 |
|
|
|
25 |
CDNAME="OwnLiveCD"
|
|
|
26 |
ISOLINUXBIN=/tmp/isolinux$$.bin
|
|
|
27 |
|
|
|
28 |
while [ ! "$3" = "" ]; do
|
|
|
29 |
if [ "$1" = "-r" ]; then EXCLUDE="$EXCLUDE -x $DATADIR/$2"; fi
|
|
|
30 |
if [ "$1" = "-a" ]; then GRAFT="$GRAFT `echo \"$2=$2\" | cut -d \"=\" -f 1-2`"; fi
|
|
|
31 |
shift; shift
|
|
|
32 |
done
|
|
|
33 |
|
|
|
34 |
# mount iso if not already mounted
|
|
|
35 |
if [ ! -d "$DATADIR" ]; then
|
|
|
36 |
DATADIR=/tmp/livecd_data$$
|
|
|
37 |
mkdir -p "$DATADIR"
|
|
|
38 |
mount -o loop "$1" "$DATADIR"
|
|
|
39 |
fi
|
|
|
40 |
|
|
|
41 |
# isolinux.bin is changed during the ISO creation,
|
|
|
42 |
# so we need to restore it from the backup.
|
|
|
43 |
gunzip -c $DATADIR/isolinux.bin.gz >$ISOLINUXBIN
|
|
|
44 |
|
|
|
45 |
mkisofs -o "$2" -v -J -R -D -A "$CDNAME" -V "$CDNAME" \
|
|
|
46 |
-no-emul-boot -boot-info-table -boot-load-size 4 \
|
|
|
47 |
-x "$DATADIR/isolinux.bin" -x "$DATADIR/isolinux.boot" $EXCLUDE \
|
|
|
48 |
-b isolinux.bin -c isolinux.boot \
|
|
|
49 |
-graft-points isolinux.bin=$ISOLINUXBIN $GRAFT "$DATADIR"
|
|
|
50 |
|
|
|
51 |
# cleanup all temporary files and directories
|
|
|
52 |
rm $ISOLINUXBIN
|
|
|
53 |
umount "$DATADIR" 2>/dev/null >/dev/null
|
|
|
54 |
if [ "$?" = "0" ]; then rmdir $DATADIR; fi
|