make should now work on clean compilations, right after make defconfig
[avatt.git] / buildroot / scripts / build-ext3-img
blob1cab710c2555a7f6d2de84807cb57961081dba09
1 #!/bin/sh
3 BLOCKSIZE=516096
4 WORKING_DIR=`pwd`
6 echo "This script will create a bootable ext3 image from buildroot."
8 echo "Enter the path to the image (${WORKING_DIR})"
9 read IMG_PATH
11 if [ "${IMAGE_PATH}" = "" ]; then
12 IMAGE_PATH=${WORKING_DIR}
15 echo "Enter the name of the image file (buildroot.img)"
16 read IMG_NAME
18 if [ "${IMAGE_NAME}" = "" ]; then
19 IMAGE_NAME="buildroot.img"
22 IMAGE=${IMAGE_PATH}/${IMAGE_NAME}
24 echo "Enter the path and filename for the root filesystem"
25 echo "tarball that you want to install into the image"
26 read ROOT_PATH
28 if [ "${ROOT_PATH}" = "" ]; then
29 echo "Error: you must specify a path."
30 exit 1
33 CYLINDERS=`du --summarize --block-size=${BLOCKSIZE} ${ROOT_PATH}`
34 BYTE_SIZE=`du --summarize --block-size=${BLOCKSIZE} --human-readable ${ROOT_PATH}`
36 CYLINDERS=${CYLINDERS%${ROOT_PATH}}
37 BYTE_SIZE=${BYTE_SIZE%${ROOT_PATH}}
39 CYLINDERS=`expr ${CYLINDERS} "*" 2`
41 echo "Now I will create an ext3 image file"
42 echo "using ${CYLINDERS} cylinders, with ${BLOCKSIZE} bytes per block"
43 echo "in other words, ${BYTE_SIZE}bytes..."
45 dd if=/dev/zero of=${IMAGE} bs=${BLOCKSIZE}c count=${CYLINDERS}
47 # Create file partition and filesystem
49 # STEP 1. create partition
50 /sbin/losetup /dev/loop3 ${IMAGE}
51 # probably should figure out how to use GNU parted to do this non-interactively
52 /sbin/fdisk -u -C${CYLINDERS} -S63 -H16 /dev/loop3
53 /sbin/losetup -d /dev/loop3
55 # STEP 2. make file system (ext3)
56 /sbin/losetup -o 32256 /dev/loop3 ${IMAGE}
57 /sbin/mkfs.ext3 /dev/loop3
58 /sbin/losetup -d /dev/loop3
60 # Install Software to the image
61 mkdir -p ${IMAGE_PATH}/temp
62 mount -o offset=32256,loop ${IMAGE} ${IMAGE_PATH}/temp
63 tar -xvf ${ROOT_PATH} --directory ${IMAGE_PATH}/temp
64 # make sure to unmount the image
65 umount ${IMAGE_PATH}/temp
66 rm -rf ${IMAGE_PATH}/temp
68 # Create a VMware .vmx file
69 cat > ${IMAGE_PATH}/buildroot.vmx <<EOF
70 config.version = "8"
71 virtualHW.version = "3"
73 uuid.location = "56 4d 5c cc 3d 4a 43 29-55 89 5c 28 1e 7e 06 58"
74 uuid.bios = "56 4d 5c cc 3d 4a 43 29-55 89 5c 28 1e 7e 06 58"
76 uuid.action = "create"
77 checkpoint.vmState = ""
79 displayName = "Buildroot"
80 annotation = ""
81 guestinfo.vmware.product.long = ""
82 guestinfo.vmware.product.url = "http://dcgrendel.be/vmbuilder/"
84 guestOS = "linux"
85 numvcpus = "1"
86 memsize = "256"
87 paevm = "FALSE"
88 sched.mem.pshare.enable = "TRUE"
89 MemAllowAutoScaleDown = "FALSE"
91 MemTrimRate = "-1"
93 nvram = "nvram"
95 mks.enable3d = "FALSE"
96 vmmouse.present = "TRUE"
98 tools.syncTime = "TRUE"
99 tools.remindinstall = "FALSE"
101 isolation.tools.hgfs.disable = "FALSE"
102 isolation.tools.dnd.disable = "FALSE"
103 isolation.tools.copy.enable = "TRUE"
104 isolation.tools.paste.enabled = "TRUE"
105 gui.restricted = "FALSE"
107 ethernet0.present = "TRUE"
108 ethernet0.connectionType = "bridged"
109 ethernet0.addressType = "generated"
110 ethernet0.generatedAddress = "00:0c:29:7e:06:58"
111 ethernet0.generatedAddressOffset = "0"
113 usb.present = "TRUE"
114 usb.generic.autoconnect = "FALSE"
116 sound.present = "TRUE"
117 sound.virtualdev = "es1371"
119 ide0:0.present = "TRUE"
120 ide0:0.fileName = "buildroot.vmdk"
121 ide0:0.deviceType = "disk"
122 ide0:0.mode = ""
123 ide0:0.redo = ""
124 ide0:0.writeThrough = "FALSE"
125 ide0:0.startConnected = "TRUE"
127 ide1:0.present = "FALSE"
128 ide1:0.fileName = ""
129 ide1:0.deviceType = "disk"
130 ide1:0.mode = ""
131 ide1:0.redo = ""
132 ide1:0.writeThrough = "FALSE"
133 ide1:0.startConnected = "FALSE"
135 floppy0.present = "FALSE"
137 serial0.present = "FALSE"
139 serial1.present = "FALSE"
141 parallel0.present = "FALSE"
145 # Install GRUB
146 /sbin/grub --no-floppy --batch <<EOT
147 device (hd0) ${IMAGE}
148 geometry (hd0) ${CYLINDERS} 16 63
149 root (hd0,0)
150 setup (hd0)
151 quit