11#! /usr/bin/env bash
22
3- set -e
3+ set -eu
44
55load_config () {
66 local _file
@@ -30,6 +30,7 @@ out_dir=""
3030archs=(" x86_64" " i686" " i486" )
3131stdout=false
3232include_aur=false
33+ pkglist=()
3334
3435# Parse options
3536OPTS=" a:o:hs"
@@ -43,7 +44,7 @@ unset OPT OPTS OPTL
4344while true ; do
4445 case " ${1} " in
4546 -a | --arch)
46- archs=( ${2} )
47+ IFS= " " read -ra archs <<< " ${2}"
4748 shift 2
4849 ;;
4950 -o | --out)
8081load_config () {
8182 local _file
8283 for _file in " ${@ } " ; do
83- if [[ -f " ${_file} " ]]; then
84- source " ${_file} "
85- fi
86- done
87- }
88-
89- for_module (){
90- local module
91- for module in " ${modules[@]} " ; do
92- eval $( echo " ${@ } " | sed " s|{}|${module} |g" )
84+ [[ -f " ${_file} " ]] && source " ${_file} "
9385 done
86+ return 0
9487}
9588
9689for arch in " ${archs[@]} " ; do
9790 for channel in $( " ${tools_dir} /channel.sh" show -a " ${arch} " -b -d -k zen -f) ; do
98- modules=( $ (
91+ readarray -t modules < < (
9992 load_config " ${script_path} /default.conf" " ${script_path} /custom.conf"
100- load_config " ${channel_dir } /config.any" " ${channel_dir } /config.${arch} "
101- if [[ ! -z " ${include_extra+SET} " ]]; then
93+ load_config " ${channel } /config.any" " ${channel } /config.${arch} "
94+ if [[ -n " ${include_extra+SET} " ]]; then
10295 if [[ " ${include_extra} " = true ]]; then
103- modules=(" share" " share-extra" )
96+ modules=(" base " " share" " share-extra" " calamares " " zsh-powerline " )
10497 else
105- modules=(" share" )
98+ modules=(" base " " share" )
10699 fi
107100 fi
108- for module in " ${modules[@]} " ; do
109- dependent=" ${module_dir} /${module} /dependent"
110- if [[ -f " ${dependent} " ]]; then
111- modules+=($( grep -h -v ^' #' " ${dependent} " | tr -d " \n" ) )
112- fi
113- done
114- unset module dependent
115- modules=($( printf " %s\n" " ${modules[@]} " | sort | uniq) )
116- for_module load_config " ${module_dir} /{}/config.any" " ${module_dir} /{}/config.${arch} "
117- echo " ${modules[@]} "
118- ) )
101+ printf " %s\n" " ${modules[@]} "
102+ )
119103
120- pkglist_opts=" -a ${arch} -b -c ${channel%/ } -k zen -l en --line ${modules[* ]} "
104+ pkglist_opts=( -a " ${arch} " -b -c " ${channel} " -k zen -l en --line " ${modules[@ ]} " )
121105
122106 if [[ " ${stdout} " = true ]]; then
123- pkglist+=($( " ${tools_dir} /pkglist.sh" ${pkglist_opts} ) )
124- if [[ " ${include_aur} " = true ]]; then
125- pkglist+=($( " ${tools_dir} /pkglist.sh" --aur ${pkglist_opts} ) )
126- fi
107+ readarray -O " ${# pkglist[@]} " -t pkglist < <( " ${tools_dir} /pkglist.sh" " ${pkglist_opts[@]} " )
108+ [[ " ${include_aur} " = true ]] && readarray -O " ${# pkglist[@]} " -t pkglist < <( " ${tools_dir} /pkglist.sh" --aur " ${pkglist_opts[@]} " ) || true
127109 else
128110 (
129- " ${tools_dir} /pkglist.sh" -d ${pkglist_opts}
130- if [[ " ${include_aur} " = true ]]; then
131- " ${tools_dir} /pkglist.sh" --aur -d ${pkglist_opts}
132- fi
111+ " ${tools_dir} /pkglist.sh" -d " ${pkglist_opts[@]} "
112+ [[ " ${include_aur} " = true ]] && " ${tools_dir} /pkglist.sh" --aur -d " ${pkglist_opts[@]} " || true
133113 ) 1> " ${out_dir} /$( basename " ${channel} " ) .${arch} "
134114 fi
135115
136116 done
137117done
138118
139119if [[ " ${stdout} " = true ]]; then
140- pkglist=( $( printf " %s\n" " ${pkglist[@]} " | sort | uniq) )
120+ readarray -t pkglist < <( printf " %s\n" " ${pkglist[@]} " | sort | uniq)
141121 printf " %s\n" " ${pkglist[@]} "
142122fi
0 commit comments