home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / lib / partman / commit.d / 50format_basicfilesystems < prev    next >
Encoding:
Text File  |  2006-08-30  |  3.0 KB  |  120 lines

  1. #!/bin/sh
  2.  
  3. . /lib/partman/definitions.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.         ext2|fat16|fat32)
  26.         if 
  27.             [ -f $id/formatted -a $id/formatted -nt $id/method ] \
  28.             && [ ! -f $id/filesystem \
  29.                  -o $id/formatted -nt $id/filesystem ]
  30.         then
  31.             continue
  32.         fi
  33.         log "Try to create file system for $dev/$id"
  34.         if [ -f $id/mountpoint ]; then
  35.             template=partman-basicfilesystems/progress_formatting_mountable
  36.             db_subst $template MOUNT_POINT "$(cat $id/mountpoint)"
  37.         else
  38.             template=partman-basicfilesystems/progress_formatting
  39.         fi
  40.         open_dialog PARTITION_INFO $id
  41.         read_line x1 x2 x3 x4 x5 device x6
  42.         close_dialog
  43.  
  44.         RET=''
  45.         db_metaget  partman/filesystem_short/"$filesystem" description || RET=''
  46.         [ "$RET" ] || RET="$filesystem"
  47.         db_subst $template TYPE "$RET"
  48.         db_subst $template PARTITION "$num"
  49.         db_subst $template DEVICE $(humandev $(cat device))
  50.         case $filesystem in
  51.             ext2)
  52.             if [ ! -f $id/usage ]; then
  53.                 name_progress_bar $template
  54.                 open_dialog CREATE_FILE_SYSTEM $id $filesystem
  55.                 read_line status
  56.                 close_dialog
  57.                 sync
  58.             else
  59.                 status=failed
  60.             fi
  61.             if [ "$status" != OK ]; then
  62.                 db_progress START 0 3 partman/text/formatting
  63.                 db_progress INFO $template
  64.                 db_progress SET 1
  65.                 if [ -f $id/usage ]; then
  66.                 usage="-T $(cat $id/usage)"
  67.                 else
  68.                 usage=''
  69.                 fi
  70.                 if
  71.                 log-output -t partman --pass-stdout mkfs.ext2 $device $usage >/dev/null
  72.                 then
  73.                 sync
  74.                 status=OK
  75.                 else
  76.                 status=failed
  77.                 fi
  78.                 db_progress STOP
  79.             fi
  80.             if [ "$status" = OK ]; then
  81.                 if [ -f $id/label ]; then
  82.                 label=$(cat $id/label|
  83.                     sed 's/\(................\).*/\1/g')
  84.                 else
  85.                 label=''
  86.                 fi
  87.                 if [ "$label" ]; then
  88.                 log-output -t partman --pass-stdout tune2fs -L "$label" $device >/dev/null
  89.                 fi
  90.                 if [ -f $id/reserved_for_root ]; then
  91.                 log-output -t partman --pass-stdout tune2fs -m $(cat $id/reserved_for_root) $device >/dev/null
  92.                 fi
  93.             fi
  94.             ;;
  95.             fat16|fat32)
  96.             name_progress_bar $template
  97.             open_dialog CREATE_FILE_SYSTEM $id $filesystem
  98.             read_line status
  99.             close_dialog
  100.             sync
  101.             ;;
  102.         esac
  103.  
  104.         if [ "$status" != OK ]; then
  105.             db_subst partman-basicfilesystems/create_failed TYPE "$filesystem"
  106.             db_subst partman-basicfilesystems/create_failed PARTITION "$num"
  107.             db_subst partman-basicfilesystems/create_failed DEVICE $(humandev $(cat device))
  108.             db_input critical partman-basicfilesystems/create_failed || true
  109.             db_go || true
  110.             #disable_swap
  111.             exit 1
  112.         fi
  113.         >$id/formatted
  114.         ;;
  115.     esac
  116.     done
  117. done
  118.  
  119. #disable_swap
  120.