Commit 21dbbb3f authored by udeved's avatar udeved

util: use getter for build_list

parent a9625a71
......@@ -97,15 +97,15 @@ copy_hostconf () {
if [[ -n ${build_mirror} ]];then
local branch=$(pacman-mirrors -a --prefix "$1" -G)
if ${keep_mirrors}; then
# set_branch "$1" "$(get_branch $1)"
info "Setting branch: %s" "${branch}"
pacman-mirrors -a -p "$1" -S "${branch}" -R
else
local mirror=${build_mirror}'/$repo/$arch'
echo "Server = ${mirror}" > "$1/etc/pacman.d/mirrorlist"
fi
else
# set_branch "$1" "$(get_branch $1)"
pacman-mirrors -a -p "$1" -S "$branch" -R
info "Setting branch: %s" "${branch}"
pacman-mirrors -a -p "$1" -S "${branch}" -R
fi
sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$1/etc/pacman.conf"
......
......@@ -65,22 +65,10 @@ check_user_repos_conf(){
get_pac_mirrors_conf(){
local conf="$tmp_dir/pacman-mirrors-$1.conf"
cp "${DATADIR}/pacman-mirrors.conf" "$conf"
sed -i "$conf" \
-e "s|Branch = stable|Branch = $1|"
sed -e "s|@branch@|$1|" -i "$conf"
echo "$conf"
}
read_build_list(){
local _space="s| ||g" \
_clean=':a;N;$!ba;s/\n/ /g' \
_com_rm="s|#.*||g"
build_list=$(sed "$_com_rm" "$1.list" \
| sed "$_space" \
| sed "$_clean")
}
# $1: list_dir
show_build_lists(){
local list temp
......@@ -101,15 +89,6 @@ show_build_profiles(){
echo $cpuarch
}
# $1: list_dir
# $2: build list
eval_build_list(){
eval "case $2 in
$(show_build_lists $1)) is_build_list=true; read_build_list $1/$2 ;;
*) is_build_list=false ;;
esac"
}
get_timer(){
echo $(date +%s)
}
......@@ -139,18 +118,6 @@ prepare_dir(){
[[ ! -d $1 ]] && mkdir -p $1
}
# # $1: chroot
# get_branch(){
# echo $(cat "$1/etc/pacman-mirrors.conf" | grep '^Branch = ' | sed 's/Branch = \s*//g')
# }
#
# # $1: chroot
# # $2: branch
# set_branch(){
# info "Setting mirrorlist branch: %s" "$2"
# sed -e "s|/stable|/$2|g" -i "$1/etc/pacman.d/mirrorlist"
# }
init_common(){
[[ -z ${target_branch} ]] && target_branch='stable'
......@@ -350,6 +317,20 @@ show_config(){
fi
}
read_build_list(){
local _space="s| ||g" _clean=':a;N;$!ba;s/\n/ /g' _com_rm="s|#.*||g"
echo $(sed "$_com_rm" "$1.list" | sed "$_space" | sed "$_clean")
}
# $1: list_dir
# $2: build list
eval_build_list(){
eval "case $2 in
$(show_build_lists $1)) is_build_list=true; build_list=$(read_build_list $1/$2) ;;
*) is_build_list=false ;;
esac"
}
run(){
if ${is_build_list};then
for item in ${build_list[@]};do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment