在網上看到別人寫的腳本,不是很滿意,自己就重寫了一下。先把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
#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
#!/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
#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
#!/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
#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
#!/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
#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