Revision fcce5224 create

b/create
21 21

  
22 22
. common.sh
23 23

  
24
DPKG_ARCH=${ARCH:-`dpkg --print-architecture`}
25

  
26
# If the target device is not a real block device we'll first losetup it.
27
# This is needed for file disks.
28
if [ ! -b $blockdev ]; then
29
  ORIGINAL_BLOCKDEV=$blockdev
30
  blockdev=$($LOSETUP -sf $blockdev)
31
  CLEANUP+=("$LOSETUP -d $blockdev")
32
fi
33

  
34
if [ "$PARTITION_STYLE" = "none" ]; then
35
  filesystem_dev=$blockdev
36
elif [ "$PARTITION_STYLE" = "msdos" ]; then
37
  # Create one big partition, and make it bootable
38
  format_disk0 $blockdev
39
  filesystem_dev=$(map_disk0 $blockdev)
40
  CLEANUP+=("unmap_disk0 $blockdev")
41
else
42
  echo "Unknown partition style $PARTITION_STYLE"
43
  exit 1
44
fi
45

  
46
mke2fs -Fjq $filesystem_dev
47
root_uuid=$($VOL_ID $filesystem_dev )
48

  
49
if [ -n "$swapdev" ]; then
50
  mkswap $swapdev
51
  swap_uuid=$($VOL_ID $swapdev || true )
52
fi
53

  
54
TMPDIR=`mktemp -d` || exit 1
55
CLEANUP+=("rmdir $TMPDIR")
56

  
57
mount $filesystem_dev $TMPDIR
58
CLEANUP+=("umount $TMPDIR")
59

  
60
cp -p /etc/hosts $TMPDIR/etc/hosts
61
cp -p /etc/resolv.conf $TMPDIR/etc/resolv.conf
62
echo $instance > $TMPDIR/etc/hostname
63
echo $instance > $TMPDIR/etc/mailname
64

  
65
cat > $TMPDIR/etc/fstab <<EOF
66
# /etc/fstab: static file system information.
67
#
68
# <file system>   <mount point>   <type>  <options>       <dump>  <pass>
69
UUID=$root_uuid   /               ext3    defaults        0       1
70
proc              /proc           proc    defaults        0       0
71
EOF
72

  
73
[ -n "$swapdev" -a -n "$swap_uuid" ] && cat >> $TMPDIR/etc/fstab <<EOF
74
UUID=$swap_uuid   swap            swap    defaults        0       0
75
EOF
76

  
77
cat > $TMPDIR/etc/network/interfaces <<EOF
78
auto lo
79
iface lo inet loopback
80
EOF
81

  
82
if [ -e $TMPDIR/etc/inittab ]; then
83
  cat $TMPDIR/etc/inittab | sed -re 's/\stty1$/ console/' \
84
    > $TMPDIR/etc/inittab.new
85
  mv $TMPDIR/etc/inittab.new $TMPDIR/etc/inittab
86
elif [ -e $TMPDIR/etc/event.d/tty1 ]; then
87
  cat $TMPDIR/etc/event.d/tty1 | sed -re 's/tty1/console/' \
88
    > $TMPDIR/etc/event.d/console
89
  rm $TMPDIR/etc/event.d/tty1
90
fi
91

  
92
RUN_PARTS=`which run-parts`
93

  
94
if [ -n "$RUN_PARTS" -a -n "$CUSTOMIZE_DIR" -a -d "$CUSTOMIZE_DIR" ]; then
95
  TARGET=$TMPDIR
96
  BLOCKDEV=$blockdev
97
  FSYSDEV=$filesystem_dev
98
  export TARGET SUITE ARCH PARTITION_STYLE EXTRA_PKGS BLOCKDEV FSYSDEV
99
  $RUN_PARTS $CUSTOMIZE_DIR
24
if [ "$CDINSTALL" = "no" ] ; then
25
    # If the target device is not a real block device we'll first losetup it.
26
    # This is needed for file disks.
27
    if [ ! -b $blockdev ]; then
28
      ORIGINAL_BLOCKDEV=$blockdev
29
      blockdev=$($LOSETUP -sf $blockdev)
30
      CLEANUP+=("$LOSETUP -d $blockdev")
31
    fi
32

  
33
    if [ "$PARTITION_STYLE" = "none" ]; then
34
      filesystem_dev=$blockdev
35
    elif [ "$PARTITION_STYLE" = "msdos" ]; then
36
      # Create one big partition, and make it bootable
37
      format_disk0 $blockdev
38
      filesystem_dev=$(map_disk0 $blockdev)
39
      CLEANUP+=("unmap_disk0 $blockdev")
40
    else
41
      echo "Unknown partition style $PARTITION_STYLE"
42
      exit 1
43
    fi
44

  
45
    mke2fs -Fjq $filesystem_dev
46
    root_uuid=$($VOL_ID $filesystem_dev )
47

  
48
    if [ -n "$swapdev" ]; then
49
      mkswap $swapdev
50
      swap_uuid=$($VOL_ID $swapdev || true )
51
    fi
52

  
53
    ##
54
    # Do magical restore action for fast installs here
55
    ##
56

  
57
    TMPDIR=`mktemp -d` || exit 1
58
    CLEANUP+=("rmdir $TMPDIR")
59

  
60
    mount $filesystem_dev $TMPDIR
61
    CLEANUP+=("umount $TMPDIR")
62

  
63
    RUN_PARTS=`which run-parts`
64

  
65
    if [ -n "$RUN_PARTS" -a -n "$CUSTOMIZE_DIR" -a -d "$CUSTOMIZE_DIR" ]; then
66
      TARGET=$TMPDIR
67
      BLOCKDEV=$blockdev
68
      FSYSDEV=$filesystem_dev
69
      export TARGET SUITE ARCH PARTITION_STYLE EXTRA_PKGS BLOCKDEV FSYSDEV
70
      $RUN_PARTS $CUSTOMIZE_DIR
71
    fi
100 72
fi
101 73

  
102 74
# execute cleanups

Also available in: Unified diff