add apt sources and prepare pinning
[moebian] / install / cleanroot
1 #!/bin/sh
2 # (c) copyright 2010 by Thomas Tanner <tanner@gmx.de>
3
4 mountpoints="cdrom dev floppy home initrd media mnt nand proc sys syspart tmp"
5
6 test "$#" -eq 0 && echo "$0 destination [source]" && exit 1
7 dest="$1" # rootfs destination (absolute path or device)
8 #dest=`pwd`
9
10 rawdest=no
11 case $dest in 
12 /dev/mmcblk[01]p?)
13     rawdest=yes
14         echo destination is partition
15     test -d /media/moebian && (echo cannot create mountdir; exit 1)
16     mkdir -p /media/moebian
17     mount $dest /media/moebian
18     dest=/media/moebian
19         ;;
20 esac
21
22 cd "$dest"
23 # create toplevel dirs and nand mount point
24 mountpoints="cdrom floppy home initrd media mnt nand proc srv sys syspart tmp"
25 content="usr"
26 copydirs="bin boot etc dev lib sbin root var"
27
28 rm -rf $mountpoints $copydirs $content
29
30 if test $dest = /home && test -L /opt; then
31     if test -d opt.nand; then
32         rm -rf opt
33         mv opt.nand opt
34         ln -sf $dest/opt /opt
35         echo "/home/opt.nand moved to /home/opt and symlink updated"
36     else
37         echo "opt for NAND does not exist"
38     fi
39 fi
40
41 rm /etc/bootmenu.d/moebian.item
42
43 df -h $dest
44
45 if test $rawdest = yes; then
46     echo removing temporary mount point
47     umount $dest && rm -rf $dest
48 fi
49
50 exit 0