2015-02-16 20:33:20 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
sync_tree(){
|
2015-02-17 12:27:13 +01:00
|
|
|
local master=$(git log --pretty=%H ...refs/heads/master^ | head -n 1) \
|
2015-02-18 20:10:31 +01:00
|
|
|
master_remote=$(git ls-remote origin -h refs/heads/master | cut -f1) \
|
|
|
|
timer=$(get_timer)
|
2015-02-17 12:27:13 +01:00
|
|
|
msg "Checking [$1] ..."
|
|
|
|
msg2 "local: ${master}"
|
|
|
|
msg2 "remote: ${master_remote}"
|
|
|
|
if [[ "${master}" == "${master_remote}" ]]; then
|
|
|
|
msg3 "nothing to do"
|
2015-02-16 23:00:32 +01:00
|
|
|
else
|
2015-02-17 12:27:13 +01:00
|
|
|
msg3 "needs sync"
|
2015-02-16 23:00:32 +01:00
|
|
|
git pull origin master
|
|
|
|
fi
|
2015-02-20 11:57:04 +01:00
|
|
|
msg "Done [$1]"
|
|
|
|
msg3 "Time ${FUNCNAME}: $(elapsed_time ${timer}) minutes"
|
2015-02-16 23:00:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
clone_tree(){
|
2015-02-18 20:10:31 +01:00
|
|
|
local timer=$(get_timer)
|
2015-02-17 12:27:13 +01:00
|
|
|
msg "Preparing [$1] ..."
|
|
|
|
msg3 "clone"
|
2015-02-17 18:28:26 +01:00
|
|
|
git clone $2.git
|
2015-02-20 11:57:04 +01:00
|
|
|
msg "Done [$1]"
|
|
|
|
msg3 "Time ${FUNCNAME}: $(elapsed_time ${timer}) minutes"
|
2015-02-16 23:00:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sync_tree_manjaro(){
|
2015-02-16 20:33:20 +01:00
|
|
|
cd ${tree_dir}
|
2015-02-18 20:10:31 +01:00
|
|
|
for repo in ${repo_tree[@]};do
|
|
|
|
if [[ -d packages-${repo} ]];then
|
|
|
|
cd packages-${repo}
|
|
|
|
sync_tree "${repo}"
|
|
|
|
cd ..
|
|
|
|
else
|
|
|
|
clone_tree "${repo}" "${host_tree}/packages-${repo}"
|
|
|
|
fi
|
|
|
|
done
|
2015-02-16 20:33:20 +01:00
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
sync_tree_abs(){
|
2015-02-17 18:28:26 +01:00
|
|
|
local repo_tree_abs=('packages' 'community')
|
|
|
|
cd ${tree_dir_abs}
|
2015-02-18 20:10:31 +01:00
|
|
|
for repo in ${repo_tree_abs[@]};do
|
|
|
|
if [[ -d ${repo} ]];then
|
|
|
|
cd ${repo}
|
|
|
|
sync_tree "${repo}"
|
|
|
|
cd ..
|
|
|
|
else
|
|
|
|
clone_tree "${repo}" "${host_tree_abs}/${repo}"
|
|
|
|
fi
|
|
|
|
done
|
2015-02-16 20:33:20 +01:00
|
|
|
cd ..
|
|
|
|
}
|