Print this page
XXX Remove nawk(1)


 189         rm /tmp/system.$$
 190 
 191         echo set root_is_ramdisk=1 >> "$UNPACKED_ROOT"/etc/system
 192         echo set ramdisk_size=$1 >> "$UNPACKED_ROOT"/etc/system
 193 }
 194 
 195 pack()
 196 {
 197         MR="$1"
 198         [ -d "$UNPACKED_ROOT" ] || usage
 199 
 200         # always compress if fiocompress exists
 201         #
 202         if [ -x /usr/sbin/fiocompress ] ; then
 203                 COMPRESS=true
 204         fi
 205 
 206         # Estimate image size and add %10 overhead for ufs stuff.
 207         # Note, we can't use du here in case $UNPACKED_ROOT is on a filesystem,
 208         # e.g. zfs, in which the disk usage is less than the sum of the file
 209         # sizes.  The nawk code
 210         #
 211         #       {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
 212         #
 213         # below rounds up the size of a file/directory, in bytes, to the
 214         # next multiple of 1024.  This mimics the behavior of ufs especially
 215         # with directories.  This results in a total size that's slightly
 216         # bigger than if du was called on a ufs directory.
 217         #
 218         # if the operation in turn is compressing the files the amount
 219         # of typical shrinkage is used to come up with a useful archive
 220         # size
 221         size=$(find "$UNPACKED_ROOT" -ls | nawk '
 222             {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
 223             END {print int(t * 1.10 / 1024)}')
 224         if [ "$COMPRESS" = true ] ; then
 225                 size=`echo $size | nawk '{s = $1} END {print int(s * 0.6)}'`
 226         fi
 227 
 228         /usr/sbin/mkfile ${size}k "$TMR"
 229 
 230         LOFIDEV=`/usr/sbin/lofiadm -a "$TMR"`
 231         if [ $? != 0 ] ; then
 232                 echo lofi plumb failed
 233                 exit 2
 234         fi
 235 
 236         RLOFIDEV=`echo $LOFIDEV | sed s/lofi/rlofi/`
 237         newfs $RLOFIDEV < /dev/null 2> /dev/null
 238         mkdir -p $MNT
 239         mount -o nologging $LOFIDEV $MNT
 240         rmdir $MNT/lost+found
 241 
 242         if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then
 243                 root_is_ramdisk $size
 244         fi
 245 




 189         rm /tmp/system.$$
 190 
 191         echo set root_is_ramdisk=1 >> "$UNPACKED_ROOT"/etc/system
 192         echo set ramdisk_size=$1 >> "$UNPACKED_ROOT"/etc/system
 193 }
 194 
 195 pack()
 196 {
 197         MR="$1"
 198         [ -d "$UNPACKED_ROOT" ] || usage
 199 
 200         # always compress if fiocompress exists
 201         #
 202         if [ -x /usr/sbin/fiocompress ] ; then
 203                 COMPRESS=true
 204         fi
 205 
 206         # Estimate image size and add %10 overhead for ufs stuff.
 207         # Note, we can't use du here in case $UNPACKED_ROOT is on a filesystem,
 208         # e.g. zfs, in which the disk usage is less than the sum of the file
 209         # sizes.  The awk code
 210         #
 211         #       {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
 212         #
 213         # below rounds up the size of a file/directory, in bytes, to the
 214         # next multiple of 1024.  This mimics the behavior of ufs especially
 215         # with directories.  This results in a total size that's slightly
 216         # bigger than if du was called on a ufs directory.
 217         #
 218         # if the operation in turn is compressing the files the amount
 219         # of typical shrinkage is used to come up with a useful archive
 220         # size
 221         size=$(find "$UNPACKED_ROOT" -ls | /usr/xpg4/bin/awk '
 222             {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
 223             END {print int(t * 1.10 / 1024)}')
 224         if [ "$COMPRESS" = true ] ; then
 225                 size=`echo $size | /usr/xpg4/bin/awk '{s = $1} END {print int(s * 0.6)}'`
 226         fi
 227 
 228         /usr/sbin/mkfile ${size}k "$TMR"
 229 
 230         LOFIDEV=`/usr/sbin/lofiadm -a "$TMR"`
 231         if [ $? != 0 ] ; then
 232                 echo lofi plumb failed
 233                 exit 2
 234         fi
 235 
 236         RLOFIDEV=`echo $LOFIDEV | sed s/lofi/rlofi/`
 237         newfs $RLOFIDEV < /dev/null 2> /dev/null
 238         mkdir -p $MNT
 239         mount -o nologging $LOFIDEV $MNT
 240         rmdir $MNT/lost+found
 241 
 242         if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then
 243                 root_is_ramdisk $size
 244         fi
 245