blob: ed6899c2e5853c09161889af1021c8f50801369d [file] [log] [blame]
#!/bin/bash
# Copyright 2018 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 already published packages to a device
## usage: fx push-package-no-publish [-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. This assumes the package has already been published.
##
## 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=""
device="$(get-device-addr $@)"
if [[ -n "$device" ]]; then
shift
shift
fi
# if the second arg is set, but 0-length, publish nothing
if [[ $# -eq 1 ]] && [[ -z "${1}" ]]; then
exit 0
fi
# pkgs is the last argument
local pkgs
if [[ $# -eq 0 ]]; then
pkgs=$("${FUCHSIA_DIR}/scripts/list-repo-targets.py" --repo "${FUCHSIA_BUILD_DIR}/amber-files/repository" | tr '\n' ' ')
else
pkgs="$@"
fi
# The target doesn't support expansions, and a local expansion makes a command
# too long to spawn, so sending a loop makes things work ok.
local cmd="
for c in $pkgs; do
amber_ctl get_up -n \"\${c}\";
manifest_path=\"/pkgfs/packages/\${c}/0/meta/module.json\";
if [ -s \"\$manifest_path\" ]; then
run module_package_indexer \"\${c}\" 0;
fi
done
"
if [[ -n "${device}" ]]; then
fx-command-run ssh "${device}" "${cmd}"
else
fx-command-run shell "${cmd}"
fi
}
main "$@"