home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / lib / partman / commit.d / 50format_ext3 < prev    next >
Encoding:
Text File  |  2009-04-19  |  3.5 KB  |  129 lines

  1. #!/bin/sh
  2.  
  3. . /lib/partman/lib/base.sh
  4.  
  5. enable_swap
  6.  
  7. for dev in $DEVICES/*; do
  8.     [ -d "$dev" ] || continue
  9.     cd $dev
  10.     partitions=
  11.     open_dialog PARTITIONS
  12.     while { read_line num id size type fs path name; [ "$id" ]; }; do
  13.         [ "$fs" != free ] || continue
  14.         partitions="$partitions $id,$num"
  15.     done
  16.     close_dialog
  17.  
  18.     for part in $partitions; do
  19.         id=${part%,*}
  20.         num=${part#*,}
  21.         [ -f $id/method -a -f $id/format \
  22.           -a -f $id/acting_filesystem ] || continue
  23.         filesystem=$(cat $id/acting_filesystem)
  24.         case $filesystem in
  25.             ext3|ext4)
  26.             if [ -f $id/formatted ] && \
  27.                [ $id/formatted -nt $id/method ] && \
  28.                ([ ! -f $id/filesystem ] || \
  29.                 [ $id/formatted -nt $id/filesystem ]); then
  30.                 continue
  31.             fi
  32.             log "Try to create file system for $dev/$id"
  33.             if [ -f $id/mountpoint ]; then
  34.                 template=partman-basicfilesystems/progress_formatting_mountable
  35.                 db_subst $template MOUNT_POINT "$(cat $id/mountpoint)"
  36.             else
  37.                 template=partman-basicfilesystems/progress_formatting
  38.             fi
  39.             open_dialog PARTITION_INFO $id
  40.             read_line x1 x2 x3 x4 x5 device x6
  41.             close_dialog
  42.  
  43.             RET=''
  44.             db_metaget partman/filesystem_short/$filesystem description || RET=''
  45.             [ "$RET" ] || RET=$filesystem
  46.             db_subst $template TYPE "$RET"
  47.             db_subst $template PARTITION "$num"
  48.             db_subst $template DEVICE $(humandev $(cat device))
  49.  
  50.             status=failed
  51.  
  52.             # Commented out for now. As libparted can't create resizable
  53.             # file systems and ext2prepare is too buggy to use for etch,
  54.             # we will always use mkfs.ext3 directly in etch, although
  55.             # that doesn't give us a progress bar.
  56.             # This will also give us dir_index by default.
  57.             #if [ -x /sbin/tune2fs ] && ! [ -f $id/usage ]; then
  58.             #    name_progress_bar $template
  59.             #    open_dialog CREATE_FILE_SYSTEM $id ext2
  60.             #    read_line status
  61.             #    close_dialog
  62.             #    sync
  63.             #    if [ "$status" = OK ]; then
  64.             #        log-output -t partman --pass-stdout \
  65.             #            /sbin/tune2fs -j $device >/dev/null || status=failed
  66.             #        sync
  67.             #    fi
  68.             #fi
  69.  
  70.             if [ "$status" != OK ]; then
  71.                 db_progress START 0 3 partman/text/formatting
  72.                 db_progress INFO $template
  73.                 db_progress SET 1
  74.                 if [ -f $id/usage ]; then
  75.                     usage="-T $(cat $id/usage)"
  76.                     else
  77.                     usage=''
  78.                 fi
  79.                 # According to Szabolcs Szakacsits, the NTFS-3g
  80.                 # author, it is safer to format the loop file,
  81.                 # rather than the device.
  82.                 if [ -s loop ]; then
  83.                     device="$(cat loop)"
  84.                     force=-F
  85.                 fi
  86.                 if log-output -t partman --pass-stdout \
  87.                    mkfs.$filesystem $force "$device" $usage >/dev/null; then
  88.                     sync
  89.                     status=OK
  90.                 else
  91.                     status=failed
  92.                 fi
  93.                 db_progress STOP
  94.             fi
  95.             if [ "$status" = OK ]; then
  96.                 label=''
  97.                 if [ -f $id/label ]; then
  98.                     label=$(cat $id/label | \
  99.                         sed 's/\(................\).*/\1/g')
  100.                 fi
  101.                 if [ "$label" ]; then
  102.                     log-output -t partman --pass-stdout \
  103.                         tune2fs -L "$label" $device >/dev/null
  104.                 fi
  105.                 if [ -f $id/reserved_for_root ]; then
  106.                     log-output -t partman --pass-stdout \
  107.                         tune2fs -m $(cat $id/reserved_for_root) $device >/dev/null
  108.                 fi
  109.             fi
  110.             if [ "$status" != OK ]; then
  111.                 RET=''
  112.                 db_metaget partman/filesystem_short/"$filesystem" description || RET=''
  113.                 [ "$RET" ] || RET="$filesystem"
  114.                 db_subst partman-ext3/create_failed TYPE "$RET"
  115.                 db_subst partman-ext3/create_failed PARTITION "$num"
  116.                 db_subst partman-ext3/create_failed DEVICE $(humandev $(cat device))
  117.                 db_input critical partman-ext3/create_failed || true
  118.                 db_go || true
  119.                 #disable_swap
  120.                 exit 1
  121.             fi
  122.             >$id/formatted
  123.             ;;
  124.         esac
  125.     done
  126. done
  127.  
  128. #disable_swap
  129.