diff --git a/bin/buildiso.in b/bin/buildiso.in index 0e11541..4f4a76a 100755 --- a/bin/buildiso.in +++ b/bin/buildiso.in @@ -81,6 +81,7 @@ display_settings(){ msg2 "arch: ${arch}" msg2 "branch: ${branch}" msg2 "chroots_iso: ${chroots_iso}" + msg2 "custom repo to keep: ${keep_repo}" msg "ARGS:" msg2 "clean_first: ${clean_first}" @@ -132,6 +133,7 @@ usage() { echo " -a Arch [default: ${arch}]" echo " -b Branch [default: ${branch}]" echo ' -r Chroots directory' + echo ' -k Custom repo to keep from pacman.conf' echo " [default: ${chroots_iso}]" echo ' -w Disable clean iso cache' echo ' -c Disable clean work dir' @@ -149,7 +151,7 @@ usage() { orig_argv=("$@") -opts='p:a:b:r:cxlisqwLh' +opts='p:a:b:r:k:cxlisqwLh' while getopts "${opts}" arg; do case "${arg}" in @@ -157,6 +159,7 @@ while getopts "${opts}" arg; do a) arch="$OPTARG" ;; b) branch="$OPTARG" ;; r) chroots_iso="$OPTARG" ;; + k) keep_repo="$OPTARG" ;; c) clean_first=false ;; w) clean_cache_iso=false;; x) clean_cache_xorg=false ;; diff --git a/conf/manjaro-tools.conf b/conf/manjaro-tools.conf index acb1d57..2130a7c 100644 --- a/conf/manjaro-tools.conf +++ b/conf/manjaro-tools.conf @@ -59,6 +59,9 @@ # clean lng cache before building # clean_cache_lng=true +# custom pacman repo to keep +# keep_repo="" + # unset defaults to given value # dist_name="Manjaro" diff --git a/lib/util-iso.sh b/lib/util-iso.sh index ddc0dfd..8fa2640 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -510,6 +510,32 @@ compress_images(){ msg3 "Time ${FUNCNAME}: $(elapsed_time ${timer}) minutes" } +clean_pacman_conf(){ + REPOS=() # set default value + # Get repos from pacman_conf + # sed is being used for filtering comments and repo brackets [] + 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 + # 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" || exit 1 + fi + done + msg "Custom repo $repo removed from pacman.conf" + fi + done +} + build_images(){ local timer=$(get_timer) load_pkgs "Packages" @@ -554,10 +580,12 @@ 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 ..