142 compress=no
143 fi
144
145 [ -x $GZIP_CMD ] || compress=no
146
147 function cleanup
148 {
149 umount -f "$rdmnt32" 2>/dev/null
150 umount -f "$rdmnt64" 2>/dev/null
151 lofiadm -d "$rdfile32" 2>/dev/null
152 lofiadm -d "$rdfile64" 2>/dev/null
153 [ -n "$rddir" ] && rm -fr "$rddir" 2> /dev/null
154 [ -n "$new_rddir" ] && rm -fr "$new_rddir" 2>/dev/null
155 }
156
157 function getsize
158 {
159 # Estimate image size and add 10% overhead for ufs stuff.
160 # Note, we can't use du here in case we're on a filesystem, e.g. zfs,
161 # in which the disk usage is less than the sum of the file sizes.
162 # The nawk code
163 #
164 # {t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
165 #
166 # below rounds up the size of a file/directory, in bytes, to the
167 # next multiple of 1024. This mimics the behavior of ufs especially
168 # with directories. This results in a total size that's slightly
169 # bigger than if du was called on a ufs directory.
170 size32=$(cat "$list32" | xargs -I {} ls -lLd "{}" 2> /dev/null |
171 nawk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
172 END {print int(t * 1.10 / 1024)}')
173 (( size32 += dirsize32 ))
174 size64=$(cat "$list64" | xargs -I {} ls -lLd "{}" 2> /dev/null |
175 nawk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
176 END {print int(t * 1.10 / 1024)}')
177 (( size64 += dirsize64 ))
178 (( total_size = size32 + size64 ))
179
180 if [ $compress = yes ] ; then
181 total_size=`echo $total_size | nawk '{print int($1 / 2)}'`
182 fi
183 }
184
185 #
186 # Copies all desired files to a target directory. One argument should be
187 # passed: the file containing the list of files to copy. This function also
188 # depends on several variables that must be set before calling:
189 #
190 # $ALT_ROOT - the target directory
191 # $compress - whether or not the files in the archives should be compressed
192 # $rdmnt - the target directory
193 #
194 function copy_files
195 {
196 list="$1"
197
198 #
199 # If compress is set, the files are gzip'd and put in the correct
200 # location in the loop. Nothing is printed, so the pipe and cpio
201 # at the end is a nop.
378 fi
379 rm -f "$errlog"
380 }
381
382 function create_archive
383 {
384 which=$1
385 archive=$2
386 lofidev=$3
387
388 echo "updating $archive"
389
390 if [ "$format" = "ufs" ]; then
391 create_ufs "$which" "$archive" "$lofidev"
392 else
393 create_isofs "$which" "$archive"
394 fi
395
396 # sanity check the archive before moving it into place
397 #
398 ARCHIVE_SIZE=`ls -l "${archive}-new" 2> /dev/null | nawk '{ print $5 }'`
399 if [ $compress = yes ] || [ $ISA = sparc ] ; then
400 #
401 # 'file' will report "English text" for uncompressed
402 # boot_archives. Checking for that doesn't seem stable,
403 # so we just check that the file exists.
404 #
405 ls "${archive}-new" >/dev/null 2>&1
406 else
407 #
408 # the file type check also establishes that the
409 # file exists at all
410 #
411 LC_MESSAGES=C file "${archive}-new" | grep gzip > /dev/null
412 fi
413
414 if [ $? = 1 ] && [ -x $GZIP_CMD ] || [ "$ARCHIVE_SIZE" -lt 10000 ]
415 then
416 #
417 # Two of these functions may be run in parallel. We
418 # need to allow the other to clean up, so we can't
460 # Clean up upon exit.
461 trap 'cleanup' EXIT
462
463 list32="$rddir/filelist.32"
464 list64="$rddir/filelist.64"
465
466 touch $list32 $list64
467
468 #
469 # This loop creates the 32-bit and 64-bit lists of files. The 32-bit list
470 # is written to stdout, which is redirected at the end of the loop. The
471 # 64-bit list is appended with each write.
472 #
473 cd "/$ALT_ROOT"
474 find $filelist -print 2>/dev/null | while read path
475 do
476 if [ $SPLIT = no ]; then
477 print "$path"
478 elif [ -d "$path" ]; then
479 if [ $format = ufs ]; then
480 size=`ls -lLd "$path" | nawk '
481 {print ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}'`
482 if [ `basename "$path"` != "amd64" ]; then
483 (( dirsize32 += size ))
484 fi
485 (( dirsize64 += size ))
486 fi
487 else
488 case `LC_MESSAGES=C /usr/bin/file -m /dev/null "$path" 2>/dev/null` in
489 *ELF\ 64-bit*)
490 print "$path" >> "$list64"
491 ;;
492 *ELF\ 32-bit*)
493 print "$path"
494 ;;
495 *)
496 # put in both lists
497 print "$path"
498 print "$path" >> "$list64"
499 esac
500 fi
|
142 compress=no
143 fi
144
145 [ -x $GZIP_CMD ] || compress=no
146
147 function cleanup
148 {
149 umount -f "$rdmnt32" 2>/dev/null
150 umount -f "$rdmnt64" 2>/dev/null
151 lofiadm -d "$rdfile32" 2>/dev/null
152 lofiadm -d "$rdfile64" 2>/dev/null
153 [ -n "$rddir" ] && rm -fr "$rddir" 2> /dev/null
154 [ -n "$new_rddir" ] && rm -fr "$new_rddir" 2>/dev/null
155 }
156
157 function getsize
158 {
159 # Estimate image size and add 10% overhead for ufs stuff.
160 # Note, we can't use du here in case we're on a filesystem, e.g. zfs,
161 # in which the disk usage is less than the sum of the file sizes.
162 # The awk code
163 #
164 # {t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
165 #
166 # below rounds up the size of a file/directory, in bytes, to the
167 # next multiple of 1024. This mimics the behavior of ufs especially
168 # with directories. This results in a total size that's slightly
169 # bigger than if du was called on a ufs directory.
170 size32=$(cat "$list32" | xargs -I {} ls -lLd "{}" 2> /dev/null |
171 /usr/xpg4/bin/awk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
172 END {print int(t * 1.10 / 1024)}')
173 (( size32 += dirsize32 ))
174 size64=$(cat "$list64" | xargs -I {} ls -lLd "{}" 2> /dev/null |
175 /usr/xpg4/bin/awk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}
176 END {print int(t * 1.10 / 1024)}')
177 (( size64 += dirsize64 ))
178 (( total_size = size32 + size64 ))
179
180 if [ $compress = yes ] ; then
181 total_size=`echo $total_size | /usr/xpg4/bin/awk '{print int($1 / 2)}'`
182 fi
183 }
184
185 #
186 # Copies all desired files to a target directory. One argument should be
187 # passed: the file containing the list of files to copy. This function also
188 # depends on several variables that must be set before calling:
189 #
190 # $ALT_ROOT - the target directory
191 # $compress - whether or not the files in the archives should be compressed
192 # $rdmnt - the target directory
193 #
194 function copy_files
195 {
196 list="$1"
197
198 #
199 # If compress is set, the files are gzip'd and put in the correct
200 # location in the loop. Nothing is printed, so the pipe and cpio
201 # at the end is a nop.
378 fi
379 rm -f "$errlog"
380 }
381
382 function create_archive
383 {
384 which=$1
385 archive=$2
386 lofidev=$3
387
388 echo "updating $archive"
389
390 if [ "$format" = "ufs" ]; then
391 create_ufs "$which" "$archive" "$lofidev"
392 else
393 create_isofs "$which" "$archive"
394 fi
395
396 # sanity check the archive before moving it into place
397 #
398 ARCHIVE_SIZE=`ls -l "${archive}-new" 2> /dev/null | /usr/xpg4/bin/awk '{ print $5 }'`
399 if [ $compress = yes ] || [ $ISA = sparc ] ; then
400 #
401 # 'file' will report "English text" for uncompressed
402 # boot_archives. Checking for that doesn't seem stable,
403 # so we just check that the file exists.
404 #
405 ls "${archive}-new" >/dev/null 2>&1
406 else
407 #
408 # the file type check also establishes that the
409 # file exists at all
410 #
411 LC_MESSAGES=C file "${archive}-new" | grep gzip > /dev/null
412 fi
413
414 if [ $? = 1 ] && [ -x $GZIP_CMD ] || [ "$ARCHIVE_SIZE" -lt 10000 ]
415 then
416 #
417 # Two of these functions may be run in parallel. We
418 # need to allow the other to clean up, so we can't
460 # Clean up upon exit.
461 trap 'cleanup' EXIT
462
463 list32="$rddir/filelist.32"
464 list64="$rddir/filelist.64"
465
466 touch $list32 $list64
467
468 #
469 # This loop creates the 32-bit and 64-bit lists of files. The 32-bit list
470 # is written to stdout, which is redirected at the end of the loop. The
471 # 64-bit list is appended with each write.
472 #
473 cd "/$ALT_ROOT"
474 find $filelist -print 2>/dev/null | while read path
475 do
476 if [ $SPLIT = no ]; then
477 print "$path"
478 elif [ -d "$path" ]; then
479 if [ $format = ufs ]; then
480 size=`ls -lLd "$path" | /usr/xpg4/bin/awk '
481 {print ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}'`
482 if [ `basename "$path"` != "amd64" ]; then
483 (( dirsize32 += size ))
484 fi
485 (( dirsize64 += size ))
486 fi
487 else
488 case `LC_MESSAGES=C /usr/bin/file -m /dev/null "$path" 2>/dev/null` in
489 *ELF\ 64-bit*)
490 print "$path" >> "$list64"
491 ;;
492 *ELF\ 32-bit*)
493 print "$path"
494 ;;
495 *)
496 # put in both lists
497 print "$path"
498 print "$path" >> "$list64"
499 esac
500 fi
|