5 while getopts "f:i" option
15 printf "Option not recognized\n"
20 shift $
(($OPTIND - 1))
22 if [ $
(id
-u) -ne 0 ];then
23 printf "Installation is only possible as root\n"
27 printf "Checking if mkfs is installed"
28 mkfs
=$
(which mkfs.
$filesystem)
30 if [ ! -z $mkfs -a -x $mkfs ];then
37 printf "Checking if parted is installed"
38 parted
=$
(which parted
)
40 if [ ! -z $parted -a -x $parted ];then
47 printf "Checking if qemu-img is installed"
48 qimg
=$
(which qemu-img
)
50 if [ ! -z $qimg -a -x $qimg ];then
58 printf "Please give the name of the image file\n"
62 if [ -z $initramfs ];then
64 printf "Please give the name of the openadk archive file\n"
69 printf "Please give the full path prefix to kernel/initramfs\n"
75 printf "Generate qemu image (512 MB)\n"
76 $qimg create
-f raw
$1 512M
>/dev
/null
78 printf "Creating filesystem $filesystem\n"
80 printf "Create partition and filesystem\n"
81 $parted -s $1 mklabel msdos
82 $parted -s $1 -- mkpart primary ext2
0 -0
83 $parted -s $1 set 1 boot on
85 offset
=$
(parted
$1 unit b print |
tail -2 |
head -1 | cut
-f 1 --delimit="B" | cut
-c 9-)
87 dd if=$1 of
=mbr bs
=$offset count
=1 2>/dev
/null
88 dd if=$1 skip
=$offset of
=$1.new
2>/dev
/null
90 if [ "$filesystem" = "ext2" -o "$filesystem" = "ext3" -o "$filesystem" = "ext4" ];then
94 mkfs.
$filesystem $mkfsopts ${1}.new
>/dev
/null
97 printf "Successfully created partition\n"
100 printf "Partition creation failed, Exiting.\n"
104 cat mbr
${1}.new
> $1
110 mount
-o loop
,offset
=$offset -t $filesystem $1 $tmp
112 if [ -z $initramfs ];then
113 printf "Extracting install archive\n"
115 printf "Fixing permissions\n"
117 chmod 4755 $tmp/bin
/busybox
119 printf "Copying kernel/initramfs\n"
120 mkdir
$tmp/boot
$tmp/dev
121 cp $2-kernel $tmp/boot
/kernel
122 cp $2-initramfs $tmp/boot
/initramfs
126 printf "Successfully installed.\n"
127 printf "Be sure $1 is writable for the user which use qemu\n"