blob: fe01cdb2c11d990cdeb8a7f4b9091246d8cc609d [file] [log] [blame]
#!/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.
#### CATEGORY=Software delivery
### push packages to a device
## usage: fx push-package [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 must already know how to reach
## the host package server (i.e. fx serve must be running).
##
## See https://fuchsia.dev/fuchsia-src/development/workflows/package_update
## for more information about using this workflow.
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $?
fx-config-read
function main {
fx-standard-switches "$@"
set -- "${FX_ARGV[@]}"
# if the second arg is set, but 0-length, publish nothing
if [[ $# -eq 1 ]] && [[ -z "${1}" ]]; then
exit 0
fi
local all_pkgs=($(fx-command-run list-packages))
# pkgs is the last argument
local pkgs=()
if [[ $# -eq 0 ]]; then
fx-warn "Pushing ${#all_pkgs[@]} packages, this may take some time..."
pkgs=("${all_pkgs[@]}")
else
for pkg in "$@"; do
for p in "${all_pkgs[@]}"; do
if [[ "$p" == "$pkg" ]]; then
pkgs+=("$p")
continue 2
fi
done
fx-error "Package $pkg is not known to the current build configuration."
fx-error "Check \`fx list-packages\` for the correct name,"
fx-error "or adjust the build configuration with \`fx set\`."
exit 1
done
fi
for pkg in "${pkgs[@]}"; do
if ! fx-command-run shell pkgctl resolve "fuchsia-pkg://fuchsia.com/${pkg}"; then
r=$?
fx-error "Push of $pkg failed"
return $r
fi
done
}
main "$@"