[util-iso] redo clean_pacman_conf to use keep_repos array so to define more than one repo to keep; some cosmetics

This commit is contained in:
udeved 2015-05-09 10:38:44 +02:00 committed by Ramon Buldó
parent 6f579af32d
commit 955c743ae4

View file

@ -350,7 +350,6 @@ make_image_boot() {
aufs_mount_root_image "${path}"
fi
copy_initcpio "${path}"
gen_boot_image "${path}"
mv ${path}/boot/${iso_name}.img ${path_iso}/${arch}/${iso_name}.img
if [[ -f ${path}/boot/intel-ucode.img ]]; then
@ -527,31 +526,42 @@ compress_images(){
clean_pacman_conf(){
# set default values
REPOS=()
flag=0
#local repos=() #valid_repos=()
#flag=0
# Get repos from pacman_conf
# sed is being used for removing comments and repo brackets []
REPOS=($(grep "\[*\]" "$pacman_conf" | sed -e '/^\s*#/d' -e 's/\[//' -e 's/\]//'))
local repos=($(grep "\[*\]" "$pacman_conf" | sed -e '/^\s*#/d' -e 's/\[//' -e 's/\]//'))
# Set valid repos
if [[ $arch = x86_64 ]]; then
VALID=('options' 'core' 'extra' 'community' 'multilib')
else
VALID=('options' 'core' 'extra' 'community')
fi
# case ${arch} in
# 'x86_64') valid_repos==('options' 'core' 'extra' 'community' 'multilib') ;;
# *) valid_repos=('options' 'core' 'extra' 'community') ;;
# esac
# Remove extra repos from pacman.conf
for repo in "${REPOS[@]}"; do
if [[ ! $(echo "${VALID[*]}" | grep "$repo") ]] && [[ ! $(echo "$keep_repo" | grep "$repo") ]]; then
# Remove custom repo
for file in $work_dir/{livecd,root,$custom}-image/etc/pacman.conf; do
if [[ -f $file ]]; then
msg2 "Editing $file"
sed -i "/^\[$repo/,/^Server/d" "$file" && flag=1 || return 1
for repo in "${repos[@]}"; do
case $repo in
'options'|'core'|'extra'|'community'|'multilib') continue ;;
*)
for kr in "${keep_repos[@]}"; do
if [[ ${repo} != ${kr} ]]; then
msg2 "Removing custom repo ${repo} ..."
sed -i "/^\[$repo/,/^Server/d" $1/etc/pacman.conf
fi
done
if [[ $flag -eq 1 ]]; then
msg "Custom repo $repo removed from pacman.conf"
fi
fi
;;
esac
# if [[ ! $(echo "${valid_repos[*]}" | grep "$repo") ]] && [[ ! $(echo "$keep_repo" | grep "$repo") ]]; then
# # Remove custom repo
# for file in $work_dir/root-image/etc/pacman.conf; do
# if [[ -f $file ]]; then
# msg2 "Editing $file"
# sed -i "/^\[$repo/,/^Server/d" "$file" && flag=1 || return 1
# fi
# done
# if [[ $flag -eq 1 ]]; then
# msg "Custom repo $repo removed from pacman.conf"
# fi
# fi
done
}
@ -582,6 +592,7 @@ build_images(){
fi
make_isolinux
make_isomounts
[[ -n ${keep_repos} ]] && clean_pacman_conf "${work_dir}/root-image"
msg3 "Time ${FUNCNAME}: $(elapsed_time ${timer}) minutes"
}
@ -629,12 +640,10 @@ make_profile(){
fi
if ${images_only}; then
build_images
clean_pacman_conf
warning "Continue compress: buildiso -p ${buildset_iso} -sc ..."
exit 1
else
build_images
clean_pacman_conf
compress_images
fi
cd ..