manjaro-tools/lib/util-pkgtree.sh

60 lines
1.4 KiB
Bash
Raw Normal View History

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(){
local master=$(git log --pretty=%H ...refs/heads/master^ | head -n 1) \
master_remote=$(git ls-remote origin -h refs/heads/master | cut -f1)
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
msg3 "needs sync"
2015-02-16 23:00:32 +01:00
git pull origin master
fi
msg "Done [$1]"
2015-02-16 23:00:32 +01:00
}
clone_tree(){
msg "Preparing [$1] ..."
msg3 "clone"
git clone $2.git -q
msg "Done [$1]"
2015-02-16 23:00:32 +01:00
}
sync_tree_manjaro(){
2015-02-16 20:33:20 +01:00
cd ${tree_dir}
for repo in ${repo_tree[@]};do
2015-02-16 22:32:21 +01:00
if [[ -d packages-${repo} ]];then
cd packages-${repo}
2015-02-16 23:00:32 +01:00
sync_tree "${repo}"
2015-02-16 20:33:20 +01:00
cd ..
else
2015-02-16 23:07:25 +01:00
clone_tree "${repo}" "${host_tree}/packages-${repo}"
2015-02-16 20:33:20 +01:00
fi
done
cd ..
}
sync_tree_abs(){
local repo_abs=packages
cd ${tree_dir} #/${repo_abs}
2015-02-16 23:00:32 +01:00
if [[ -d packages ]];then
cd packages
sync_tree "${repo_abs}"
2015-02-16 23:00:32 +01:00
cd ..
else
clone_tree "${repo_abs}" "${host_tree_abs}"
2015-02-16 23:00:32 +01:00
fi
2015-02-16 20:33:20 +01:00
cd ..
}