Apktool 2.9.2
[opengapps/opengapps.git] / download_sources.sh
blob346affa5aafec0e4ad642fe061f8f407df38a80e
1 #!/bin/bash
2 # This file is part of The Open GApps script of @mfonville.
4 # The Open GApps scripts are free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # These scripts are distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
15 case $(uname -s) in
16 Darwin|Macintosh) readlink() { perl -MCwd -e 'print Cwd::abs_path shift' "$2"; };;
17 esac;
19 SCRIPT="$(readlink -f "$0")"
20 TOP="$(dirname "$SCRIPT")"
21 SCRIPTS="$TOP/scripts"
23 # shellcheck source=scripts/inc.tools.sh
24 . "$SCRIPTS/inc.tools.sh"
26 # Check tools
27 checktools git git-lfs
29 argument() {
30 case $1 in
31 arm)
32 modules="all $1"
34 arm64|x86)
35 modules="all arm $1"
37 x86_64)
38 modules="all arm x86 $1"
40 --shallow)
41 depth="--depth=1 --checkout" # checkout instead of rebasing, to avoid that it tries to rebase a huge number of commits in one go, resulting in failures (experimental!)
43 --i-would-really-like-my-diskspace-back)
44 for module in $modules; do
45 git submodule deinit -f sources/$module
46 rm -rf .git/modules/sources/$module
47 done
48 echo "NOTICE: All local sources removed! Find more donations for a larger hard disk..."
49 exit 0
51 esac
54 depth=""
55 modules="all arm arm64 x86 x86_64"
57 for arg in "$@"; do
58 argument $arg
59 done
61 pushd "$TOP" > /dev/null
62 for module in $modules; do
63 git submodule update --init --remote $depth -- "sources/$module" # --rebase is specifed in .gitmodules
64 if [ $? -ne 0 ]; then
65 echo "ERROR during git execution, aborted!"
66 exit 1
68 done
69 git submodule foreach -q 'branch="$(git config -f "$toplevel/.gitmodules" "submodule.$name.branch")"; git checkout -q "$branch"; git pull -q $depth --rebase; git lfs pull'
70 popd > /dev/null