5 script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && cd .. && pwd )"
6 share_dir="${script_path}/channels/share"
9 pkgdir_name="packages-repo"
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:,codename:,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 "${codename}" ]]; then
106 msg_error "codename not specified"
108 elif [[ -z "${locale_name}" ]]; then
109 msg_error "Locale not specified"
114 pkgdir_name="packages-repo"
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 # Plymouth package list
132 if [[ "${boot_splash}" = true ]]; then
134 $(ls ${share_dir}/${pkgdir_name}.${arch}/plymouth/*.${arch} 2> /dev/null)
135 $(ls ${channel_dir}/${pkgdir_name}.${arch}/plymouth/*.${arch} 2> /dev/null)
140 #-- Read package list --#
141 # Read the file and remove comments starting with # and add it to the list of packages to install.
142 for _file in ${_loadfilelist[@]}; do
143 if [[ -f "${_file}" ]]; then
144 msg_debug "Loaded package file ${_file}"
145 _pkglist=( ${_pkglist[@]} "$(grep -h -v ^'#' ${_file})" )
149 #-- Read exclude list --#
150 # Exclude packages from the share exclusion list
152 "${share_dir}/${pkgdir_name}.${arch}/exclude"
153 "${channel_dir}/${pkgdir_name}.${arch}/exclude"
156 for _file in ${_excludefile[@]}; do
157 if [[ -f "${_file}" ]]; then
158 _excludelist=( ${_excludelist[@]} $(grep -h -v ^'#' "${_file}") )
162 #-- excludeに記述されたパッケージを除外 --#
163 # _pkglistを_subpkglistにコピーしexcludeのパッケージを除外し再代入
164 _subpkglist=(${_pkglist[@]})
166 for _pkg in ${_subpkglist[@]}; do
167 # もし変数_pkgの値が配列_excludelistに含まれていなかったらpkglistに追加する
168 if [[ ! $(printf '%s\n' "${_excludelist[@]}" | grep -qx "${_pkg}"; echo -n ${?} ) = 0 ]]; then
169 _pkglist=(${_pkglist[@]} "${_pkg}")
174 #-- excludeされたパッケージを表示 --#
175 if [[ -n "${_excludelist[*]}" ]]; then
176 msg_debug "The following packages have been removed from the installation list."
177 msg_debug "Excluded packages: ${_excludelist[*]}"
180 # Sort the list of packages in abc order.
181 _pkglist=($(for _pkg in ${_pkglist[@]}; do echo "${_pkg}"; done | sort | perl -pe 's/\n/ /g'))
183 echo "${_pkglist[@]}" | sed -e "s/\${codename}/${codename}/g" >&1