Skip to content

Commit

Permalink
Support running run_flashy_remote.sh in release build
Browse files Browse the repository at this point in the history
Summary:
When we release a prebuilt flashy to OSS, we need to point to the right flashy binary, since we are no longer building flashy from the project root.

Add a new flag `path-to-flashy` that allows pointing to the release path of flashy.

In the github release, make sure we have the right folder structure

```
. flashy
|---scripts
     |--- run_flashy.sh
     |--- run_flashy_remote.sh
```

Test Plan:
# Running in release folder, path to flashy provided

```
release/scripts $ ./run_flashy_remote.sh --device mtd:flash0 --host fboss9310996-oob.snc1 --dry-run --imagepath ../flash-wedge40 --path-to-flashy ../flashy
Running in dry-run mode
Running a remote upgrade on 'fboss9310996-oob.snc1' with image '/data/users/linhaolee/openbmc/tools/flashy/release/flash-wedge40'
Continue (y/n)?y
path-to-flashy provided: /data/users/linhaolee/openbmc/tools/flashy/release/flashy
Making installation directories on OpenBMC...
Copying flashy...
Copying image...
Copying upgrade script...
Finished dry run
```

# Running in scripts folder, path to flashy not provided
```
openbmc/tools/flashy/scripts $ ./run_flashy_remote.sh --device mtd:flash0 --host fboss9310996-oob.snc1 --dry-run --imagepath ../release/flash-wedge40
Running in dry-run mode
Running a remote upgrade on 'fboss9310996-oob.snc1' with image '/data/users/linhaolee/openbmc/tools/flashy/release/flash-wedge40'
Continue (y/n)?y
path-to-flashy not provided, building flashy...
Making installation directories on OpenBMC...
Copying flashy...
Copying image...
Copying upgrade script...
Finished dry run
```

Reviewed By: deathowl

fbshipit-source-id: 27bcbaf8606864c2b768455ff2a9ee15e2dbfaa3
  • Loading branch information
lhl2617 authored and facebook-github-bot committed Jul 5, 2022
1 parent 577abe5 commit 5aec440
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/flashy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ jobs:
path: tools/flashy/build
- name: Prepare release folder
run: |
mkdir tools/flashy/release
mkdir tools/flashy/release tools/flashy/release/scripts
cp tools/flashy/build/flashy tools/flashy/release/flashy
cp tools/flashy/scripts/run_flashy.sh tools/flashy/release
cp tools/flashy/scripts/run_flashy*.sh tools/flashy/release/scripts
- name: Get short SHA
id: slug
run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"
Expand Down
36 changes: 28 additions & 8 deletions tools/flashy/scripts/run_flashy_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ set -eo pipefail
openbmc_image_path="/opt/upgrade/image"
# Path to Flashy on OpenBMC
openbmc_flashy_path="/opt/flashy/flashy"
# Path to run_flashy upgrade script from project root
# Path to run_flashy upgrade script from project root/release folder
run_flashy_script_path="scripts/run_flashy.sh"
# Path to flashy, empty means build from project root
path_to_flashy=""
# Dry run, skips running flashy
dry_run="false"

Expand All @@ -35,14 +37,20 @@ sshcmd=("${sshpassCmd[@]}" ssh "${options[@]}")

usage="Usage:
$(basename "$0") \
--device DEVICE_ID --imagepath IMAGE_PATH --host OPENBMC_HOSTNAME (--dry-run)
--device DEVICE_ID --imagepath IMAGE_PATH --host OPENBMC_HOSTNAME --path-to-flashy PATH_TO_FLASHY (--dry_run)
Run this script to upgrade a remote OpenBMC.
Example DEVICE_ID: \"mtd:flash0\"
Supply --dry_run to only run the initialize step (does not actually run
flashy on the device, but copies over required files.)
Supply --dry_run to only run the initialize step (does not actually run flashy on the device,
but copies over required files.)
If --path-to-flashy is supplied, it is assumed that flashy is already built--this is true if you
are using the prebuilt released flashy.
Otherwise, please run this script in the repository checkout and let the script build
flashy. Go >= 1.14 must be available on your system.
"

scpfile() {
Expand All @@ -60,14 +68,20 @@ scpfile() {
}

initialize() {
echo "Building flashy..." >&2
./build.sh
if [[ -z "$path_to_flashy" ]]
then
echo "path-to-flashy not provided, building flashy..." >&2
./build.sh
path_to_flashy="$(realpath "./build/flashy")"
else
printf "path-to-flashy provided: %s\n" "$path_to_flashy" >&2
fi

echo "Making installation directories on OpenBMC..." >&2
"${sshcmd[@]}" "mkdir -p /opt/flashy /opt/upgrade"

echo "Copying flashy..." >&2
scpfile ./build/flashy "$openbmc_flashy_path"
scpfile "$path_to_flashy" "$openbmc_flashy_path"

echo "Copying image..." >&2
scpfile "$imagepath" "$openbmc_image_path"
Expand Down Expand Up @@ -148,6 +162,12 @@ case $key in
shift
shift
;;
--path-to-flashy)
check_second_argument_supplied "$@"
path_to_flashy="$(realpath "$2")"
shift
shift
;;
--dry-run)
dry_run="true"
shift
Expand All @@ -171,7 +191,7 @@ confirm_continue() {
esac
}

# make sure we're in flashy's project root
# make sure we're in flashy's project/release root
cd "$(dirname "$0")" && cd ..

if [[ "$dry_run" == "true" ]]
Expand Down

0 comments on commit 5aec440

Please sign in to comment.