diff --git a/crup-runner.sh b/crup-runner.sh deleted file mode 100755 index eccb6136f4..0000000000 --- a/crup-runner.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash - -update_toplevel () { - # Don't "pull" if checkout is not on a named branch - if test "$2" = "pull" && ( ! git symbolic-ref HEAD >/dev/null 2>/dev/null ); then - first_args="$1 fetch" - else - first_args="$1 $2" - fi - shift 2 - echo "[$solution] $first_args $@" 1>&2 - $first_args $@ | sed "s/^/[$solution] /g" 1>&2 - status=$? - if [ "$status" -ne 0 ]; then - exit $status - fi -} - -set_target_os () { - # Get the os we're building for. On first run, this will be unset. - target_os=$(git config --get-all target.os 2>/dev/null) - if [ -z "$target_os" ]; then - case $(uname -s) in - Linux) target_os=unix ;; - Darwin) target_os=mac ;; - CYGWIN*|MINGW*) target_os=win ;; - *) - echo "[$solution] *** No target.os set in .git/config, and I can't" 1>&2 - echo "[$solution] *** figure it out from 'uname -s'" 1>&2 - exit 1 - ;; - esac - git config target.os "$target_os" - fi -} - -update_submodule_url () { - # If the submodule's URL in .gitmodules has changed, propagate the new - # new URL down. This is the same as `git submodule sync`, but we do it - # this way because `git submodule sync` is absurdly slow. - new_url=$(git config -f .gitmodules "submodule.$1.url" 2>/dev/null) - old_url=$(git config "submodule.$1.url" 2>/dev/null) - if [ "$new_url" != "$old_url" ]; then - git config "submodule.$1.url" "$new_url" - if [ -e "$1"/.git ]; then - ( cd $submod && git config remote.origin.url "$new_url" ) - fi - fi -} - -process_submodule () { - # Check whether this submodule should be ignored or updated. - # If it's a new submodule, match the os specified in .gitmodules against - # the os specified in .git/config. - update_policy=$(git config --get "submodule.$1.update") - if [ -z "$update_policy" ]; then - submod_os=$(git config -f .gitmodules --get "submodule.$1.os") - if [ -n "$submod_os" -a "$submod_os" != "all" ]; then - update_policy=none - for os in $target_os; do - if [ "${submod_os/${os}/}" != "${submod_os}" ]; then - update_policy=checkout - fi - done - else - update_policy=checkout - fi - if [ "$update_policy" != "none" ]; then - git submodule --quiet init "$1" - fi - git config "submodule.$1.update" $update_policy - fi - ignore_policy=$(git config --get "submodule.$1.ignore") - if [ -z "$ignore_policy" ]; then - git config "submodule.$1.ignore" all - fi - if [ "$update_policy" != "none" ]; then - update_submodule_url "$1" - echo "$solution/$1" - fi -} - -if [ -z "$*" ]; then - exit 0 -fi -set -o pipefail -dir="$1" -solution="${1%%/*}" -cd "$solution" 1>/dev/null - -if [ "$solution" = "$1" ]; then - # Skip git checkouts not managed by crup. - gitdir="$(git rev-parse --git-dir)" - if ! grep -q -s "The Chromium Authors" "$gitdir/description"; then - echo "Skipping unmanaged git directory $1" 1>&2 - exit 0 - fi - - # Set default behavior to ignore diffs in submodule checkouts - diff_policy=$(git config --get "diff.ignoreSubmodules") - if [ -z "$diff_policy" ]; then - git config diff.ignoreSubmodules all - fi - - # Don't "pull" if checkout is not on a named branch - shift - if test $# -ne 0; then - update_toplevel "$@" - fi - - set_target_os - - git ls-files -s | grep ^160000 | awk '{print $4}' | - while read submod; do - process_submodule "$submod" - done - status=$? -else - submodule="${1#*/}" - echo "[$solution] updating $submodule" - git submodule update --recursive --quiet "$submodule" | - ( grep -v '^Skipping submodule' || true ) | sed "s|^|[$1] |g" 2>/dev/null - status=$? - if [ "$status" -ne "0" ]; then - echo "[$solution] FAILED to update $submodule" - fi -fi -exit $status diff --git a/git-crsync b/git-crsync index edeb20e774..67b7ae7701 100755 --- a/git-crsync +++ b/git-crsync @@ -1,3 +1,3 @@ #!/bin/bash -exec bash git-crup --sync "$@" +. git-crup diff --git a/git-crup b/git-crup index 8b96e7aaba..56b84c3998 100755 --- a/git-crup +++ b/git-crup @@ -3,169 +3,43 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# A convenience script to largely replicate the behavior of `gclient sync` in a -# submodule-based checkout. Fetches latest commits for top-level solutions; -# updates submodules; and runs post-sync hooks. +TOPLEVEL=$(git rev-parse --show-toplevel) +TOPPERLEVEL=$(dirname $TOPLEVEL) -orig_args="$@" -ECHO= -pull=pull -pull_args= -hooks=yes -j=10 -crup_runner="crup-runner.sh" +cat <] +Please consult https://code.google.com/p/chromium/wiki/UsingGitSubmodules#Convert_from_submodules_to_gclient +for instructions on how to convert your submodule checkout to gclient. - -n, --dry-run Don't do anything; just show what would have been done. - --fetch Run 'git fetch' on top-level sources, but don't merge. - --sync Don't do anything at all to the top-level sources. - -j, --jobs Run this many jobs in parallel. - --no-hooks Don't run hooks (e.g., to generate build files) after - updating. -EOF -} - -serial_update() { - ( cd "$1" - if test -n "$toplevel_cmd"; then - $ECHO $toplevel_cmd | sed "s/^/[$1] /g" - if [ $? -ne 0 ]; then - return $? - fi - fi - $ECHO git submodule --quiet sync - $ECHO git ls-files -s | grep ^160000 | awk '{print $4}' | - while read submod; do - $ECHO "$crup_runner" "$1/$submod" - done - ) -} - -while test $# -ne 0; do - case "$1" in - -j[0-9]*) - j=$(echo "$1" | cut -c3-) - ;; - --jobs=[0-9]*) - j=$(echo "$1" | cut -c8-) - ;; - -j|--jobs) - case "$2" in - ''|-*) - j=0 - ;; - *) - j="$2" - shift - ;; - esac - ;; - -n|--dry-run) - ECHO=echo - ;; - -h|--help) - usage - exit 0 - ;; - --fetch) - pull=fetch - ;; - --sync) - pull= - ;; - --no-hooks|--nohooks) - hooks=no - ;; - *) - pull_args="$pull_args $1" - break - ;; - esac - shift -done - -# Auto-update depot_tools. -if [ -z "$GIT_CRUP_REINVOKE" ]; then - kernel_name="\$(uname -s)" - if [ "\${kernel_name:0:5}" = "MINGW" ]; then - cmd '/C update_depot_tools.bat' - else - update_depot_tools - fi - GIT_CRUP_REINVOKE=1 exec bash "$0" $orig_args -fi - -while test "$PWD" != "/"; do - if test -f "$PWD/src/.gitmodules"; then - break - fi - cd .. -done -if test "$PWD" = "/"; then - echo "Could not find the root of your checkout; aborting." 1>&2 - exit 1 -fi - -export GIT_MERGE_AUTOEDIT=no - -if ( echo test | xargs --max-lines=1 true 2>/dev/null ); then - max_lines="--max-lines=1" -else - max_lines="-L 1" -fi - -if ( echo test | xargs -I bar true 2>/dev/null ); then - replace_arg="-I replace_arg" -else - replace_arg="-ireplace_arg" -fi +The simplest chromium and/or blink instructions follow for convenience. -if ( echo test test | xargs -P 2 true 2>/dev/null ); then - xargs_parallel=yes -else - if test "$j" != "1"; then - echo "Warning: parallel execution is not supported on this platform." 1>&2 - fi - xargs_parallel=no -fi - -if test -n "$pull"; then - toplevel_cmd="git $pull $pull_args -q origin" -else - toplevel_cmd= -fi - -set -o pipefail -if test "$xargs_parallel" = "yes"; then - ( ls -d */.git | sed 's/\/\.git$//' | - xargs $max_lines $replace_arg -P "$j" \ - "$crup_runner" replace_arg $ECHO $toplevel_cmd | - xargs $max_lines -P "$j" $ECHO "$crup_runner" ) -else - ls -d */.git | - while read gitdir; do - serial_update "${gitdir%%/.git}" - done -fi - -status=$? - -if [ "$status" -ne 0 ]; then - cat 1>&2 <