outfile=$1; shift
-if [ -z "$outfile" ]; then
+if [[ -z $outfile ]]; then
derror "No output file specified."
usage
exit 1
baseimage=$1; shift
-if [ -z "$baseimage" ]; then
+if [[ -z $baseimage ]]; then
derror "No base image specified."
usage
exit 1
fi
-if [ -f $outfile -a -z "$force" ]; then
+if [[ -f $outfile && ! $force ]]; then
derror "Will not override existing initramfs ($outfile) without --force"
exit 1
fi
-if [ -z "$no_imagedir" -a ! -d "$imagedir" ]; then
+if [[ ! $no_imagedir && ! -d $imagedir ]]; then
derror "Image directory $overlay is not a directory"
exit 1
fi
-if [ -z "$no_overlay" -a ! -d "$overlay" ]; then
+if [[ ! $no_overlay && ! -d $overlay ]]; then
derror "Overlay $overlay is not a directory"
exit 1
fi
-if [ -z "$no_overlay" ]; then
+if [[ ! $no_overlay ]]; then
ofile="$imagedir/90-overlay.img"
dinfo "Creating image $ofile from directory $overlay"
( cd "$overlay"; find . |cpio --quiet -H newc -o |gzip -9 > "$ofile"; )
fi
-if [ -z "$no_imagedir" ]; then
- images=$(for i in $imagedir/*.img;do [ -f $i ] || continue; echo $i; done)
+if [[ ! $no_imagedir ]]; then
+ for i in "$imagedir/"*.img; do
+ [[ -f $i ]] && images+=("$i")
+ done
fi
-images="$images $@"
+images+=($@)
dinfo "Using base image $baseimage"
-cat $baseimage > $outfile
+cat "$baseimage" > "$outfile"
-for i in $images; do
+for i in "${images[@]}"; do
dinfo "Appending $i"
- cat $i >> $outfile
+ cat "$i" >> "$outfile"
done
dinfo "Created $outfile"