3 script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && cd .. && pwd )"
6 ## Current official channel
11 ## Scheduled to discontinue distribution
15 ## They are unstable channel
21 architectures=("x86_64" "i686")
22 locale_list=("ja" "en")
24 default_options=("--boot-splash" "--cleanup" "--user" "alter" "--password" "alter" "--log")
28 work_dir="${script_path}/work"
29 out_dir="${script_path}/out"
38 # Message common function
39 # msg_common [type] [-n] [string]
41 local _msg_opts=("-a" "fullbuild" "-s" "5") _type="${1}"
43 [[ "${1}" = "-n" ]] && _msg_opts+=("-o" "-n") && shift 1
44 [[ "${nocolor}" = true ]] && _msg_opts+=("-n")
45 _msg_opts+=("${_type}" "${@}")
46 "${script_path}/tools/msg.sh" "${_msg_opts[@]}"
49 # Show an INFO message
50 # ${1}: message string
51 msg_info() { msg_common info "${@}"; }
53 # Show an Warning message
54 # ${1}: message string
55 msg_warn() { msg_common warn "${@}"; }
57 # Show an ERROR message then exit with status
58 # ${1}: message string
59 # ${2}: exit code number (with 0 does not exit)
61 msg_common error "${1}"
62 [[ -n "${2:-}" ]] && exit "${2}"
70 msg_error "fullbuild.sh has been killed by the user."
76 local _exit_code=0 _options=("${share_options[@]}")
78 _options+=("--arch" "${arch}" "--lang" "${lang}" "--out" "${out_dir}/${cha}/${lang}" "${cha}")
80 if [[ "${simulation}" = false ]] && [[ "${remove_cache}" = true ]]; then
81 msg_info "Removing package cache for ${arch}"
82 sudo rm -rf "${work_dir}/cache/${arch}"
85 if [[ ! -e "${fullbuild_dir}/fullbuild.${cha}_${arch}_${lang}" ]]; then
86 if [[ "${simulation}" = true ]]; then
87 echo "sudo bash build.sh ${_options[*]}"
90 msg_info "Build the ${lang} version of ${cha} on the ${arch} architecture."
91 sudo bash "${script_path}/build.sh" "${_options[@]}"
93 if (( _exit_code == 0 )); then
94 touch "${fullbuild_dir}/fullbuild.${cha}_${arch}_${lang}"
95 elif (( "${retry_count}" == "${retry}" )); then
96 msg_error "Failed to build (Exit code: ${_exit_code})"
97 if [[ "${abort}" = true ]]; then
100 failed+=("${cha}-${arch}-${lang}")
103 msg_error "build.sh finished with exit code ${_exit_code}. Will try again."
108 msg_info "Found: ${fullbuild_dir}/fullbuild.${cha}_${arch}_${lang}"
113 echo "usage ${0} [options] [channel]"
115 echo " General options:"
116 echo " -a <options> Set other options in build.sh"
117 echo " -c Build all channel (DO NOT specify the channel !!)"
118 echo " -d Use the default build.sh arguments. (${default_options[*]})"
119 echo " -e Exit the script when the build fails"
120 echo " -g Use gitversion"
121 echo " -h | --help This help message"
122 echo " -l <locale> Set the locale to build"
123 echo " -m <architecture> Set the architecture to build"
124 echo " -o <dir> Set the out dir"
125 echo " -r <interer> Set the number of retries"
126 echo " Defalut: ${retry}"
127 echo " -s Enable simulation mode"
128 echo " -t Build the tarball as well"
129 echo " -w <dir> Set the work dir"
131 echo " --remove-cache Clear cache for all packages on every build"
132 echo " --noconfirm Run without confirmation"
134 echo " !! WARNING !!"
135 echo " Do not set channel or architecture with -a."
136 echo " Be sure to enclose the build.sh argument with '' to avoid mixing it with the fullbuild.sh argument."
137 echo " Example: ${0} -a '-b -k zen'"
139 echo "Run \"build.sh -h\" for channel details."
141 "${script_path}/tools/channel.sh" show
144 share_options+=("--noconfirm")
148 OPTS=("a:" "d" "e" "g" "h" "r:" "s" "c" "t" "m:" "l:" "w:" "o:")
149 OPTL=("help" "remove-cache" "noconfirm")
150 if ! OPT=$(getopt -o "$(printf "%s," "${OPTS[@]}")" -l "$(printf "%s," "${OPTL[@]}")" -- "${ARGUMENT[@]}"); then
154 unset OPT OPTS OPTL ARGUMENT
159 IFS=" " read -r -a share_options <<< "${2}"
167 share_options+=("${default_options[@]}")
175 IFS=" " read -r -a architectures <<< "${2}"
183 if [[ ! -d "${script_path}/.git" ]]; then
184 msg_error "There is no git directory. You need to use git clone to use this feature."
187 share_options+=("--gitversion")
200 share_options+=("--tarball")
203 IFS=" " read -r -a locale_list <<< "${2}"
237 if [[ "${all_channel}" = true ]]; then
238 if [[ -n "${*}" ]]; then
239 msg_error "Do not specify the channel." "1"
241 readarray -t channels < <("${script_path}/tools/channel.sh" -b show)
243 elif [[ -n "${*}" ]]; then
247 if [[ "${simulation}" = true ]]; then
251 if [[ "${customized_work}" = false ]]; then
253 source "${script_path}/default.conf"
254 if [[ -f "${script_path}/custom.conf" ]]; then
255 source "${script_path}/custom.conf"
257 if [[ "${work_dir:0:1}" = "/" ]]; then
258 echo -n "${work_dir}"
260 echo -n "${script_path}/${work_dir}"
265 fullbuild_dir="${work_dir}/fullbuild"
266 mkdir -p "${fullbuild_dir}"
268 if [[ "$(find "${fullbuild_dir}" -maxdepth 1 -mindepth 1 -name "fullbuild.*" 2> /dev/null)" ]] && [[ "${noconfirm}" = false ]]; then
269 msg_info "Do you want to reset lock files ? (y/N)"
270 read -r -n 1 _yes_or_no
272 if [[ "${_yes_or_no}" = "y" ]] || [[ "${_yes_or_no}" = "Y" ]]; then
273 find "${fullbuild_dir}" -maxdepth 1 -mindepth 1 -name "fullbuild.*" -delete 2> /dev/null
278 share_options+=("--work" "${work_dir}")
279 msg_info "Options: ${share_options[*]}"
280 if [[ "${noconfirm}" = false ]]; then
281 msg_info "Press Enter to continue or Ctrl + C to cancel."
286 trap 'trap_exit' 1 2 3 15
288 for arch in "${architectures[@]}"; do
289 for cha in "${channels[@]}"; do
290 for lang in "${locale_list[@]}"; do
291 for retry_count in $(seq 1 "${retry}"); do
292 if grep -h -v ^'#' "${script_path}/channels/${cha}/architecture" | grep -x "${arch}" 1> /dev/null 2>&1; then
301 if [[ "${simulation}" = false ]]; then
302 if (( "${#failed[@]}" == 0 )); then
303 msg_info "All editions have been built"
305 msg_error "Build of the following settings failed"
306 printf " - %s\n" "${failed[@]}"