5 script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && cd .. && pwd )"
6 share_dir="${script_path}/channels/share"
17 #channel_dir="${script_path}/channels/xfce"
22 echo "usage ${0} [options] [command]"
24 echo "Get a list of packages to install on that channel"
26 echo " General options:"
27 echo " -a | --arch [arch] Specify the architecture"
28 echo " -b | --boot-splash Enable boot splash"
29 echo " -c | --channel Specify the channel directory"
30 echo " -k | --kernel Specify the kernel"
31 echo " -h | --help This help message"
34 # Usage: getclm <number>
35 # 標準入力から値を受けとり、引数で指定された列を抽出します。
37 echo "$(cat -)" | cut -d " " -f "${1}"
42 "${script_path}/tools/msg.sh" -s "5" -a "pkglist.sh" -l "Error" -r "red" error "${1}"
46 "${script_path}/tools/msg.sh" -s "5" -a "pkglist.sh" -l "Info" -r "green" error "${1}"
50 "${script_path}/tools/msg.sh" -s "5" -a "pkglist.sh" -l "Debug" -r "magenta" error "${1}"
56 _opt_short="a:bc:k:l:h"
57 _opt_long="arch:,boot-splash,channel:,kernel:,locale:,help"
58 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- ${ARGUMENT})
59 [[ ${?} != 0 ]] && exit 1
62 unset OPT _opt_short _opt_long
99 if [[ -z "${arch}" ]]; then
100 msg_error "Architecture not specified"
102 elif [[ -z "${channel_dir}" ]]; then
103 msg_error "Channel directory not specified"
105 #elif [[ -z "${kernel}" ]]; then
106 #msg_error "kernel not specified"
108 elif [[ -z "${locale_name}" ]]; then
109 msg_error "Locale not specified"
114 pkgdir_name="packages"
119 #-- Detect package list to load --#
120 # Add the files for each channel to the list of files to read.
123 $(ls ${share_dir}/${pkgdir_name}.${arch}/*.${arch} 2> /dev/null)
124 "${share_dir}/${pkgdir_name}.${arch}/lang/${locale_name}.${arch}"
127 $(ls ${channel_dir}/${pkgdir_name}.${arch}/*.${arch} 2> /dev/null)
128 "${channel_dir}/${pkgdir_name}.${arch}/lang/${locale_name}.${arch}"
131 "${share_dir}/${pkgdir_name}.${arch}/kernel/${kernel}.${arch}"
132 "${channel_dir}/${pkgdir_name}.${arch}/kernel/${kernel}.${arch}"
135 # Plymouth package list
136 if [[ "${boot_splash}" = true ]]; then
138 $(ls ${share_dir}/${pkgdir_name}.${arch}/plymouth/*.${arch} 2> /dev/null)
139 $(ls ${channel_dir}/${pkgdir_name}.${arch}/plymouth/*.${arch} 2> /dev/null)
144 #-- Read package list --#
145 # Read the file and remove comments starting with # and add it to the list of packages to install.
146 for _file in ${_loadfilelist[@]}; do
147 if [[ -f "${_file}" ]]; then
148 msg_debug "Loaded package file ${_file}"
149 _pkglist=( ${_pkglist[@]} "$(grep -h -v ^'#' ${_file})" )
153 #-- Read exclude list --#
154 # Exclude packages from the share exclusion list
156 "${share_dir}/${pkgdir_name}.${arch}/exclude"
157 "${channel_dir}/${pkgdir_name}.${arch}/exclude"
160 for _file in ${_excludefile[@]}; do
161 if [[ -f "${_file}" ]]; then
162 _excludelist=( ${_excludelist[@]} $(grep -h -v ^'#' "${_file}") )
166 #-- excludeに記述されたパッケージを除外 --#
167 # _pkglistを_subpkglistにコピーしexcludeのパッケージを除外し再代入
168 _subpkglist=(${_pkglist[@]})
170 for _pkg in ${_subpkglist[@]}; do
171 # もし変数_pkgの値が配列_excludelistに含まれていなかったらpkglistに追加する
172 if [[ ! $(printf '%s\n' "${_excludelist[@]}" | grep -qx "${_pkg}"; echo -n ${?} ) = 0 ]]; then
173 _pkglist=(${_pkglist[@]} "${_pkg}")
178 #-- excludeされたパッケージを表示 --#
179 if [[ -n "${_excludelist[*]}" ]]; then
180 msg_debug "The following packages have been removed from the installation list."
181 msg_debug "Excluded packages: ${_excludelist[*]}"
184 # Sort the list of packages in abc order.
185 _pkglist=($(for _pkg in ${_pkglist[@]}; do echo "${_pkg}"; done | sort | perl -pe 's/\n/ /g'))
187 echo "${_pkglist[@]}" >&1