blob: 4ce183079703c5e9c9698314e498896b36c2bb8d [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
#### DEPRECATED
### push packages to a device
## usage: fx push-package [pkg1 pkg2 ...]
##
## Deprecated: This command is deprecated as it is misleading. Packages in
## Fuchsia are only cached, not installed, and the cache is updated on-demand
## when a component is launched from a fuchsia package URL. An attempt to "push"
## a package as implemented here only performs one of these resolutions, and may
## or may not influence what happens "next" if a user "runs" a component url. As
## such this command influences a poor mental model of the system and should be
## avoided.
##
## 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
fx-warn "fx push-package is deprecated and should not be used"
fx-warn "The notion of 'push' is falsified in this implementation and does not really exist."
fx-warn "Users can simply 'fx run <component-url>' in order to affect cache updates."
sleep 5
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 "$@"