| #!/bin/bash |
| # Copyright 2017 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| ### push packages to a device |
| |
| ## usage: fx push-package [-d|--device <device_address>] [pkg1 pkg2 ...] |
| ## |
| ## Push packages to a device. One or more package names may be supplied. If no |
| ## package name is suppled all packages in the build output will be pushed. The |
| ## target must be reachable from the host and most already know the host's IP |
| ## address. |
| ## |
| ## See https://fuchsia.googlesource.com/docs/+/master/development/workflows/package_update.md |
| ## for more information about using this workflow. |
| ## |
| ## optional arguments (must be first): |
| ## -d|--device IP address of the target |
| |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/lib/vars.sh |
| fx-config-read |
| |
| function usage { |
| fx-command-help push-package |
| } |
| |
| function main { |
| fx-standard-switches "$@" |
| set -- "${FX_ARGV[@]}" |
| |
| local device="" |
| local device_args=() |
| device="$(get-device-addr $@)" |
| |
| if [[ -n "$device" ]]; then |
| shift |
| device_args=("-d" "$1") |
| shift |
| fi |
| |
| # if the second arg is set, but 0-length, publish nothing |
| if [[ $# -eq 1 ]] && [[ -z "${1}" ]]; then |
| exit 0 |
| fi |
| |
| fx-command-run publish "$@" |
| |
| fx-command-run push-package-no-publish "${device_args[@]}" "$@" |
| } |
| |
| main "$@" |