| #!/bin/bash -e |
| |
| # Licensed to the Apache Software Foundation (ASF) under one or more |
| # contributor license agreements. See the NOTICE file distributed with |
| # this work for additional information regarding copyright ownership. |
| # The ASF licenses this file to You under the Apache License, Version 2.0 |
| # (the "License"); you may not use this file except in compliance with |
| # the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| component="$1" |
| |
| dsl=~/.config/srcs.dsl |
| |
| if [ ! -e "$dsl" ]; then |
| if [ "$component" == "__defaults__" ];then |
| ( |
| echo '# srcs dsl language' |
| echo '# add_src <component> <remote_name> <git_remote_addr>' |
| echo '# git_config <component> <key> <value>' |
| for c in tez hive calcite;do |
| echo "add_src $c apache https://github.com/apache/$c" |
| done |
| echo 'git_config hive extra.ideProjects ql,common' |
| echo 'git_config hive extra.mavenOpts -Denforcer.skip -Phadoop-2,itests' |
| )> "$dsl" |
| exit 0 |
| else |
| echo -e "ERROR: $dsl not found" |
| echo -e "you may get a default by calling invoking:\n $0 __defaults__" |
| exit 1 |
| fi |
| fi |
| |
| [ "$component" == "" ] && echo "usage: $0 <component>" && exit 1 |
| |
| function add_src() { |
| if [ "$1" == "$component" ];then |
| if git remote get-url "$2" 2>&1 >/dev/null;then |
| echo " * already has remote $2" |
| else |
| echo " * adding $2 ($3)" |
| git remote add "$2" "$3" |
| fi |
| fi |
| } |
| |
| function git_config() { |
| if [ "$1" == "$component" ];then |
| echo " * git config $2=$3" |
| git config "$2" "$3" |
| fi |
| } |
| |
| |
| refs="/work/reference/$component/" |
| mkdir -p "$refs" |
| |
| cd "$refs" |
| [ ! -d .git ] && git init . |
| echo " * updating refs ($refs)" |
| echo " * interpreting: $dsl" |
| . $dsl |
| |
| git fetch -j10 --all |
| |
| # go to home dir |
| cd |
| [ ! -d "$component" ] && git init "$component" |
| #&& echo "sources for $component already exists" && exit 1 |
| |
| cd "$component" |
| if [ -d "$refs" ];then |
| echo " * adding reference repo $refs" |
| echo "$refs/.git/objects" > .git/objects/info/alternates |
| fi |
| |
| echo " * interpreting: $dsl" |
| . $dsl |
| |
| git fetch -j10 --all |
| |
| banner ok |