[util-iso] (clean_pacman_conf) use flag variable

This commit is contained in:
Aaditya Bagga 2015-05-03 09:28:39 +05:30
parent 93805a8ccf
commit 9f050b09b8

View file

@ -511,9 +511,11 @@ compress_images(){
} }
clean_pacman_conf(){ clean_pacman_conf(){
REPOS=() # set default value # set default values
REPOS=()
flag=0
# Get repos from pacman_conf # Get repos from pacman_conf
# sed is being used for filtering comments and repo brackets [] # sed is being used for removing comments and repo brackets []
REPOS=($(grep "\[*\]" "$pacman_conf" | sed -e '/^\s*#/d' -e 's/\[//' -e 's/\]//')) REPOS=($(grep "\[*\]" "$pacman_conf" | sed -e '/^\s*#/d' -e 's/\[//' -e 's/\]//'))
# Set valid repos # Set valid repos
if [[ $arch = x86_64 ]]; then if [[ $arch = x86_64 ]]; then
@ -528,11 +530,13 @@ clean_pacman_conf(){
for file in $work_dir/{livecd,root,$custom}-image/etc/pacman.conf; do for file in $work_dir/{livecd,root,$custom}-image/etc/pacman.conf; do
if [[ -f $file ]]; then if [[ -f $file ]]; then
msg2 "Editing $file" msg2 "Editing $file"
sed -i "/^\[$repo/,/^Server/d" "$file" || exit 1 sed -i "/^\[$repo/,/^Server/d" "$file" && flag=1 || return 1
fi fi
done done
if [[ $flag -eq 1 ]]; then
msg "Custom repo $repo removed from pacman.conf" msg "Custom repo $repo removed from pacman.conf"
fi fi
fi
done done
} }