[Galaxy S I9000 Q&A, Help & Troubleshooting] nikagl:
Hi kblam,

Well... it's still a work in progress. Not sure why it doesn't work at the moment, but here's my current script:

#!/bin/sh

echo 'Requesting password to allow running as root...'
sudo echo 'Thanks :)!'

# Make folder
if [ ! -d "BuildOdin" ]
then
mkdir BuildOdin
fi

# Copy BaseRom files
cp BaseRom/adsp.mbn BuildOdin/adsp.mbn
cp BaseRom/amss.mbn BuildOdin/amss.mbn
cp BaseRom/cache.img.ext4 BuildOdin/cache.img.ext4
cp BaseRom/preload.img.ext4 BuildOdin/preload.img.ext4

# Copy boot image
if [ -s NewRom/boot.img ]
then
cp NewRom/boot.img BuildOdin/boot.img
else
cp BaseRom/boot.img BuildOdin/boot.img
fi

# Copy recovery image
if [ -s NewRom/recovery.img ]
then
cp NewRom/recovery.img BuildOdin/recovery.img
else
cp BaseRom/recovery.img BuildOdin/recovery.img
fi

# Create system image

mysyssize=`du -s -h NewRom/system | awk 'BEGIN{FS="[M]"} {print $1}'`
mysyssizeincreased=$((mysyssize+50))
echo 'Filesize will be' $mysyssizeincreased 'MB'

echo 'dd empty image...'
dd if=/dev/zero of=BuildOdin/system.img.ext4 bs=1M count=$mysyssizeincreased >&- 2>&-

echo 'make it ext4...'
mke2fs -F -T ext4 BuildOdin/system.img.ext4 >&- 2>&-

echo 'mounting...'
sudo mount -t ext4 -o loop BuildOdin/system.img.ext4 /mnt >&- 2>&-

echo 'copying system...'
cp NewRom/system/* /mnt -rp
sync

echo 'unmounting...'
sudo umount /mnt

# Create Odin and Odin MD5 files
cd BuildOdin

echo 'tarring...'
tar -cf MyOdinpack.tar adsp.mbn amss.mbn boot.img cache.img.ext4 preload.img.ext4 recovery.img system.img.ext4

echo 'copying...'
cp MyOdinpack.tar MyOdinpack.tar.md5

echo 'md5sum...'
md5sum -t MyOdinpack.tar>>MyOdinpack.tar.md5

echo 'done!'

Taking out all unnessesary comments and commands, what it's supposed to do is the following:

1. First copy the files from the BaseRom (the ones you usually do not extract either):

cp BaseRom/adsp.mbn BuildOdin/adsp.mbn
cp BaseRom/amss.mbn BuildOdin/amss.mbn
cp BaseRom/cache.img.ext4 BuildOdin/cache.img.ext4
cp BaseRom/preload.img.ext4 BuildOdin/preload.img.ext4

2. Then take the boot and recovery from another folder as they usually need to be based on another kernel (f/e Skyhigh kernel ;)) and/or recovery (f/e CWM/Faemod):

cp NewRom/boot.img BuildOdin/boot.img
cp NewRom/recovery.img BuildOdin/recovery.img

3. Take the size of the new image (based on the system folder size + 50):

mysyssize=`du -s -h NewRom/system | awk 'BEGIN{FS="[M]"} {print $1}'`
mysyssizeincreased=$((mysyssize+50))

4. Create an empty system image

dd if=/dev/zero of=BuildOdin/system.img.ext4 bs=1M count=$mysyssizeincreased >&- 2>&-

5. Convert it to ext4

mke2fs -F -T ext4 BuildOdin/system.img.ext4 >&- 2>&-

6. Mount it and copy the new system files (can be unzipped from the cwm-zip) and unmount

sudo mount -t ext4 -o loop BuildOdin/system.img.ext4 /mnt >&- 2>&-
cp NewRom/system/* /mnt -rp
sync
sudo umount /mnt

7. The rest is same to building other md5 odin files. Combine them with tar and calculate and add the md5 sum

tar -cf MyOdinpack.tar adsp.mbn amss.mbn boot.img cache.img.ext4 preload.img.ext4 recovery.img system.img.ext4
cp MyOdinpack.tar MyOdinpack.tar.md5
md5sum -t MyOdinpack.tar>>MyOdinpack.tar.md5

As mentioned - I am not sure why the system image created this way does not work yet (I only tested it once) - maybe someone else is willing to test?

Regards,

Nika.