1 # Dont forget to update functions.sh check_looptype
2 # $1 is the target directory for the filesystem
5 export source_path="${clst_destpath}"
6 export destination_path="$1"
7 export loopname="image.loop"
9 # We get genkernel-built kernels and initrds in place, create the loopback
10 # file system on $clst_target_path, mount it, copy our bootable filesystem
11 # over, umount it, and have a ready-to-burn ISO tree at $clst_target_path.
13 echo "Calculating size of loopback filesystem..."
14 loopsize=`du -ks ${source_path} | cut -f1`
15 [ "${loopsize}" = "0" ] && loopsize=1
16 # Add 4MB for filesystem slop
17 loopsize=`expr ${loopsize} + 4096`
18 echo "Creating loopback file..."
19 dd if=/dev/zero of=${destination_path}/${loopname} bs=1k count=${loopsize} \
20 || die "${loopname} creation failure"
21 mke2fs -m 0 -F -q ${destination_path}/${loopname} \
22 || die "Couldn't create ext2 filesystem"
23 install -d ${destination_path}/loopmount
24 sync; sync; sleep 3 # Try to work around 2.6.0+ loopback bug
25 mount -t ext2 -o loop ${destination_path}/${loopname} \
26 ${destination_path}/loopmount \
27 || die "Couldn't mount loopback ext2 filesystem"
28 sync; sync; sleep 3 # Try to work around 2.6.0+ loopback bug
29 echo "cp -pPR ${source_path}/* ${destination_path}/loopmount"
30 cp -pPR ${source_path}/* ${destination_path}/loopmount
31 [ $? -ne 0 ] && { umount ${destination_path}/${loopname}; \
32 die "Couldn't copy files to loopback ext2 filesystem"; }
33 umount ${destination_path}/loopmount \
34 || die "Couldn't unmount loopback ext2 filesystem"
35 rm -rf ${destination_path}/loopmount
36 # Now, $clst_target_path should contain a proper bootable image for our
37 # ISO, including boot loader and loopback filesystem.
41 rm -rf "$1/zisofs" > /dev/null 2>&1
42 echo "Creating zisofs..."
43 mkzftree -z 9 -p2 "${clst_destpath}" "$1/zisofs" \
44 || die "Could not run mkzftree, did you emerge zisofs"
48 echo "Copying files for image (no loop)..."
49 cp -pPR "${clst_destpath}"/* "$1" \
50 || die "Could not copy files to image (no loop)"
54 echo "Creating squashfs..."
55 export loopname="image.squashfs"
56 mksquashfs "${clst_destpath}" "$1/${loopname}" ${clst_fsops} -noappend \
57 || die "mksquashfs failed, did you emerge squashfs-tools?"
61 echo "Creating jffs..."
62 export loopname="image.jffs"
63 # fs_check /usr/sbin/mkfs.jffs jffs sys-fs/mtd
64 mkfs.jffs -d ${clst_destpath} -o $1/${loopname} ${clst_fsops} \
65 || die "Could not create a jffs filesystem"
69 echo "Creating jffs2..."
70 export loopname="image.jffs"
71 # fs_check /usr/sbin/mkfs.jffs2 jffs2 sys-fs/mtd
72 mkfs.jffs2 --root=${clst_destpath} --output=$1/${loopname} ${clst_fsops} \
73 || die "Could not create a jffs2 filesystem"
77 echo "Creating cramfs..."
78 export loopname="image.cramfs"
79 #fs_check /sbin/mkcramfs cramfs sys-fs/cramfs
80 mkcramfs ${clst_fsops} ${clst_destpath} $1/${loopname} \
81 || die "Could not create a cramfs filesystem"