summaryrefslogtreecommitdiff
path: root/package/adkinstall/src/adkinstall.foxg20
blob: 99cd899f45d9b043a478a185af8599dc3c45c086 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
# installs a rootfs tar archive from OpenADK onto a micro SD card
# special script for foxboard netus aka foxg20

if [ -z $1 ];then
        printf "Please give your root tar archive as parameter\n"
        exit 1
fi

if [ ! -f $1 ];then
	printf "given root tar archive does not exist\n"
	exit 1
fi

printf "Creating partition scheme\n"
parted -s /dev/mmcblk0 mklabel msdos
sleep 2
maxsize=$(env LC_ALL=C parted /dev/mmcblk0 -s unit cyl print |awk '/^Disk/ { print $3 }'|sed -e 's/cyl//')
rootsize=$(($maxsize-2))
parted -s /dev/mmcblk0 unit cyl mkpart primary fat32 0 5
parted -s /dev/mmcblk0 unit cyl mkpart primary ext2 5 $rootsize
parted -s /dev/mmcblk0 unit cyl mkpart primary fat32 $rootsize $maxsize
parted -s /dev/mmcblk0 set 1 boot on
sfdisk --change-id /dev/mmcblk0 3 88 >/dev/null 2>&1
sleep 2
sync
printf "Creating vfat filesystem\n"
mkfs.vfat /dev/mmcblk0p1 >/dev/null 2>&1
printf "Creating ext2 filesystem\n"
mke2fs /dev/mmcblk0p2 >/dev/null 2>&1
tune2fs -c0 -i0 /dev/mmcblk0p2 >/dev/null 2>&1
mount -t ext2 /dev/mmcblk0p2 /mnt
mkdir /mnt/boot
mount -t vfat /dev/mmcblk0p1 /mnt/boot

printf "Extracting install archive\n"
tar -C /mnt -xzpf $1
if [ $? -ne 0 ];then
	printf "Extracting of install archive failed"
	exit 1
fi

chmod 1777 /mnt/tmp
chmod 4755 /mnt/bin/busybox
sync
umount /mnt/boot
umount /mnt
if [ $? -ne 0 ];then
	printf "Unmounting filesystem failed"
	exit 1
else
	printf "Successfully installed.\n"
	exit 0
fi