在网上看到别人写的脚本,不是很满意,自己就重写了一下。先把MeeGo的获取脚本给做了,后来想想Android也可以这么干,所以就把meego项目同步脚本改了改,基本上也能用上了。不过我个人还是推荐用repo的方式。代码基础是一样的,要改动的东西不算多。下面是脚本源码。

 

获取或者同步MeeGo项目源码的脚本:
#!/bin/sh
#get_meego_projects.sh
REPO_MANI_DIR="meego_manifest"
REPO_MANIFEST="${REPO_MANI_DIR}/default.xml"
REPO_URL_BASE="git://gitorious.org"

if [ -f ${REPO_MANI_DIR}/.git/config ]; then
    ( cd ${REPO_MANI_DIR} ; git pull )
else
    git clone git://gitorious.org/repo-for-meego/meego_manifest.git
fi

#awk -F'name=|"' '/^[[:space:]]*<project/{print $2}' ${REPO_MANIFEST} | while read REPO_PATH
awk -F'path=|"' '/^[[:space:]]*<project/{print $3}' ${REPO_MANIFEST} | while read REPO_PATH
do
    if [ -f ${REPO_PATH}/.git/config ]; then
        echo "----------Begin updating ${REPO_PATH}----------"
        ( cd ${REPO_PATH} ; git pull )
        echo "----------End updating ${REPO_PATH}----------"
    else
        echo "----------Begin cloning ${REPO_PATH}----------"
        mkdir -p $(dirname ${REPO_PATH}) && git clone ${REPO_URL_BASE}/${REPO_PATH}.git ${REPO_PATH}
        echo "----------End cloning ${REPO_PATH}----------"
    fi
done
 
使用repo获取meego源码的方法:
#!/bin/sh
#get_meego_repo.sh
REPO_TARGET_DIR="/opt/meego/sources"
REPO_SOURCE_URL="git://gitorious.org/repo-for-meego/meego_manifest.git"

curl http://android.git.kernel.org/repo > /usr/local/bin/repo
chmod a+x /usr/local/bin/repo
mkdir -p ${REPO_TARGET_DIR}
cd ${REPO_TARGET_DIR}
repo init -u ${REPO_SOURCE_URL}
repo sync
 
获取或者同步Android项目源码的脚本:
#!/bin/sh
#get_android_source.sh
REPO_MANI_DIR="manifest"
REPO_MANIFEST="${REPO_MANI_DIR}/default.xml"
REPO_URL_BASE="http://android.git.kernel.org/platform"

if [ -f ${REPO_MANI_DIR}/.git/config ]; then
    ( cd ${REPO_MANI_DIR} ; git pull )
else
    git clone http://android.git.kernel.org/platform/manifest.git
fi


#awk -F'name=|"' '/^[[:space:]]*<project/{print $2}' ${REPO_MANIFEST} | while read REPO_PATH
awk -F'path=|"' '/^[[:space:]]*<project/{print $3}' ${REPO_MANIFEST} | while read REPO_PATH
do
    if [ -f ${REPO_PATH}/.git/config ]; then
        echo "----------Begin updating ${REPO_PATH}----------"
        ( cd ${REPO_PATH} ; git pull )
        echo "----------End updating ${REPO_PATH}----------"
    else
        echo "----------Begin cloning ${REPO_PATH}----------"
        mkdir -p $(dirname ${REPO_PATH}) && git clone ${REPO_URL_BASE}/${REPO_PATH}.git ${REPO_PATH}
        echo "----------End cloning ${REPO_PATH}----------"
    fi
done
 
使用repo获取android源码的方法:
#!/bin/sh
#get_android_repo.sh
REPO_TARGET_DIR="/opt/android/sources"
REPO_SOURCE_URL="git://android.git.kernel.org/platform/manifest.git"

curl http://android.git.kernel.org/repo > /usr/local/bin/repo
chmod a+x /usr/local/bin/repo
mkdir -p ${REPO_TARGET_DIR}
cd ${REPO_TARGET_DIR}
repo init -u ${REPO_SOURCE_URL}
repo sync