home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / lib / partman / commit.d / 50format_reiserfs < prev    next >
Encoding:
Text File  |  2009-04-19  |  2.4 KB  |  94 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.             reiserfs)
  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.             # Trying to use parted will probably fail;
  52.             # libparted currently doesn't support reiser
  53.             name_progress_bar $template
  54.             open_dialog CREATE_FILE_SYSTEM $id reiserfs
  55.             read_line status
  56.             close_dialog
  57.             sync
  58.             if [ "$status" != OK ]; then
  59.                 db_progress START 0 3 partman/text/formatting
  60.                 db_progress INFO $template
  61.                 db_progress SET 1
  62.  
  63.                 label=''
  64.                 if [ -f $id/label ]; then
  65.                     label=$(cat $id/label | \
  66.                         sed 's/\(................\).*/\1/g')
  67.                 fi
  68.                 # Ensure label is quoted correctly
  69.                 if log-output -t partman --pass-stdout \
  70.                    mkfs.reiserfs ${label:+-l "$label"} -f -q \
  71.                             $device >/dev/null; then
  72.                     sync
  73.                     status=OK
  74.                 else
  75.                     status=failed
  76.                 fi
  77.                 db_progress STOP
  78.             fi
  79.             if [ "$status" != OK ]; then
  80.                 db_subst partman-reiserfs/create_failed PARTITION "$num"
  81.                 db_subst partman-reiserfs/create_failed DEVICE $(humandev $(cat device))
  82.                 db_input critical partman-reiserfs/create_failed || true
  83.                 db_go || true
  84.                 #disable_swap
  85.                 exit 1
  86.             fi
  87.             >$id/formatted
  88.             ;;
  89.         esac
  90.     done
  91. done
  92.  
  93. #disable_swap
  94.