Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
androdeb: add push command
Browse files Browse the repository at this point in the history
Similar to the previously added 'pull' command, this one adds a
shorthand to copy files to the device

Signed-off-by: Erick Reyes <[email protected]>
  • Loading branch information
ErickReyesR committed Jun 28, 2018
1 parent e25caea commit 5104a6c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
34 changes: 30 additions & 4 deletions androdeb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ case $key in
remove) REMOVE=1; shift || true; ;;
git-pull) GIT_PULL=1; shift || true; ;;
pull) PULL=1; shift || true; break ;;
push) PUSH=1; shift || true; break ;;
--arch) ARCH=$2; shift || true; shift || true; ;;
--archive) TARF=$2; shift || true; shift || true; ;;
--tracers) source $spath/packages/tracers; shift || true; ;;
Expand Down Expand Up @@ -62,16 +63,24 @@ if [ ! -z "$GIT_PULL" ]; then
exit 0
fi

# Helper function to count number of source arguments in a list
# when more than one argument is supplied, it is assumed the last argument
# is a destination
function count_sources() {
local source_count=$#
if [ $source_count -gt 1 ]; then
source_count=$((source_count - 1))
fi
echo "$source_count"
}

if [ ! -z "$PULL" ]; then
if [ $1 == "-a" ]; then
PRESERVE="-a"
echo "Preserving filestamps and mode"
shift || true
fi
file_count=$#
if [ $file_count -gt 1 ]; then
file_count=$((file_count - 1))
fi
file_count=`count_sources $@`
i=0
while [ $i -lt $file_count ]; do
files["$i"]=/data/androdeb/debian/$1
Expand All @@ -82,6 +91,23 @@ if [ ! -z "$PULL" ]; then
exit 0
fi

if [ ! -z "$PUSH" ]; then
if [ $1 == "--sync" ]; then
sync=$1
shift || true
fi
file_count=`count_sources $@`
i=0
while [ $i -lt $file_count ]; do
files["$i"]=$1
shift || true
i=$((i + 1))
done
dest=/data/androdeb/debian/$1
$ADB push $sync "${files[@]}" $dest
exit 0
fi

if [ -z "$ASHELL" ] && [ -z "$PACKAGES" ]; then
echo "No packages specified, so I'm going to build/install all packages (--fullbuild)"
config_full_build
Expand Down
3 changes: 2 additions & 1 deletion utils/banners
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ usage() {
echo " shell Enter the androdeb shell environment and get to work!"
echo " remove Remove androdeb from the device"
echo " git-pull Git pull androdeb to update it on your host"
echo " pull Retrieve files from the androdeb filesystem in the device"
echo " pull Copy files from the androdeb filesystem in the device"
echo " push Copy files to the androdeb filesystem in the device"
echo ""
echo " prepare Prepare the device (when running for the first time)"
echo " --tracers Enable tracing packages (perf and trace-cmd)"
Expand Down

0 comments on commit 5104a6c

Please sign in to comment.