mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
netboot: Format mk-s390image
Command line used: $ shfmt --space-redirects --case-indent --simplify --func-next-line --write mk-s390image Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
339b69cf3b
commit
76b7928592
@@ -38,12 +38,10 @@ success=no
|
|||||||
# shellcheck disable=SC2317
|
# shellcheck disable=SC2317
|
||||||
cleanup()
|
cleanup()
|
||||||
{
|
{
|
||||||
if [ -n "$binval" ]
|
if [ -n "$binval" ]; then
|
||||||
then
|
|
||||||
rm -f -- "$binval"
|
rm -f -- "$binval"
|
||||||
fi
|
fi
|
||||||
if [ -n "$image" ] && [ "$success" = no ]
|
if [ -n "$image" ] && [ "$success" = no ]; then
|
||||||
then
|
|
||||||
rm -f -- "$image"
|
rm -f -- "$image"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -52,25 +50,25 @@ trap cleanup EXIT
|
|||||||
# Usage
|
# Usage
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
cat <<-EOF
|
cat <<- EOF
|
||||||
Usage: $cmd KERNEL BOOT_IMAGE [-r RAMDISK] [-p PARMFILE]
|
Usage: $cmd KERNEL BOOT_IMAGE [-r RAMDISK] [-p PARMFILE]
|
||||||
|
|
||||||
Build an s390 image BOOT_IMAGE suitable for CD/tape/network boot or as a
|
Build an s390 image BOOT_IMAGE suitable for CD/tape/network boot or as a
|
||||||
KVM firmware image using a stripped Linux kernel file KERNEL.
|
KVM firmware image using a stripped Linux kernel file KERNEL.
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-p Use PARMFILE with kernel parameters in the image
|
-p Use PARMFILE with kernel parameters in the image
|
||||||
-r Include RAMDISK in the image
|
-r Include RAMDISK in the image
|
||||||
-h Print this help, then exit
|
-h Print this help, then exit
|
||||||
-v Print version information, then exit
|
-v Print version information, then exit
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
printversion()
|
printversion()
|
||||||
{
|
{
|
||||||
cat <<-EOD
|
cat <<- EOD
|
||||||
$cmd: version %S390_TOOLS_VERSION%
|
$cmd: version %S390_TOOLS_VERSION%
|
||||||
Copyright IBM Corp. 2017
|
Copyright IBM Corp. 2017
|
||||||
EOD
|
EOD
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,8 +78,7 @@ dec2be64()
|
|||||||
local num=$1
|
local num=$1
|
||||||
local b
|
local b
|
||||||
local i
|
local i
|
||||||
for i in $(seq 1 8)
|
for i in $(seq 1 8); do
|
||||||
do
|
|
||||||
b="\\x$(printf '%x' "$((num % 256))")$b"
|
b="\\x$(printf '%x' "$((num % 256))")$b"
|
||||||
num=$((num / 256)) || true
|
num=$((num / 256)) || true
|
||||||
done
|
done
|
||||||
@@ -116,21 +113,17 @@ dobuild()
|
|||||||
local ramdisk_offset
|
local ramdisk_offset
|
||||||
local parmfile_size
|
local parmfile_size
|
||||||
# check whether all specified files exist
|
# check whether all specified files exist
|
||||||
for i in $kernel $ramdisk $parmfile
|
for i in $kernel $ramdisk $parmfile; do
|
||||||
do
|
if [ ! -f "$i" ]; then
|
||||||
if [ ! -f "$i" ]
|
echo "$cmd: File $i not found" >&2
|
||||||
then
|
return 1
|
||||||
echo "$cmd: File $i not found" >&2
|
fi
|
||||||
return 1
|
if [ ! -r "$i" ]; then
|
||||||
fi
|
echo "$cmd: File $i cannot be read, no read permission" >&2
|
||||||
if [ ! -r "$i" ]
|
return 1
|
||||||
then
|
fi
|
||||||
echo "$cmd: File $i cannot be read, no read permission" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
if ! file -b -- "$(readlink -f -- "$kernel")" | grep "Linux S390" > /dev/null
|
if ! file -b -- "$(readlink -f -- "$kernel")" | grep "Linux S390" > /dev/null; then
|
||||||
then
|
|
||||||
echo "$cmd: Unrecognized file format for $kernel" >&2
|
echo "$cmd: Unrecognized file format for $kernel" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -143,8 +136,7 @@ dobuild()
|
|||||||
dd if="$kernel" of="$image" bs=4096 conv=sync status=none
|
dd if="$kernel" of="$image" bs=4096 conv=sync status=none
|
||||||
|
|
||||||
# append ramdisk if specified
|
# append ramdisk if specified
|
||||||
if [ "$ramdisk" != "" ]
|
if [ "$ramdisk" != "" ]; then
|
||||||
then
|
|
||||||
ramdisk_size=$(du -b -L -- "$ramdisk" | cut -f1)
|
ramdisk_size=$(du -b -L -- "$ramdisk" | cut -f1)
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
kernel_size=$(du -b -L -- "$kernel" | cut -f1)
|
kernel_size=$(du -b -L -- "$kernel" | cut -f1)
|
||||||
@@ -160,17 +152,15 @@ dobuild()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# set cmdline
|
# set cmdline
|
||||||
if [ "$parmfile" != "" ]
|
if [ "$parmfile" != "" ]; then
|
||||||
then
|
|
||||||
max_parmfile_size=$(max_kernel_cmdline_size "$kernel")
|
max_parmfile_size=$(max_kernel_cmdline_size "$kernel")
|
||||||
parmfile_size=$(du -b -L -- "$parmfile" | cut -f1)
|
parmfile_size=$(du -b -L -- "$parmfile" | cut -f1)
|
||||||
if (( parmfile_size <= max_parmfile_size ));
|
if ((parmfile_size <= max_parmfile_size)); then
|
||||||
then
|
|
||||||
# Clear any previous parameters
|
# Clear any previous parameters
|
||||||
dd seek=$OFFS_COMMANDLINE_BYTES bs=1 count="$max_parmfile_size" \
|
dd seek=$OFFS_COMMANDLINE_BYTES bs=1 count="$max_parmfile_size" \
|
||||||
if=/dev/zero of="$image" conv=notrunc status=none
|
if=/dev/zero of="$image" conv=notrunc status=none
|
||||||
dd seek=$OFFS_COMMANDLINE_BYTES bs=1 count="$parmfile_size" \
|
dd seek=$OFFS_COMMANDLINE_BYTES bs=1 count="$parmfile_size" \
|
||||||
if="$parmfile" of="$image" conv=notrunc status=none
|
if="$parmfile" of="$image" conv=notrunc status=none
|
||||||
else
|
else
|
||||||
echo "$cmd: Size $parmfile_size of $parmfile exceeds command line limit of $max_parmfile_size bytes" >&2
|
echo "$cmd: Size $parmfile_size of $parmfile exceeds command line limit of $max_parmfile_size bytes" >&2
|
||||||
return 1
|
return 1
|
||||||
@@ -183,25 +173,40 @@ dobuild()
|
|||||||
|
|
||||||
# check args and build
|
# check args and build
|
||||||
# shellcheck disable=SC2086,SC2048
|
# shellcheck disable=SC2086,SC2048
|
||||||
if args=$(getopt "r:p:hv" $*)
|
if args=$(getopt "r:p:hv" $*); then
|
||||||
then
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
set -- $args
|
set -- $args
|
||||||
while [ "$1" != "" ]
|
while [ "$1" != "" ]; do
|
||||||
do
|
|
||||||
case $1 in
|
case $1 in
|
||||||
-r) ramdisk=$2; shift 2;;
|
-r)
|
||||||
-p) parmfile=$2; shift 2;;
|
ramdisk=$2
|
||||||
-h) usage; exit 0;;
|
shift 2
|
||||||
-v) printversion; exit 0;;
|
;;
|
||||||
--) shift; break;;
|
-p)
|
||||||
*) echo "$cmd: Unexpected argument $1, exiting..." >&2; exit 1;;
|
parmfile=$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-v)
|
||||||
|
printversion
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$cmd: Unexpected argument $1, exiting..." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# = 2 ]
|
if [ $# = 2 ]; then
|
||||||
then
|
|
||||||
kernel=$1
|
kernel=$1
|
||||||
image=$2
|
image=$2
|
||||||
dobuild
|
dobuild
|
||||||
|
|||||||
Reference in New Issue
Block a user