generate-psu-tar: Add machine name and remove single "-" options
Remove single "-" options because there are too many similar options.
The openbmc image manager expects "MachineName" in MANIFEST that matches
the BMC's OPENBMC_TARGET_MACHINE in /etc/os-release.
* If there is no MachineName in MANIFEST, it logs a warning for now;
* If they do not match, an error is reported and the version is deleted.
Add --machineName argument for generate-psu-tar to make it support the
"MachineName".
Tested: Verify that when a correct machine name is given, the tarball is
processed by image manager correctly;
And if an invalid machine name is given, the tarball uploaded
will get "Machine name doesn't match" error and is deleted.
Signed-off-by: Chicago Duan <duanzhijia01@inspur.com>
Change-Id: Ie39e01ae7e4a48fade3459a7eb82da214e0400e9
diff --git a/README.md b/README.md
index e6378bf..6221433 100644
--- a/README.md
+++ b/README.md
@@ -133,8 +133,8 @@
1. Generate a tarball of PSU firmware image by [generate-psu-tar tool][4].
```
- ./generate-psu-tar -i <psu-image> -v <version> -model <model> -mf \
- <manufacture> -o <psu.tar> -s
+ ./generate-psu-tar --image <psu-image> --version <version> --model <model> --manufacture \
+ <manufacture> --machineName <machineName> --outfile <psu.tar> --sign
```
2. To update the PSU firmware, follow the same steps as described in
[code-update.md][5]:
diff --git a/tools/generate-psu-tar b/tools/generate-psu-tar
index 83bc020..5bbc60c 100755
--- a/tools/generate-psu-tar
+++ b/tools/generate-psu-tar
@@ -4,19 +4,20 @@
help=$'Generate Tarball with PSU image and MANIFEST Script
usage: generate-psu-tar [OPTION] <parameter>...
Options:
- -i, --image <file> PSU FW image
- -v, --version <version> PSU FW version
- -model, --model <model> PSU FW model
- -mf, --manufacture <version> PSU FW manufacture
- -o, --outfile <filename> Outfile name
- For example : -o psufw.tar
- The default outfile name is image.tar,and
- "image" is what you input.
- -s, --sign <path> Sign the image. The optional path argument specifies
- the private key file. Defaults to the bash variable
- PRIVATE_KEY_PATH if available, or else uses the
- open-source private key in this script.
- -h, --help Display this help text and exit.
+ --image <file> PSU FW image
+ --version <version> PSU FW version
+ --model <model> PSU FW model
+ --manufacture <version> PSU FW manufacture
+ --machineName <machineName> Optionally specify the target machine name of this image.
+ --outfile <filename> Outfile name
+ For example : -o psufw.tar
+ The default outfile name is image.tar,and
+ "image" is what you input.
+ --sign <path> Sign the image. The optional path argument specifies
+ the private key file. Defaults to the bash variable
+ PRIVATE_KEY_PATH if available, or else uses the
+ open-source private key in this script.
+ --help Display this help text and exit.
'
private_key=$'-----BEGIN PRIVATE KEY-----
@@ -44,33 +45,38 @@
version=""
model=""
manufacture=""
+machineName=""
declare -a partitions=()
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
- -i|--image)
+ --image)
image="$2"
shift 2
;;
- -v|--version)
+ --version)
version="$2"
shift 2
;;
- -model|--model)
+ --model)
model="$2"
shift 2
;;
- -mf|--manufacture)
+ --manufacture)
manufacture="$2"
shift 2
;;
- -o|--outfile)
+ --machineName)
+ machineName="$2"
+ shift 2
+ ;;
+ --outfile)
outfile="$2"
shift 2
;;
- -s|--sign)
+ --sign)
do_sign=true
if [[ ! -z "${2}" && "${2}" != -* ]]; then
private_key_path="$2"
@@ -79,7 +85,7 @@
shift 1
fi
;;
- -h|--help)
+ --help)
echo "$help"
exit
;;
@@ -157,6 +163,10 @@
echo -e "purpose=xyz.openbmc_project.Software.Version.VersionPurpose.PSU\nversion=$version\n\
extended_version=model=$model,manufacture=$manufacture" > $manifest_location
+if [[ ! -z "${machineName}" ]]; then
+ echo -e "MachineName=${machineName}" >> $manifest_location
+fi
+
if [[ "${do_sign}" == true ]]; then
private_key_name=$(basename "${private_key_path}")
key_type="${private_key_name%.*}"