diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 4b5dd898b..000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,71 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -name: "CodeQL" - -on: - push: - branches: [dev, dev-stable, master] - pull_request: - # The branches below must be a subset of the branches above - branches: [dev] - schedule: - - cron: '0 17 * * 2' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - # Override automatic language detection by changing the below list - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['cpp', 'python'] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/codescan-analysis.yml b/.github/workflows/codescan-analysis.yml deleted file mode 100644 index edfd2f2d8..000000000 --- a/.github/workflows/codescan-analysis.yml +++ /dev/null @@ -1,35 +0,0 @@ -# This workflow requires that you have an existing account with codescan.io -# For more information about configuring your workflow, -# read our documentation at https://github.com/codescan-io/codescan-scanner-action -name: CodeScan - -on: - push: - branches: [master, main] - pull_request: - # The branches below must be a subset of the branches above - branches: [master, main] - -jobs: - CodeScan: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Cache files - uses: actions/cache@v2 - with: - path: | - ~/.sonar - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Run Analysis - uses: codescan-io/codescan-scanner-action@master - with: - login: ${{ secrets.CODESCAN_AUTH_TOKEN }} - organization: ${{ secrets.CODESCAN_ORGANIZATION_KEY }} - projectKey: ${{ secrets.CODESCAN_PROJECT_KEY }} - - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@v1 - with: - sarif_file: codescan.sarif diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 000000000..6a7a5f8fb --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,34 @@ +# This is a basic workflow to help you get started with Actions + +name: ShellCheck CL + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the dev branch + push: + branches: [ dev ] + pull_request: + branches: [ dev ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Runs a single command using the runners shell + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + severity: error + env: + SHELLCHECK_OPTS: --shell=bash diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b50bcdc2e..000000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: shell -sudo: required -addons: - apt: - packages: - - ninja - - cmake - - clang - - qtbase5-dev -script: - - bash -c 'shopt -s globstar nullglob; shellcheck -s bash --exclude=SC2068 -S error **/*.{sh,ksh,bash}' - - bash -c 'shopt -s globstar nullglob; shellcheck -s bash --exclude=SC2068 -S error tools/*.{sh,ksh,bash}' -git: - submodules: false - language: bash diff --git a/build.sh b/build.sh index d2f4c5f69..8340fb106 100755 --- a/build.sh +++ b/build.sh @@ -32,7 +32,7 @@ alteriso_version="3.1" # Load config file [[ ! -f "${defaultconfig}" ]] && "${tools_dir}/msg.sh" -a 'build.sh' error "${defaultconfig} was not found." && exit 1 for config in "${defaultconfig}" "${script_path}/custom.conf"; do - [[ -f "${script_path}/${config}.conf" ]] && source "${script_path}/${config}.conf" + [[ -f "${config}" ]] && source "${config}" done umask 0022 @@ -424,7 +424,7 @@ prepare_build() { local module_check module_check(){ msg_debug "Checking ${1} module ..." - ! bash "${tools_dir}/module.sh" check "${1}" && msg_error "Module ${1} is not available." "1"; + bash "${tools_dir}/module.sh" check "${1}" || msg_error "Module ${1} is not available." "1"; } modules=($(printf "%s\n" "${modules[@]}" | awk '!a[$0]++')) for_module "module_check {}" @@ -600,10 +600,10 @@ make_pkgbuild() { # Customize installation (airootfs) make_customize_airootfs() { # Overwrite airootfs with customize_airootfs. - local _airootfs _airootfs_script_options _script _script_list _airootfs_list _main_script + local _airootfs _airootfs_script_options _script _script_list _airootfs_list=() _main_script - _airootfs_list=("${channel_dir}/airootfs.any" "${channel_dir}/airootfs.${arch}") - for_module '_airootfs_list=("${_airootfs_list[@]}" "${module_dir}/{}/airootfs.any" "${module_dir}/{}/airootfs.${arch}")' + for_module '_airootfs_list+=("${module_dir}/{}/airootfs.any" "${module_dir}/{}/airootfs.${arch}")' + _airootfs_list+=("${channel_dir}/airootfs.any" "${channel_dir}/airootfs.${arch}") for _airootfs in "${_airootfs_list[@]}";do if [[ -d "${_airootfs}" ]]; then diff --git a/channels/cinnamon/airootfs.any/etc/lightdm/lightdm.conf.d/02-autologin-session.conf b/channels/cinnamon/airootfs.any/etc/lightdm/lightdm.conf.d/02-autologin-session.conf new file mode 100644 index 000000000..141172b02 --- /dev/null +++ b/channels/cinnamon/airootfs.any/etc/lightdm/lightdm.conf.d/02-autologin-session.conf @@ -0,0 +1,2 @@ +[Seat:*] +autologin-session=cinnamon2d diff --git a/channels/i3/airootfs.any/etc/lightdm/lightdm.conf.d/02-autologin-session.conf b/channels/i3/airootfs.any/etc/lightdm/lightdm.conf.d/02-autologin-session.conf new file mode 100644 index 000000000..4632526a0 --- /dev/null +++ b/channels/i3/airootfs.any/etc/lightdm/lightdm.conf.d/02-autologin-session.conf @@ -0,0 +1,2 @@ +[Seat:*] +autologin-session=i3 diff --git a/channels/i3/airootfs.any/etc/skel/.config/rofi/power.sh b/channels/i3/airootfs.any/etc/skel/.config/rofi/power.sh index e6b249c7a..76fdb36af 100755 --- a/channels/i3/airootfs.any/etc/skel/.config/rofi/power.sh +++ b/channels/i3/airootfs.any/etc/skel/.config/rofi/power.sh @@ -22,7 +22,7 @@ declare -A menu_list=( function main() { local -r IFS=$'\n' - [[ $# -ne 0 ]] && eval "${menu_list[$1]}" || echo "${!menu_list[*]}" + [[ "${#}" -ne 0 ]] && eval "${menu_list[$1]}" || echo "${!menu_list[*]}" } -main $@ +main "${@}" diff --git a/modules/lightdm/airootfs.any/root/customize_airootfs_lightdm.sh b/modules/lightdm/airootfs.any/root/customize_airootfs_lightdm.sh index 843567d4c..ee6e9c45b 100755 --- a/modules/lightdm/airootfs.any/root/customize_airootfs_lightdm.sh +++ b/modules/lightdm/airootfs.any/root/customize_airootfs_lightdm.sh @@ -20,7 +20,7 @@ sed -i "s|%USERNAME%|${username}|g" "/etc/lightdm/lightdm.conf.d/02-autologin.co # Session list -if cat "/etc/lightdm/lightdm.conf.d/02-autologin-session.conf" | grep "%SESSION%" 1> /dev/null 2>&1; then +if [[ -f "/etc/lightdm/lightdm.conf.d/02-autologin-session.conf" ]] && cat "/etc/lightdm/lightdm.conf.d/02-autologin-session.conf" | grep "%SESSION%" 1> /dev/null 2>&1; then session_list=() while read -r session; do session_list+=("${session}") @@ -32,6 +32,10 @@ if cat "/etc/lightdm/lightdm.conf.d/02-autologin-session.conf" | grep "%SESSION% elif (( "${#session_list[@]}" == 0)); then echo "Warining: Auto login session was not found" else - remove "/etc/lightdm/lightdm.conf.d/02-autologin-session.conf" + echo "Failed to set the session.Multiple sessions were found." >&2 + echo "Please set the session of automatic login in /etc/lightdm/lightdm.conf.d/02-autologin-session.conf" + echo "Found session: $(printf "%s " "${session_list[@]}")" + sleep 0.5 + exit 1 fi fi diff --git a/system/aur.sh b/system/aur.sh index 588a9d8f4..ca8dac426 100755 --- a/system/aur.sh +++ b/system/aur.sh @@ -9,7 +9,7 @@ set -e -u aur_username="aurbuild" -pacman_debug=true +pacman_debug=false pacman_args=() trap 'exit 1' 1 2 3 15 diff --git a/system/pkgbuild.sh b/system/pkgbuild.sh index 852534b51..4a2cd33d9 100755 --- a/system/pkgbuild.sh +++ b/system/pkgbuild.sh @@ -9,7 +9,7 @@ set -e build_username="pkgbuild" -pacman_debug=true +pacman_debug=false pacman_args=() _help() { @@ -66,7 +66,7 @@ function user_check () { # 一般ユーザーで実行します function run_user () { - sudo -u "${build_username}" ${@} + sudo -u "${build_username}" "${@}" } # 引数を確認 @@ -106,12 +106,12 @@ pacman -Syy "${pacman_args[@]}" cd "${pkgbuild_dir}" pkgbuild_dirs=($(ls "${pkgbuild_dir}" 2> /dev/null)) if (( "${#pkgbuild_dirs[@]}" != 0 )); then - for _dir in ${pkgbuild_dirs[@]}; do + for _dir in "${pkgbuild_dirs[@]}"; do cd "${_dir}" depends=($(source "${pkgbuild_dir}/${_dir}/PKGBUILD"; echo "${depends[@]}")) makedepends=($(source "${pkgbuild_dir}/${_dir}/PKGBUILD"; echo "${makedepends[@]}")) if (( ${#depends[@]} + ${#makedepends[@]} != 0 )); then - for _pkg in ${depends[@]} ${makedepends[@]}; do + for _pkg in "${depends[@]}" "${makedepends[@]}"; do if pacman -Ssq "${_pkg}" | grep -x "${_pkg}" 1> /dev/null; then pacman -S --asdeps --needed "${pacman_args[@]}" "${_pkg}" fi diff --git a/tools/README.md b/tools/README.md index a427d40c6..97eae5386 100644 --- a/tools/README.md +++ b/tools/README.md @@ -7,6 +7,9 @@ Alter Linuxのビルドに使用する処理をコマンド化したものです 全てのチャンネルのパッケージの一覧を表示します。 `channel.sh`でチャンネルの一覧を取得後、`pkglist.sh`でパッケージ一覧を取得します。 +## alteriso-info.sh +ビルド情報を書いたテキストファイルを出力します。詳細は`alteiso-info.sh`を実行してください。 + ## build_helper.py GUIのビルドヘルパーです。PyGobjectが必要です。 @@ -43,6 +46,10 @@ menuconfigで使用されるスクリプトです。 ## menuconf-to-alterconf.sh menuconfigで使用されるスクリプトです。 +## module.sh +使用可能なモジュールの一覧や確認を行います。 +詳細は`module.sh -h`を実行してください。 + ## msg.sh ラベルと色がついたメッセージを出力します。このスクリプトは様々な場所から呼び出されます。 詳細は`msg.sh -h`を実行してください。 @@ -52,7 +59,7 @@ menuconfigで使用されるスクリプトです。 `build.sh`の依存関係チェックに使用されています。 詳細は`package.py -h`を実行してください。 -## pkglist.py +## pkglist.sh 指定されたチャンネルのパッケージ一覧を取得します。 詳細は`pkglist.sh`を実行してください。 @@ -60,6 +67,11 @@ menuconfigで使用されるスクリプトです。 `allpkglist.sh`で全てのパッケージ一覧を取得後、そのパッケージが公式リポジトリから利用可能かどうかを調べます。 詳細は`testpkg.sh`を実行してください。 +## umount.sh +指定されたディレクトリ以下のマウントポイントを検索してアンマウントします。 +`build.sh`や`clean.sh`から呼び出されます。 +詳細は`umount.sh`を実行してください。 + ## wizard.sh CLIの対話型のビルド設定ツールです。英語と日本語に対応しています。 依存パッケージの自動インストールやキーリングの自動インストールを行います。 diff --git a/tools/allpkglist.sh b/tools/allpkglist.sh index c58fe0512..110f1d8b8 100755 --- a/tools/allpkglist.sh +++ b/tools/allpkglist.sh @@ -4,7 +4,7 @@ set -e load_config() { local _file - for _file in ${@}; do + for _file in "${@}"; do if [[ -f "${_file}" ]]; then source "${_file}" fi @@ -79,7 +79,7 @@ fi load_config() { local _file - for _file in ${@}; do + for _file in "${@}"; do if [[ -f "${_file}" ]]; then source "${_file}" fi @@ -88,12 +88,12 @@ load_config() { for_module(){ local module - for module in ${modules[@]}; do - eval $(echo ${@} | sed "s|{}|${module}|g") + for module in "${modules[@]}"; do + eval $(echo "${@}" | sed "s|{}|${module}|g") done } -for arch in ${archs[@]}; do +for arch in "${archs[@]}"; do for channel in $("${tools_dir}/channel.sh" show -a "${arch}" -b -d -k zen -f); do modules=($( load_config "${script_path}/default.conf" "${script_path}/custom.conf" @@ -105,7 +105,7 @@ for arch in ${archs[@]}; do modules=("share") fi fi - for module in ${modules[@]}; do + for module in "${modules[@]}"; do dependent="${module_dir}/${module}/dependent" if [[ -f "${dependent}" ]]; then modules+=($(grep -h -v ^'#' "${dependent}" | tr -d "\n" )) diff --git a/tools/alteriso-info.sh b/tools/alteriso-info.sh index 6b0c327ce..9b5ed064a 100755 --- a/tools/alteriso-info.sh +++ b/tools/alteriso-info.sh @@ -97,7 +97,7 @@ variable_list=( "iso_version" ) -for var in ${variable_list[@]}; do +for var in "${variable_list[@]}"; do if [[ -z "$(eval echo '$'${var})" ]]; then echo "${var} is empty" >&2 exit 1 diff --git a/tools/channel.sh b/tools/channel.sh index b4e816885..43ad180ed 100755 --- a/tools/channel.sh +++ b/tools/channel.sh @@ -237,10 +237,10 @@ else fi case "${mode}" in - "check" ) check ${@} ;; + "check" ) check "${@}" ;; "show" ) show ;; - "desc" ) desc ${@} ;; - "ver" ) get_alteriso_version ${@} ;; + "desc" ) desc "${@}" ;; + "ver" ) get_alteriso_version "${@}" ;; "help" ) _help; exit 0 ;; * ) _help; exit 1 ;; esac diff --git a/tools/clean.sh b/tools/clean.sh index 0b22d7744..c8a901cfe 100755 --- a/tools/clean.sh +++ b/tools/clean.sh @@ -4,6 +4,7 @@ set -eu script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && cd .. && pwd )" work_dir="${script_path}/work" +tools_dir="${script_path}/tools" debug=false only_work=false noconfirm=false @@ -13,7 +14,7 @@ noconfirm=false # load_config [file1] [file2] ... load_config() { local _file - for _file in ${@}; do + for _file in "${@}"; do if [[ -f "${_file}" ]]; then source "${_file}" fi @@ -90,22 +91,7 @@ _umount() { if mountpoint -q "${1}"; then umount -lf "${1}"; fi; } # Unmount chroot dir umount_chroot () { - local _mount - if [[ ! -v "work_dir" ]] || [[ "${work_dir}" = "" ]]; then - msg_error "Exception error about working directory" 1 - fi - if [[ ! -d "${work_dir}" ]]; then - return 0 - fi - for _mount in $(find "${work_dir}" -mindepth 1 -type d -printf "%p\0" | xargs -0 -I{} bash -c "mountpoint -q {} && echo {}" | tac); do - if echo "${_mount}" | grep "${work_dir}" > /dev/null 2>&1 || echo "${_mount}" | grep "${script_path}" > /dev/null 2>&1 || echo "${_mount}" | grep "${out_dir}" > /dev/null 2>&1; then - msg_info "Unmounting ${_mount}" - _umount "${_mount}" 2> /dev/null - else - msg_error "It is dangerous to unmount a directory that is not managed by the script." - msg_error "Path: ${_mount}" - fi - done + "${tools_dir}/umount.sh" "${work_dir}" } # Usage: getclm @@ -168,9 +154,7 @@ fi umount_chroot if [[ "${only_work}" = false ]]; then remove "${script_path}/menuconfig/build/"** - remove "${script_path}/system/cpp-src/mkalteriso/build"/** remove "${script_path}/menuconfig-script/kernel_choice" - remove "${script_path}/system/mkalteriso" fi remove "${work_dir%/}"/** diff --git a/tools/fullbuild.sh b/tools/fullbuild.sh index febed3348..3ff178889 100755 --- a/tools/fullbuild.sh +++ b/tools/fullbuild.sh @@ -15,6 +15,8 @@ architectures=("x86_64" "i686") locale_list=("ja" "en") share_options=() default_options=("--boot-splash" "--cleanup" "--user" "alter" "--password" "alter") +failed=() +abort=false work_dir="${script_path}/work" simulation=false @@ -25,62 +27,39 @@ all_channel=false customized_work=false noconfirm=false -# Show an INFO message -# $1: message string -msg_info() { - local _msg_opts="-a fullbuilid -s 5" - if [[ "${1}" = "-n" ]]; then - _msg_opts="${_msg_opts} -o -n" - shift 1 - fi - "${script_path}/tools/msg.sh" ${_msg_opts} info "${1}" +# Message common function +# msg_common [type] [-n] [string] +msg_common(){ + local _msg_opts=("-a" "fullbuild" "-s" "5") _type="${1}" + shift 1 + [[ "${1}" = "-n" ]] && _msg_opts+=("-o" "-n") && shift 1 + [[ "${nocolor}" = true ]] && _msg_opts+=("-n") + _msg_opts+=("${_type}" "${@}") + "${script_path}/tools/msg.sh" "${_msg_opts[@]}" } -# Show an Warning message -# $1: message string -msg_warn() { - local _msg_opts="-a fullbuilid -s 5" - if [[ "${1}" = "-n" ]]; then - _msg_opts="${_msg_opts} -o -n" - shift 1 - fi - "${script_path}/tools/msg.sh" ${_msg_opts} warn "${1}" -} +# Show an INFO message +# ${1}: message string +msg_info() { msg_common info "${@}"; } -# Show an debug message -# $1: message string -msg_debug() { - if [[ "${debug}" = true ]]; then - local _msg_opts="-a fullbuilid -s 5" - if [[ "${1}" = "-n" ]]; then - _msg_opts="${_msg_opts} -o -n" - shift 1 - fi - "${script_path}/tools/msg.sh" ${_msg_opts} debug "${1}" - fi -} +# Show an Warning message +# ${1}: message string +msg_warn() { msg_common warn "${@}"; } # Show an ERROR message then exit with status -# $1: message string -# $2: exit code number (with 0 does not exit) +# ${1}: message string +# ${2}: exit code number (with 0 does not exit) msg_error() { - local _msg_opts="-a fullbuilid -s 5" - if [[ "${1}" = "-n" ]]; then - _msg_opts="${_msg_opts} -o -n" - shift 1 - fi - "${script_path}/tools/msg.sh" ${_msg_opts} error "${1}" - if [[ -n "${2:-}" ]]; then - exit ${2} - fi + msg_common error "${1}" + [[ -n "${2:-}" ]] && exit "${2}" } trap_exit() { - local status=${?} + local status="${?}" echo msg_error "fullbuild.sh has been killed by the user." - exit ${status} + exit "${status}" } @@ -90,7 +69,8 @@ build() { _options+=("--arch" "${arch}" "--lang" "${lang}" "${cha}") if [[ "${simulation}" = false ]] && [[ "${remove_cache}" = true ]]; then - sudo pacman -Sccc --noconfirm + msg_info "Removing package cache for ${arch}" + sudo rm -rf "${work_dir}/cache/${arch}" fi if [[ ! -e "${fullbuild_dir}/fullbuild.${cha}_${arch}_${lang}" ]]; then @@ -105,7 +85,11 @@ build() { touch "${fullbuild_dir}/fullbuild.${cha}_${arch}_${lang}" elif (( "${retry_count}" == "${retry}" )); then msg_error "Failed to build (Exit code: ${_exit_code})" - exit "${_exit_code}" + if [[ "${abort}" = true ]]; then + exit "${_exit_code}" + else + failed+=("${cha}-${arch}-${lang}") + fi else msg_error "build.sh finished with exit code ${_exit_code}. Will try again." fi @@ -121,6 +105,7 @@ _help() { echo " -a Set other options in build.sh" echo " -c Build all channel (DO NOT specify the channel !!)" echo " -d Use the default build.sh arguments. (${default_options[*]})" + echo " -e Exit the script when the build fails" echo " -g Use gitversion" echo " -h | --help This help message" echo " -l Set the locale to build" @@ -148,7 +133,7 @@ share_options+=("--noconfirm") # Parse options ARGUMENT=("${@}") -OPTS="a:dghr:sctm:l:w:" +OPTS="a:deghr:sctm:l:w:" OPTL="help,remove-cache,noconfirm" if ! OPT=$(getopt -o ${OPTS} -l ${OPTL} -- "${ARGUMENT[@]}"); then exit 1 @@ -157,7 +142,7 @@ eval set -- "${OPT}" unset OPT OPTS OPTL ARGUMENT while true; do - case ${1} in + case "${1}" in -a) share_options+=(${2}) shift 2 @@ -170,6 +155,10 @@ while true; do share_options+=("${default_options[@]}") shift 1 ;; + -e) + abort=true + shift 1 + ;; -m) architectures=(${2}) shift 2 @@ -236,7 +225,7 @@ if [[ "${all_channel}" = true ]]; then channnels=($("${script_path}/tools/channel.sh" -b show)) fi elif [[ -n "${*}" ]]; then - channnels=(${@}) + channnels=("${@}") fi if [[ "${simulation}" = true ]]; then @@ -271,16 +260,11 @@ fi trap 'trap_exit' 1 2 3 15 -if [[ "${simulation}" = false ]]; then - msg_info "Update the package database." - sudo pacman -Syy -fi - -for arch in ${architectures[@]}; do - for cha in ${channnels[@]}; do - for lang in ${locale_list[@]}; do - for retry_count in $(seq 1 ${retry}); do - if [[ -n $(cat "${script_path}/channels/${cha}/architecture" | grep -h -v ^'#' | grep -x "${arch}") ]]; then +for arch in "${architectures[@]}"; do + for cha in "${channnels[@]}"; do + for lang in "${locale_list[@]}"; do + for retry_count in $(seq 1 "${retry}"); do + if [[ -n "$(cat "${script_path}/channels/${cha}/architecture" | grep -h -v ^'#' | grep -x "${arch}")" ]]; then build fi done @@ -290,5 +274,10 @@ done if [[ "${simulation}" = false ]]; then - msg_info "All editions have been built" + if (( "${#failed[@]}" == 0 )); then + msg_info "All editions have been built" + else + msg_error "Build of the following settings failed" + printf " - %s\n" "${failed[@]}" + fi fi diff --git a/tools/kernel-choice-conf-gen.sh b/tools/kernel-choice-conf-gen.sh index 321474291..9aedee60f 100755 --- a/tools/kernel-choice-conf-gen.sh +++ b/tools/kernel-choice-conf-gen.sh @@ -6,25 +6,9 @@ arch_list=( "i686" ) -# rm helper -# Delete the file if it exists. -# For directories, rm -rf is used. -# If the file does not exist, skip it. -# remove ... -remove() { - local _list=($(echo "$@")) _file - for _file in "${_list[@]}"; do - if [[ -f "${_file}" ]]; then - rm -f "${_file}" - elif [[ -d "${_file}" ]]; then - rm -rf "${_file}" - fi - done -} - #cd "${script_path}" -for arch in ${arch_list[@]}; do - remove "${script_path}/menuconfig-script/kernel_choice_${arch}" +for arch in "${arch_list[@]}"; do + rm -rf "${script_path}/menuconfig-script/kernel_choice_${arch}" for kernel in $(bash "${script_path}/tools/kernel.sh" -a "${arch}" show ); do echo "config KERNEL_N_A_M_E_${kernel}" >> "${script_path}/menuconfig-script/kernel_choice_${arch}" echo -e "\tbool ${kernel}" >> "${script_path}/menuconfig-script/kernel_choice_${arch}" diff --git a/tools/kernel.sh b/tools/kernel.sh index 077cb411f..a8029fdfa 100755 --- a/tools/kernel.sh +++ b/tools/kernel.sh @@ -101,7 +101,7 @@ get() { _kernel_name_list=($(cat "${_kernel_config_file}" | grep -h -v ^'#' | getclm 1)) _get_kernel_line() { local _kernel _count=0 - for _kernel in ${_kernel_name_list[@]}; do + for _kernel in "${_kernel_name_list[@]}"; do _count=$(( _count + 1 )) if [[ "${_kernel}" = "${1}" ]]; then echo "${_count}"; return 0; fi done @@ -175,9 +175,9 @@ else fi case "${mode}" in - "check" ) check ${@} ;; + "check" ) check "${@}" ;; "show" ) show ;; - "get" ) get ${@} ;; + "get" ) get "${@}" ;; "help" ) _help; exit 0 ;; * ) _help; exit 1 ;; esac diff --git a/tools/keyring.sh b/tools/keyring.sh index 7fbbf3b3a..f95ee7cab 100755 --- a/tools/keyring.sh +++ b/tools/keyring.sh @@ -171,7 +171,7 @@ checkpkg() { run() { msg_info "Running ${*}" - ${@} + eval "${@}" } diff --git a/tools/locale.sh b/tools/locale.sh index b91cf1da8..71ccca7ba 100755 --- a/tools/locale.sh +++ b/tools/locale.sh @@ -90,13 +90,13 @@ get() { _locale_name_list=($(cat "${_locale_config_file}" | grep -h -v ^'#' | awk '{print $1}')) _get_locale_line_number() { local _lang _count=0 - for _lang in ${_locale_name_list[@]}; do + for _lang in "${_locale_name_list[@]}"; do _count=$(( _count + 1 )) if [[ "${_lang}" = "${1}" ]]; then echo "${_count}"; return 0; fi done echo -n "failed" } - _locale_line_number="$(_get_locale_line_number ${@})" + _locale_line_number="$(_get_locale_line_number "${@}")" # 不正なロケール名なら終了する if [[ "${_locale_line_number}" = "failed" ]]; then @@ -131,7 +131,7 @@ eval set -- "${OPT}" unset OPTS OPTL while true; do - case ${1} in + case "${1}" in -a | --arch) arch="${2}" shift 2 @@ -165,9 +165,9 @@ else fi case "${mode}" in - "check" ) check ${@} ;; + "check" ) check "${@}" ;; "show" ) show ;; - "get" ) get ${@} ;; + "get" ) get "${@}" ;; "help" ) _help; exit 0 ;; * ) _help; exit 1 ;; esac diff --git a/tools/pkglist.sh b/tools/pkglist.sh index 48373d55b..81cf07d44 100755 --- a/tools/pkglist.sh +++ b/tools/pkglist.sh @@ -44,8 +44,8 @@ _help() { # for_module for_module(){ local module - for module in ${modules[@]}; do - eval $(echo ${@} | sed "s|{}|${module}|g") + for module in "${modules[@]}"; do + eval $(echo "${@}" | sed "s|{}|${module}|g") done } @@ -183,7 +183,7 @@ fi #-- Read package list --# # Read the file and remove comments starting with # and add it to the list of packages to install. -for _file in ${_loadfilelist[@]}; do +for _file in "${_loadfilelist[@]}"; do if [[ -f "${_file}" ]]; then msg_debug "Loaded package file ${_file}" _pkglist=( ${_pkglist[@]} "$(grep -h -v ^'#' ${_file})" ) @@ -197,7 +197,7 @@ done _excludefile=("${channel_dir}/packages.${arch}/exclude" "${channel_dir}/packages_aur.${arch}/exclude") for_module '_excludefile+=("${module_dir}/{}/packages.${arch}/exclude" "${module_dir}/{}/packages_aur.${arch}/exclude")' -for _file in ${_excludefile[@]}; do +for _file in "${_excludefile[@]}"; do if [[ -f "${_file}" ]]; then _excludelist+=($(grep -h -v ^'#' "${_file}") ) fi diff --git a/tools/testpkg.sh b/tools/testpkg.sh index c88d2fc44..88c5036c1 100755 --- a/tools/testpkg.sh +++ b/tools/testpkg.sh @@ -89,7 +89,7 @@ done # パッケージ一覧 msg_debug "Getting package list ..." -for arch in ${archs[@]}; do +for arch in "${archs[@]}"; do packages+=($("${script_path}/tools/allpkglist.sh" -s -a "${arch}")) done @@ -98,7 +98,7 @@ msg_debug "Getting group list ..." group_list=($(curl -s https://archlinux.org/groups/ | grep "/groups/x86_64" | cut -d "/" -f 4)) # 実行開始 -for pkg in ${packages[@]}; do +for pkg in "${packages[@]}"; do msg_debug "Searching ${pkg} ..." if ! searchpkg "${pkg}"; then echo "${pkg} is not in the official repository." >&2 diff --git a/tools/umount.sh b/tools/umount.sh index a20ce566d..980091da1 100755 --- a/tools/umount.sh +++ b/tools/umount.sh @@ -19,6 +19,7 @@ tools_dir="${script_path}/tools/" debug=false nocolor=false force=false +maxdepth="2" _help() { echo "usage ${0} [options] [dir]" @@ -28,6 +29,7 @@ _help() { echo " General options:" echo " -f | --force Force umount (No warning)" echo " -d | --debug Enable debug message" + echo " -m | --maxdepth Specify the maximum hierarchy (set 0 to no limit)" echo " -h | --help This help message" } @@ -76,7 +78,8 @@ umount_work () { fi [[ ! -d "${target_dir}" ]] && return 0 while read -r _mount; do - if echo "${_mount}" | grep "${target_dir}" > /dev/null 2>&1 || [[ "${force}" = true ]]; then + if [[ "${force}" = true ]] || [[ "${_mount}" = "${target_dir}"* ]] > /dev/null 2>&1; then + msg_debug "Checking ${_mount}" if mountpoint -q "${_mount}"; then msg_info "Unmounting ${_mount}" _umount "${_mount}" 2> /dev/null @@ -84,7 +87,13 @@ umount_work () { else msg_error "It is dangerous to unmount a directory that is not managed by the script." fi - done < <(find "${target_dir}" -mindepth 1 -type d -printf "%p\n" | tac) + done < <( + if (( maxdepth == 0 )); then + find "${target_dir}" -mindepth 1 -type d -printf "%p\n" | tac + else + find "${target_dir}" -mindepth 1 -maxdepth "${maxdepth}" -type d -printf "%p\n" | tac + fi + ) } @@ -94,8 +103,8 @@ if (( ! "${EUID}" == 0 )); then fi # Parse options -OPTS=("dfh") -OPTL=("debug" "force" "help:") +OPTS=("d" "f" "h" "m:") +OPTL=("debug" "force" "help" "maxdepth:") if ! OPT=$(getopt -o "$(printf "%s," "${OPTS[@]}")" -l "$(printf "%s," "${OPTL[@]}")" -- "${@}"); then exit 1 fi @@ -114,6 +123,10 @@ while true; do force=true shift 1 ;; + -m | --maxdepth) + maxdepth="${2}" + shift 2 + ;; -h | --help) _usage exit 0 @@ -133,7 +146,7 @@ done if [[ -z "${1+SET}" ]]; then msg_error "Please specify the target directory." "1" else - target_dir="${1}" + target_dir="$(realpath "${1}")" fi umount_work diff --git a/tools/wizard.sh b/tools/wizard.sh index 13277ba07..f27fc4932 100755 --- a/tools/wizard.sh +++ b/tools/wizard.sh @@ -166,7 +166,7 @@ Function_Global_Main_check_required_files () { "default.conf" ) - for Var_Local_file in ${Var_Local_file_list[@]}; do + for Var_Local_file in "${Var_Local_file_list[@]}"; do if [[ ! -f "${Var_Global_Wizard_Env_script_path}/${Var_Local_file}" ]]; then msg_error "${Var_Local_file}が見つかりませんでした。" "${Var_Local_file} was not found." Var_Local_error=true @@ -199,9 +199,9 @@ Function_Global_Main_install_dependent_packages () { local Var_Local_package Var_Local_installed_package Var_Local_installed_version Var_Local_installed_package=($(pacman -Q | getclm 1)) Var_Local_installed_version=($(pacman -Q | getclm 2)) - for Var_Local_package in $(seq 0 $(( ${#Var_Local_installed_package[@]} - 1 ))); do - if [[ ${Var_Local_installed_package[${Var_Local_package}]} = ${1} ]]; then - if [[ ${Var_Local_installed_version[${Var_Local_package}]} = $(pacman -Sp --print-format '%v' --config "${Var_Global_Wizard_Env_pacman_conf}" ${1}) ]]; then + for Var_Local_package in $(seq 0 $(( "${#Var_Local_installed_package[@]}" - 1 ))); do + if [[ "${Var_Local_installed_package[${Var_Local_package}]}" = "${1}" ]]; then + if [[ "${Var_Local_installed_version[${Var_Local_package}]}" = $(pacman -Sp --print-format '%v' --config "${Var_Global_Wizard_Env_pacman_conf}" ${1}) ]]; then echo -n "true" return 0 else @@ -214,14 +214,14 @@ Function_Global_Main_install_dependent_packages () { return 0 } echo - for Var_Local_package in ${dependence[@]}; do + for Var_Local_package in "${dependence[@]}"; do msg "依存パッケージ ${Var_Local_package} を確認しています..." "Checking dependency package ${Var_Local_package} ..." if [[ $(Function_Local_checkpkg ${Var_Local_package}) = false ]]; then Var_Global_missing_packages+=(${Var_Local_package}) fi done if [[ -n "${Var_Global_missing_packages[*]}" ]]; then - yay -S --needed --config "${Var_Global_Wizard_Env_pacman_conf}" ${Var_Global_missing_packages[@]} + yay -S --needed --config "${Var_Global_Wizard_Env_pacman_conf}" "${Var_Global_missing_packages[@]}" fi echo } @@ -255,7 +255,7 @@ Function_Global_Main_run_keyring.sh () { Function_Global_Main_remove_dependent_packages () { if [[ -n "${Var_Global_missing_packages[*]}" ]]; then - sudo pacman -Rsn --config "${Var_Global_Wizard_Env_pacman_conf}" ${Var_Global_missing_packages[@]} + sudo pacman -Rsn --config "${Var_Global_Wizard_Env_pacman_conf}" "${Var_Global_missing_packages[@]}" fi } @@ -313,7 +313,7 @@ Function_Global_Ask_locale() { local Var_Local_locale_list Var_Local_locale Var_Local_count=1 Var_Local_input_locale Var_Local_locale_list=($("${Var_Global_Wizard_Env_script_path}/tools/locale.sh" -a "${Var_Global_Wizard_Option_build_arch}" show)) - for Var_Local_locale in ${Var_Local_locale_list[@]}; do + for Var_Local_locale in "${Var_Local_locale_list[@]}"; do ( local locale_name locale_gen_name locale_version locale_time locale_fullname eval $("${Var_Global_Wizard_Env_script_path}/tools/locale.sh" -a "${Var_Global_Wizard_Option_build_arch}" get "${Var_Local_locale}" ) @@ -328,7 +328,7 @@ Function_Global_Ask_locale() { set +e expr "${Var_Local_input_locale}" + 1 >/dev/null 2>&1 - if [[ ${?} -lt 2 ]]; then + if [[ "${?}" -lt 2 ]]; then set -e # 数字である Var_Local_input_locale=$(( Var_Local_input_locale - 1 )) @@ -562,7 +562,7 @@ Function_Global_Ask_kernel () { #選択肢の生成 local Var_Local_kernel Var_Local_count=1 Var_Local_int - for Var_Local_kernel in ${Var_Local_kernel_list[@]}; do + for Var_Local_kernel in "${Var_Local_kernel_list[@]}"; do ( local kernel kernel_filename kernel_mkinitcpio_profile eval $("${Var_Global_Wizard_Env_script_path}/tools/kernel.sh" -a "${Var_Global_Wizard_Option_build_arch}" get "${Var_Local_kernel}" ) @@ -616,7 +616,7 @@ Function_Global_Ask_channel () { msg "チャンネルを以下の番号から選択してください。" "Select a channel from the numbers below." # 選択肢を生成 - for Var_Local_channel in ${Var_Local_channel_list[@]}; do + for Var_Local_channel in "${Var_Local_channel_list[@]}"; do if [[ -f "${Var_Global_Wizard_Env_script_path}/channels/${Var_Local_channel_dir[$(( Var_Local_count - 1 ))]}/description.txt" ]]; then Var_Local_description=$(cat "${Var_Global_Wizard_Env_script_path}/channels/${Var_Local_channel_dir[$(( Var_Local_count - 1 ))]}/description.txt") else