]> git.wh0rd.org - home.git/blobdiff - .bin/cros-repo
vcs-url: fix gensub usage
[home.git] / .bin / cros-repo
index 3da6b5cdcecbfb752f1292074ff2d4c114732a5e..8f8765ba23817979678c1945a27ed06f80d52664 100755 (executable)
@@ -1,46 +1,67 @@
-#!/bin/sh
+#!/bin/bash
 
 usage() {
        cat <<-EOF
        Usage: repo-cros [options]
 
        Options:
+          depot_tools    clone depot_tools tree
           int            switch to internal tree
           ext            switch to external tree
           -b <branch>    switch branches (use "master" to get to ToT)
           -r <path>      patch to reference repo (e.g. ~/chromiumos/)
+          -g <group>
+          -m <manifest>
+          -e <email>
 
        Operates on the repo in ${PWD}
        EOF
        exit ${1:-1}
 }
 
-vexec() {
+v() {
        printf '%s\n%s\n' "${PWD}" "$*"
-       exec "$@"
+       "$@"
 }
 
 email="vapier@chromium.org"
 REF=
 BRANCH=
 MANIFEST=
+MANIFEST_NAME=
+RGROUPS=()
 REPO_URL=
 while [[ $# -gt 0 ]] ; do
        case $1 in
+       depot_tools|dt)
+               exec git clone https://git.chromium.org/chromium/tools/depot_tools.git
+               ;;
        int)
-               MANIFEST='ssh://gerrit-int.chromium.org:29419/chromeos/manifest-internal.git'
-               REPO_URL='http://git.chromium.org/external/repo.git'
+               MANIFEST='https://chrome-internal.googlesource.com/chromeos/manifest-internal.git'
+               REPO_URL='https://chromium.googlesource.com/external/repo.git'
                ;;
        ext)
-               MANIFEST='http://git.chromium.org/chromiumos/manifest.git'
-               REPO_URL='http://git.chromium.org/external/repo.git'
+               MANIFEST='https://chromium.googlesource.com/chromiumos/manifest.git'
+               REPO_URL='https://chromium.googlesource.com/external/repo.git'
                ;;
        -b)
                BRANCH=$2
                shift
                ;;
        -r)
-               REF=$(realpath "$2")
+               REF=$(realpath "${2:-$(echo ~/chromiumos)}")
+               shift
+               ;;
+       -g)
+               RGROUPS+=( "$2" )
+               shift
+               ;;
+       -m)
+               MANIFEST_NAME="${2%.xml}.xml"
+               shift
+               ;;
+       -e)
+               email=$2
                shift
                ;;
        *)
@@ -50,6 +71,18 @@ while [[ $# -gt 0 ]] ; do
        shift
 done
 
+if [[ ${#BRANCH} -eq 3 ]] && [[ -d ${REF} ]] ; then
+       BRANCH=$(git --git-dir="${REF}/.repo/manifests.git" branch -a | grep -o "release-${BRANCH}.*")
+fi
+
+v repo init \
+       ${MANIFEST:+-u "${MANIFEST}"} \
+       ${REPO_URL:+--repo-url="${REPO_URL}"} \
+       ${REF:+--reference "${REF}"} \
+       ${MANIFEST_NAME:+-m "${MANIFEST_NAME}"} \
+       ${RGROUPS:+-g "${RGROUPS[*]}"} \
+       ${BRANCH:+-b "${BRANCH}"}
+
 rdir=$(realpath "`pwd`")
 while [[ ! -d ${rdir}/.repo ]] ; do
        rdir=${rdir%/*}
@@ -67,9 +100,4 @@ if [[ -d ${rdir} ]] ; then
        fi
 fi
 
-vexec \
-       repo init \
-       ${MANIFEST:+-u "${MANIFEST}"} \
-       ${REPO_URL:+--repo-url="${REPO_URL}"} \
-       ${REF:+--reference "${REF}"} \
-       ${BRANCH:+-b "${BRANCH}"}
+exit 0