diff options
author | Arthur She <arthur.she@linaro.org> | 2014-09-18 00:19:40 -0700 |
---|---|---|
committer | Arthur She <arthur.she@linaro.org> | 2014-09-18 00:19:40 -0700 |
commit | f805e0a3bfff2b615cdca9d4b8860cffb753241a (patch) | |
tree | 8f45417335cb52f1eec63d218b583dfac0b0896e | |
parent | 32898a4ed21ded173d14ab4748b64c7061514f8e (diff) |
modified: kselftest-repo-update.sh
modified: kselftest-repo.conf
-rwxr-xr-x | kselftest-repo-update.sh | 71 | ||||
-rw-r--r-- | kselftest-repo.conf | 23 |
2 files changed, 45 insertions, 49 deletions
diff --git a/kselftest-repo-update.sh b/kselftest-repo-update.sh index 5a55f77..e7c06f4 100755 --- a/kselftest-repo-update.sh +++ b/kselftest-repo-update.sh @@ -1,32 +1,40 @@ #!/bin/bash # # This script is used to update in-kernel-tests (kernel_src/tools/testing/selftest) -CONFIG_FILE="./kselftest-repo.conf" +#CONFIG_FILE="./kselftest-repo.conf" +CONFIG_FILE="./kselftest-repo-arthur.conf" . ${CONFIG_FILE} -TCODE_REPO="ssh://git@git.linaro.org/people/arthur.she/in-kernel-tests.git" +#TCODE_REPO="ssh://git@git.linaro.org/people/arthur.she/in-kernel-tests.git" +TCODE_REPO="file:///media/arthur/arthur-usb3/linaro/qa/git/kselftest.git" WORKING_DIR="/tmp/qa-kselftest" KSRC_DIR="${WORKING_DIR}/kernel_src" TCODE_DIR="${WORKING_DIR}/kselftest" +checkout_branch () { + # $1: branch name + + # Check if the current branch is what we want + current_branch=`git branch | grep "^\*" | awk '{print $2}'` + if [ "${current_branch}" = "$1" ]; then + # This branch is what we want, update it + git pull + else + # This branch is not what we want, check out the target branch + [ -z "`git branch|grep \"$1$\"`" ] && git checkout -b $1 origin/$1 || git checkout $1 + [ $? -ne 0 ] && echo "Error: Can not clone branch \"$1\"" && exit 1 + git pull + fi +} + clone_repo () { # $1: git repository # $2: the branch we want # $3: target directory if [ -d "$3" ]; then - # The kernel source is exist, update it + # The source is exist, update it pushd $3 - # Check if the current branch is what we want - current_branch=`git branch | grep "^\*" | awk '{print $2}'` - if [ "${current_branch}" = "$2" ]; then - # This branch is what we want, update it - git pull - else - # This branch is not what we want, check out the target branch - [ -z "`git branch|grep \"$2$\"`" ] && git checkout -b $2 origin/$2 || git checkout $2 - [ $? -ne 0 ] && echo "Error: Can not clone branch \"$2\" from repo: $1" && exit 1 - git pull - fi + checkout_branch $2 popd else # We have to clone the kernel source @@ -35,16 +43,6 @@ clone_repo () { [ $? -ne 0 ] && echo "Error: Can not clone branch \"$2\" from repo: $1" && exit 1 } -checkout_branch () { - # $1: branch name - - current_branch=`git branch | grep "^\*" | awk '{print $2}'` - if [ "${current_branch}" != "$1" ]; then - git checkout -b $1 origin/$1 - [ $? -ne 0 ] && echo "Error: Can not checkout branch: \"$1\"" && exit 1 - fi -} - [ -d ${WORKING_DIR} ] || mkdir -p ${WORKING_DIR} # Clone our test code @@ -54,40 +52,37 @@ clone_repo ${TCODE_REPO} master ${TCODE_DIR} pushd ${TCODE_DIR} for i in `seq 0 $((${#REMOTE_REPO[@]}-1))`; do - echo -e "\nSync with repo: ${REMOTE_REPO[$i]}\n" remote_repo="`echo ${REMOTE_REPO[$i]}|cut -d ' ' -f1`" remote_branch="`echo ${REMOTE_REPO[$i]}|cut -d ' ' -f2`" dir_name=`echo ${KSELFTEST_BRANCH[$i]}|awk '{print $NF}'` kworking_dir="${KSRC_DIR}/${dir_name}" + echo -e "\nSync with repo: ${remote_repo}\n" clone_repo ${remote_repo} ${remote_branch} ${kworking_dir} pushd ${kworking_dir} cm=`git log -n1|head -n1|awk '{print $NF}'` - commit_comment="Update to ${cm} from repo ${REMOTE_REPO[$i]}" + commit_comment="Update to ${cm} from repo ${remote_repo} branch ${remote_branch}" popd - IFS=' ';read -ra bn <<< ${branch[$i]} + IFS=' ';read -ra bn <<< ${KSELFTEST_BRANCH[$i]} for b in ${bn[@]}; do - echo -e "\nUpdate branch \"${b}\"\n" + echo -e "\nUpdate test code of branch \"${b}\"\n" checkout_branch ${b} rm -rf * - cp -ra ${KSRC_DIR}/tools/testing/selftests/* . - if [ -n "`git diff`" ]; then + cp -ra ${kworking_dir}/tools/testing/selftests/* . + if [ -z "`git status|grep 'nothing to commit'`" ]; then # There're something changed echo "We got something changed, update it.." # Remove files which have been deleted - for df in `git status|grep "deleted:"|awk '{print $2}'`; - do - git rm ${df} - done + [ -n "`git status|grep \"delete\"`" ] && git add -u . # Add new/modified files - git add . - # Commit & push + [ -n "`git status|grep 'Untracked files'`" ] && git add . + # Commit, tag & push git commit -m "${commit_comment}" - git push origin ${b} + git tag ${cm} + git push --tag origin ${b} else echo "Already up-to-date." fi done done popd - diff --git a/kselftest-repo.conf b/kselftest-repo.conf index b5d75e9..3cba732 100644 --- a/kselftest-repo.conf +++ b/kselftest-repo.conf @@ -1,16 +1,17 @@ -# -KSELFTEST_BRANCH=("master linux-mainline" \ - "linux-stable" \ - "linux-linaro" \ - "linux-linaro-stable-3.10" \ - "linux-linaro-stable-3.14" ) +#!/bin/bash + +KSELFTEST_BRANCH=( "master linux-mainline" \ + "linux-stable" \ + "linux-linaro" \ + "linux-linaro-stable-3.10" \ + "linux-linaro-stable-3.14" ) # The format is "GIT_REPO BRANCH" # The script will clone the branch 'BRANCH' from the repository 'GIT_REPO' -REMOTE_REPO=("git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master" \ - "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master" \ - "http://git.linaro.org/kernel/linux-linaro-tracking.git master" \ - "http://git.linaro.org/kernel/linux-linaro-stable.git linux-linaro-lsk-v3.10" \ - "http://git.linaro.org/kernel/linux-linaro-stable.git linux-linaro-lsk-v3.14" ) +REMOTE_REPO=( "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master" \ + "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master" \ + "http://git.linaro.org/kernel/linux-linaro-tracking.git master" \ + "http://git.linaro.org/kernel/linux-linaro-stable.git linux-linaro-lsk-v3.10" \ + "http://git.linaro.org/kernel/linux-linaro-stable.git linux-linaro-lsk-v3.14" ) |