diff --git a/bin/buildiso.in b/bin/buildiso.in index 8f464cb..4d5d2d7 100755 --- a/bin/buildiso.in +++ b/bin/buildiso.in @@ -82,6 +82,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}" @@ -119,8 +120,6 @@ load_config "${USER_CONFIG}/manjaro-tools.conf" load_config "${SYSCONFDIR}/manjaro-tools.conf" clean_first=true -clean_cache_xorg=true -clean_cache_lng=true clean_cache_iso=true pretend=false @@ -135,6 +134,7 @@ usage() { echo " -a Arch [default: ${arch}]" echo " -b Branch [default: ${branch}]" echo ' -r Chroots directory' + echo ' -k Custom pacman repo to keep' echo " [default: ${chroots_iso}]" echo ' -w Disable clean iso cache' echo ' -c Disable clean work dir' @@ -152,7 +152,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 @@ -160,6 +160,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 c20214e..2130a7c 100644 --- a/conf/manjaro-tools.conf +++ b/conf/manjaro-tools.conf @@ -53,6 +53,15 @@ # default iso buildset; name without .set extension # buildset_iso=default +# clean xorg cache before building +# clean_cache_xorg=true + +# 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 3ed6ae5..fdd3489 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -525,6 +525,36 @@ compress_images(){ msg3 "Time ${FUNCNAME}: $(elapsed_time ${timer}) minutes" } +clean_pacman_conf(){ + # set default values + 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/\]//')) + # 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" && flag=1 || return 1 + fi + done + if [[ $flag -eq 1 ]]; then + msg "Custom repo $repo removed from pacman.conf" + fi + fi + done +} + build_images(){ local timer=$(get_timer) load_pkgs "Packages" @@ -599,10 +629,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 .. diff --git a/lib/util.sh b/lib/util.sh index 81cccc8..9099d0a 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -258,6 +258,14 @@ load_config(){ buildset_iso='default' fi + if [[ -z ${clean_cache_xorg} ]];then + clean_cache_xorg='true' + fi + + if [[ -z ${clean_cache_lng} ]];then + clean_cache_lng='true' + fi + ##### iso settings ##### if [[ -z ${dist_release} ]];then