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