forked from artix/artools
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e52f9b577e | ||
![]() |
31baa79248 | ||
![]() |
fb1cead10a | ||
![]() |
01e37feb4e | ||
![]() |
25e2755ffa | ||
![]() |
03fc8aea26 | ||
![]() |
fcc006f30f |
@@ -19,7 +19,7 @@ import ${LIBDIR}/util.sh
|
||||
import ${LIBDIR}/util-pkg-tree.sh
|
||||
|
||||
show_imports(){
|
||||
for repo in ${repo_tree_artix[@]};do
|
||||
for repo in ${repo_tree_import[@]};do
|
||||
read_import_list "$repo"
|
||||
for p in ${import_list[@]};do
|
||||
msg2 "%s: %s" ""$repo "$p"
|
||||
@@ -34,18 +34,18 @@ display_settings(){
|
||||
msg "REPOS:"
|
||||
msg2 "repo_tree_artix: %s" "${repo_tree_artix[*]}"
|
||||
msg2 "repo_tree_arch: %s" "${repo_tree_arch[*]}"
|
||||
msg2 "repo_tree_import: %s" "${repo_tree_import[*]}"
|
||||
|
||||
msg "ARGS:"
|
||||
msg2 "verbose: %s" "${verbose}"
|
||||
msg2 "artix: %s" "${artix}"
|
||||
msg2 "artix_stable: %s" "${artix_stable}"
|
||||
msg2 "artix_testing: %s" "${artix_testing}"
|
||||
msg2 "arch: %s" "${arch}"
|
||||
msg2 "import_arch: %s" "${import_arch}"
|
||||
|
||||
msg "PATHS:"
|
||||
msg2 "tree_dir_artix: %s" "${tree_dir_artix}"
|
||||
msg2 "tree_dir_arch: %s" "${tree_dir_arch}"
|
||||
# msg2 "host_tree_artix: %s" "${host_tree_artix}"
|
||||
# msg2 "host_tree_arch: %s" "${host_tree_arch}"
|
||||
|
||||
if ${verbose}; then
|
||||
if ${import_arch};then
|
||||
@@ -59,19 +59,21 @@ load_user_info
|
||||
|
||||
load_config "${AT_USERCONFDIR}/artools.conf" || load_config "${SYSCONFDIR}/artools.conf"
|
||||
|
||||
artix=false
|
||||
artix_stable=false
|
||||
pretend=false
|
||||
arch=false
|
||||
import_arch=false
|
||||
verbose=false
|
||||
artix_testing=false
|
||||
|
||||
rsync_args=(-aWx --progress --delete --no-R --no-implied-dirs)
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options]"
|
||||
echo " -x Sync artix tree"
|
||||
echo " -s Sync artix tree stable"
|
||||
echo " -t Sync artix tree testing"
|
||||
echo " -a Sync arch tree"
|
||||
echo ' -i Import arch system packages'
|
||||
echo ' -i Import arch packages'
|
||||
echo ' -v Verbose import output'
|
||||
echo ' -q Query settings'
|
||||
echo ' -h This help'
|
||||
@@ -82,11 +84,12 @@ usage() {
|
||||
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='xaivqh'
|
||||
opts='staivqh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
x) artix=true ;;
|
||||
s) artix_stable=true ;;
|
||||
t) artix_testing=true ;;
|
||||
a) arch=true ;;
|
||||
i) import_arch=true ;;
|
||||
v) verbose=true; rsync_args+=(-v --stats) ;;
|
||||
@@ -103,7 +106,7 @@ prepare_dir "${tree_dir_arch}"
|
||||
|
||||
${pretend} && display_settings && exit 1
|
||||
|
||||
${artix} && sync_tree_artix
|
||||
${artix_stable} && sync_tree_artix "${artix_testing}"
|
||||
|
||||
${arch} && sync_tree_arch
|
||||
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
# artix package tree
|
||||
# repo_tree_artix=('system' 'world' 'galaxy')
|
||||
# repo_tree_import=('system-arch' 'world-arch' 'galaxy-arch')
|
||||
|
||||
# host_tree_artix=https://github.com/artix-linux
|
||||
|
||||
|
@@ -17,33 +17,38 @@ get_remote_head(){
|
||||
echo $(git ls-remote origin -h refs/heads/$1 | cut -f1)
|
||||
}
|
||||
|
||||
is_dirty() {
|
||||
[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
sync_tree_branches(){
|
||||
local branches=(master artix archlinux)
|
||||
for b in ${branches[@]};do
|
||||
git checkout $b &> /dev/null
|
||||
local local_head=$(get_local_head "$b")
|
||||
local remote_head=$(get_remote_head "$b")
|
||||
local timer=$(get_timer) repo="$1"
|
||||
msg "Checking [%s] (%s) ..." "$repo" "$b"
|
||||
local branches=('master') repo="$1" testing="$2"
|
||||
${testing} && branches+=('testing')
|
||||
for branch in ${branches[@]};do
|
||||
git checkout $branch &> /dev/null
|
||||
local local_head=$(get_local_head "$branch")
|
||||
local remote_head=$(get_remote_head "$branch")
|
||||
local timer=$(get_timer)
|
||||
msg "Checking [%s] (%s) ..." "$repo" "$branch"
|
||||
msg2 "local: %s" "${local_head}"
|
||||
msg2 "remote: %s" "${remote_head}"
|
||||
if [[ "${local_head}" == "${remote_head}" ]]; then
|
||||
info "nothing to do"
|
||||
else
|
||||
info "needs sync"
|
||||
git pull origin $b
|
||||
git pull origin $branch
|
||||
fi
|
||||
msg "Done [%s] (%s)" "$repo" "$b"
|
||||
msg "Done [%s] (%s)" "$repo" "$branch"
|
||||
done
|
||||
git checkout master &> /dev/null
|
||||
show_elapsed_time "${FUNCNAME}" "${timer}"
|
||||
}
|
||||
|
||||
sync_tree(){
|
||||
local branch="master"
|
||||
local branch="master" repo="$1"
|
||||
local local_head=$(get_local_head "$branch")
|
||||
local remote_head=$(get_remote_head "$branch")
|
||||
local timer=$(get_timer) repo="$1"
|
||||
local timer=$(get_timer)
|
||||
msg "Checking [%s] ..." "$repo"
|
||||
msg2 "local: %s" "${local_head}"
|
||||
msg2 "remote: %s" "${remote_head}"
|
||||
@@ -67,11 +72,23 @@ clone_tree(){
|
||||
}
|
||||
|
||||
sync_tree_artix(){
|
||||
local testing="$1"
|
||||
cd ${tree_dir_artix}
|
||||
for repo in ${repo_tree_artix[@]};do
|
||||
if [[ -d ${repo} ]];then
|
||||
cd ${repo}
|
||||
sync_tree_branches "${repo}"
|
||||
$(is_dirty) && die "[%s] has uncommited changes!" "${repo}"
|
||||
sync_tree_branches "${repo}" "${testing}"
|
||||
cd ..
|
||||
else
|
||||
clone_tree "${repo}" "${host_tree_artix}/${repo}"
|
||||
fi
|
||||
done
|
||||
for repo in ${repo_tree_import[@]};do
|
||||
if [[ -d ${repo} ]];then
|
||||
cd ${repo}
|
||||
$(is_dirty) && die "[%s] has uncommited changes!" "${repo}"
|
||||
sync_tree "${repo}"
|
||||
cd ..
|
||||
else
|
||||
clone_tree "${repo}" "${host_tree_artix}/${repo}"
|
||||
@@ -100,33 +117,35 @@ read_import_list(){
|
||||
import_list=$(sed "$_com_rm" "${list_dir_import}/$name.list" | sed "$_space" | sed "$_clean")
|
||||
}
|
||||
|
||||
is_dirty() {
|
||||
[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
get_pkgver(){
|
||||
source PKGBUILD
|
||||
echo $pkgver-$pkgrel
|
||||
}
|
||||
|
||||
is_untracked(){
|
||||
[[ $(git ls-files --others --exclude-standard) != "" ]] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
import_from_arch(){
|
||||
local timer=$(get_timer)
|
||||
for repo in ${repo_tree_artix[@]};do
|
||||
for repo in ${repo_tree_import[@]};do
|
||||
read_import_list "$repo"
|
||||
if [[ -n ${import_list[@]} ]];then
|
||||
cd ${tree_dir_artix}/$repo
|
||||
git checkout archlinux &> /dev/null
|
||||
git checkout master &> /dev/null
|
||||
$(is_dirty) && die "[%s] has uncommited changes!" "${repo}"
|
||||
local arch_dir=packages
|
||||
[[ $repo == "galaxy" ]] && arch_dir=community
|
||||
msg "Import into [%s] branch (archlinux)" "$repo"
|
||||
[[ $repo == "galaxy-arch" ]] && arch_dir=community
|
||||
msg "Import into [%s]" "$repo"
|
||||
for pkg in ${import_list[@]};do
|
||||
msg2 "Importing [%s] ..." "$pkg"
|
||||
rsync "${rsync_args[@]}" ${tree_dir_arch}/$arch_dir/$pkg/trunk/ ${tree_dir_artix}/$repo/$pkg/
|
||||
if $(is_dirty); then
|
||||
if $(is_dirty) || $(is_untracked); then
|
||||
git add $pkg
|
||||
cd $pkg
|
||||
git commit -m "Archlinux $pkg-$(get_pkgver) import"
|
||||
local ver=$(get_pkgver)
|
||||
msg2 "Archlinux import: [%s]" "$pkg-$ver"
|
||||
git commit -m "Archlinux import: $pkg-$ver"
|
||||
cd ..
|
||||
fi
|
||||
done
|
||||
|
@@ -93,6 +93,8 @@ init_artools_pkg(){
|
||||
|
||||
[[ -z ${repo_tree_artix[@]} ]] && repo_tree_artix=('system' 'world' 'galaxy')
|
||||
|
||||
[[ -z ${repo_tree_import[@]} ]] && repo_tree_import=('system-arch' 'world-arch' 'galaxy-arch')
|
||||
|
||||
[[ -z ${host_tree_artix} ]] && host_tree_artix='https://github.com/artix-linux'
|
||||
|
||||
[[ -z ${tree_dir_arch} ]] && tree_dir_arch=${workspace_dir}/archlinux
|
||||
|
Reference in New Issue
Block a user