7 # Email : hayao@fascode.net
9 # (c) 2019-2020 Fascode Network.
13 # Wfa is a multilingual AUR helper written in bash that is being developed to replace yaourt
17 # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
18 # Version 2, December 2004
20 # Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
22 # Everyone is permitted to copy and distribute verbatim or modified
23 # copies of this license document, and changing it is allowed as long
24 # as the name is changed.
26 # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
27 # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
29 # 0. You just DO WHAT THE FUCK YOU WANT TO.
36 ######################################################################################
40 ["Undefined operation"]="未定義のオペレーションです"
41 ["only one operation may be used at a time"]="一度に使用できるオペレーションは1つだけです"
42 ["Failed to set the argument of %s"]="%sの引数の設定に失敗しました"
43 ["Setting that command is not currently supported"]="そのコマンドの設定は現在サポートされていません"
44 ["Searching in AUR ..."]="AUR内を検索しています..."
45 ["No package with an exact name match was found"]="完全に一致する名前のパッケージが見つかりませんでした"
46 ["Select a package %s with an exact name match"]="名前が完全に一致するパッケージ %s を選択します"
47 ["Download PKGBUILD of %s"]="%s のPKGBUILDをダウンロード"
48 ["Get PKGBUILD from %s"]="%sからPKGBUILDを取得します"
49 ["PKGBUILD has already been downloaded"]="PKGBUILDは既にダウンロードされています"
50 ["Do you want to overwrite and download? [n] :"]="上書きダウンロードしますか? [n] :"
51 ["Unpacking the tarball of PKGBUILD ..."]="PKGBUILDを展開しています ..."
52 [".SRCINFO was not found.\nGenerating it using makepkg"]=".SCRINFOが見つかりませんでした。makepkgを使用して生成しています"
53 ["Conflict(s) was found"]="衝突が見つかりました"
54 ["Install dependent packages..."]="依存パッケージをインストールします..."
55 ["Found %s"]="%s を見つけました"
56 ["Packages to cleanBuild? [n] :"]="パッケージをクリーンビルドしますか? [n] :"
57 ["Could not find all required packages:\n %s"]="必要なすべてのパッケージが見つかりませんでした %s"
58 ["This is a feature that has not been implemented yet"]="まだ実装されていない機能です"
60 ["(Orphaned)"]="(メンテナ不在)"
61 ["[Installed]"]="[インストール済み]"
62 ["This is a feature that has not been implemented yet"]="まだ実装されていない機能です"
64 ######################################################################################
77 aururl="https://aur.archlinux.org/"
80 #-- options (bool) --#
95 makepkg_command="/usr/bin/makepkg"
97 makepkg_config="/etc/makepkg.conf"
103 pacman_command="/usr/bin/pacman"
105 pacman_config="/etc/pacman.conf"
111 git_command="/usr/bin/git"
117 gpg_command="/usr/bin/gpg"
123 sudo_command="/usr/bin/sudo"
129 ######################################################################################
134 # https://github.com/FascodeNet/alterlinux/blob/dev/tools/msg.sh の変数名にアンダーバーを追加し関数化
136 local OPTIND OPTARG arg
138 local _appname="msg.sh"
139 local _bash_debug=false
143 local _msg_type="info"
145 local _label_space="7"
146 local _adjust_chr=" "
147 local _customized_label=false
148 local _customized_label_color=false
150 local _noappname=false
151 local _noadjust=false
152 local _output="stdout"
155 echo "usage msg [option] [type] [message]"
157 echo "Display a message with a colored app name and message type label"
159 echo " General type:"
160 echo " info General message"
161 echo " warn Warning message"
162 echo " error Error message"
163 echo " debug Debug message"
165 echo " General options:"
166 echo " -a [name] Specify the app name"
167 echo " -c [character] Specify the character to adjust the label"
168 echo " -l [label] Specify the label."
169 echo " -n | --nocolor No output colored output"
170 echo " -o [option] Specify echo options"
171 echo " -r [color] Specify the color of label"
172 echo " -s [number] Specifies the label space."
173 echo " -x | --bash-debug Enables output bash debugging"
174 echo " -h | --help This help message"
176 echo " --nolabel Do not output label"
177 echo " --noappname Do not output app name"
178 echo " --noadjust Do not adjust the width of the label"
181 while getopts "a:c:l:no:r:s:xh-:" arg; do
187 _adjust_chr="${OPTARG}"
190 _customized_label=true
191 _msg_label="${OPTARG}"
197 _echo_opts="${OPTARG}"
200 _customized_label_color=true
232 _label_space="${OPTARG}"
273 shift $((OPTIND - 1))
298 # You can specify multiple decorations with ;.
299 # 0 => All attributs off (ノーマル)
301 # 4 => Underscore (下線)
303 # 7 => Reverse video on (色反転)
310 [[ "${_customized_label_color}" = false ]] && _labelcolor="32"
311 [[ "${_customized_label}" = false ]] && _msg_label="Info"
317 [[ "${_customized_label_color}" = false ]] && _labelcolor="33"
318 [[ "${_customized_label}" = false ]] && _msg_label="Warning"
324 [[ "${_customized_label_color}" = false ]] && _labelcolor="35"
325 [[ "${_customized_label}" = false ]] && _msg_label="Debug"
331 [[ "${_customized_label_color}" = false ]] && _labelcolor="31"
332 [[ "${_customized_label}" = false ]] && _msg_label="Error"
336 echo "Please specify the message type" >&2
340 echo "Unknown message type" >&2
345 _word_count="${#_msg_label}"
350 if [[ "${_nolabel}" = false ]]; then
351 if [[ "${_noadjust}" = false ]]; then
352 for __time in $( seq 1 $(( ${_label_space} - ${_word_count})) ); do
353 echo -ne "${_adjust_chr}"
356 if [[ "${_nocolor}" = false ]]; then
357 echo -ne "\e[$([[ -v _backcolor ]] && echo -n "${_backcolor}"; [[ -v _labelcolor ]] && echo -n ";${_labelcolor}"; [[ -v _decotypes ]] && echo -n ";${_decotypes}")m${_msg_label}\e[m "
359 echo -ne "${_msg_label} "
365 if [[ "${_noappname}" = false ]]; then
366 if [[ "${_nocolor}" = false ]]; then
367 echo -ne "\e[36m[${_appname}]\e[m "
369 echo -ne "[${_appname}] "
374 for _count in $(seq "1" "$(echo -ne "${_message}\n" | wc -l)"); do
375 _echo_message=$(echo -ne "${_message}\n" |head -n "${_count}" | tail -n 1 )
376 _full_message="$(echo_appname)$(echo_type)${_echo_message}"
379 echo ${_echo_opts} "${_full_message}" >&1
382 echo ${_echo_opts} "${_full_message}" >&2
385 echo ${_echo_opts} "${_full_message}" > ${_output}
397 local _locale="$(echo "${LANG}" | cut -d "." -f 1)"
401 local _translated_text="$(eval echo '$'{${_locale}[\"${*}\"]})"
403 if [[ -z "${_translated_text}" ]]; then
406 echo "${_translated_text}"
410 local _text _fulltext=() _main
412 if declare -p "${_locale}" 2> /dev/null 1>/dev/null; then
413 _main="$(_get_text ${1})"
418 echo "$(printf "${_main}" "${@}")"
420 _msg_translate "${@}"
425 # Show an INFO message
428 if [[ "${msgdebug}" = false ]]; then
431 local _msg_opts="-a ${wfa_name}"
432 if [[ "${1}" = "-n" ]]; then
433 _msg_opts="${_msg_opts} -o -n"
436 [[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x"
437 [[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n"
438 msg ${_msg_opts} info "$(translate "${@}")"
439 if [[ "${bash_debug}" = true ]]; then
444 # Show an Warning message
447 if [[ "${msgdebug}" = false ]]; then
450 local _msg_opts="-a ${wfa_name}"
451 if [[ "${1}" = "-n" ]]; then
452 _msg_opts="${_msg_opts} -o -n"
455 [[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x"
456 [[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n"
457 msg ${_msg_opts} warn "$(translate "${@}")"
458 if [[ "${bash_debug}" = true ]]; then
463 # Show an debug message
466 if [[ "${msgdebug}" = false ]]; then
469 if [[ "${debug}" = true ]]; then
470 local _msg_opts="-a ${wfa_name}"
471 if [[ "${1}" = "-n" ]]; then
472 _msg_opts="${_msg_opts} -o -n"
475 [[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x"
476 [[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n"
477 msg ${_msg_opts} debug "$(translate "${@}")"
479 if [[ "${bash_debug}" = true ]]; then
484 # Show an ERROR message then exit with status
486 # $2: exit code number (with 0 does not exit)
488 if [[ "${msgdebug}" = false ]]; then
491 local _msg_opts="-a ${wfa_name}"
492 if [[ "${1}" = "-n" ]]; then
493 _msg_opts="${_msg_opts} -o -n"
496 [[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x"
497 [[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n"
498 msg ${_msg_opts} error "$(translate "${@}")"
499 if [[ "${bash_debug}" = true ]]; then
505 local OPTIND OPTARG arg _textcolor _decotypes=() _message
506 while getopts "c:b" arg; do
544 shift $((OPTIND - 1))
547 _message="$(translate "${@}")"
548 if [[ "${nocolor}" = true ]]; then
551 echo -ne "\e[$([[ -v _textcolor ]] && echo -n ";${_textcolor}"; [[ -v _decotypes ]] && echo -n ";${_decotypes}")m${_message}\e[m"
555 ######################################################################################
560 # Delete the file if it exists.
561 # For directories, rm -rf is used.
562 # If the file does not exist, skip it.
563 # remove <file> <file> ...
565 local _list=($(echo "$@")) _file
566 for _file in "${_list[@]}"; do
567 msg_debug "Removing ${_file}"
568 if [[ -f "${_file}" ]]; then
570 elif [[ -d "${_file}" ]]; then
577 local _pacman_help=false
582 echo "${wfa_command}"
583 echo "${wfa_command} <operation> [...]"
586 echo " ${wfa_command} {-h --help}"
587 echo " ${wfa_command} {-V --version}"
588 #echo " ${wfa_command} {-D --database} <options> <package(s)>"
589 #echo " ${wfa_command} {-F --files} [options] [package(s)]"
590 echo " ${wfa_command} {-Q --query} [options] [package(s)]"
591 echo " ${wfa_command} {-R --remove} [options] <package(s)>"
592 echo " ${wfa_command} {-S --sync} [options] [package(s)]"
593 #echo " ${wfa_command} {-T --deptest} [options] [package(s)]"
594 #echo " ${wfa_command} {-U --upgrade} [options] <file(s)>"
596 #echo "New operations:"
597 #echo " ${wfa_command} {-P --show} [options]"
598 #echo " ${wfa_command} {-G --getpkgbuild} [package(s)]"
601 echo " --repo Assume targets are from the repositories"
602 echo " -a --aur Assume targets are from the AUR"
604 echo "Permanent configuration options:"
605 echo " --aururl <url> Set an alternative AUR URL"
606 echo " --makepkg <file> makepkg command to use"
607 echo " --mflags <flags> Pass arguments to makepkg"
608 echo " --pacman <file> pacman command to use"
609 echo " --git <file> git command to use"
610 echo " --gitflags <flags> Pass arguments to git"
611 echo " --gpg <file> gpg command to use"
612 echo " --gpgflags <flags> Pass arguments to gpg"
613 echo " --config <file> pacman.conf file to use"
614 echo " --makepkgconf <file> makepkg.conf file to use"
615 echo " --nomakepkgconf Use the default makepkg.conf"
619 local _wfa_usage_sync
621 echo "usage: ${wfa_command} {-S --sync} [options] [package(s)]"
623 echo " -b, --dbpath <path> set an alternate database location"
624 echo " -c, --clean remove old packages from cache directory (-cc for all)"
625 echo " -d, --nodeps skip dependency version checks (-dd to skip all checks)"
626 echo " -s, --search <regex> search remote repositories for matching strings"
627 echo " -u, --sysupgrade upgrade installed packages (-uu enables downgrades)"
628 echo " -y, --refresh download fresh package databases from the server"
629 echo " (-yy to force a refresh even if up to date)"
631 echo " --color <when> colorize the output"
632 echo " --config <path> set an alternate configuration file"
633 echo " --noconfirm do not ask for any confirmation"
634 echo " --debug display debug messages"
635 echo " --noconfirm do not ask for any confirmation"
639 if [[ "${operation}" = "none" ]]; then
641 elif [[ "${_pacman_help}" = true ]]; then
642 "${pacman_command}" -h --${operation}
643 elif [[ "$(type -t "_wfa_usage_${operation}" )" = "function" ]]; then
644 _wfa_usage_${operation}
646 msg_error "Undefined operation"
652 if [[ "${operation}" = "none" ]]; then
654 add_args pacman "--${operation}"
656 msg_error "only one operation may be used at a time"
662 if (( ${UID} == 0 )); then
670 run_sudo "${pacman_command}" ${@}
674 # https://github.com/FascodeNet/aptpac/blob/master/aptpac のADD_OPTION関数を参考
675 # Usage: add_args [pacman/makepkg] <args1> <args2>...
683 _args_array=(${makepkg_args})
685 makepkg_args=${_args_array[@]}
686 msg_debug "makepkg ARGS: ${makepkg_args}"
690 _args_array=(${pacman_args})
692 pacman_args=${_args_array[@]}
693 msg_debug "pacman ARGS: ${pacman_args}"
696 _args_array=(${mpg_args})
698 git_args=${_args_array[@]}
699 msg_debug "git ARGS: ${git_args}"
702 _args_array=(${gpg_args})
704 gpg_args=${_args_array[@]}
705 msg_debug "gpg ARGS: ${gpg_args}"
708 _args_array=(${sudo_args})
710 sudo_args=${_args_array[@]}
711 msg_debug "sudo ARGS: ${sudo_args}"
714 msg_error "Failed to set the argument of %s" "${_target}"
715 msg_error "Setting that command is not currently supported"
721 # 引数で指定されたパッケージがAUR以外の場所に存在しない場合にのみ正常終了します(AURのパッケージの場合に正常終了)
722 check_aur_package() {
723 local _package="${1}"
724 # 参考: https://qiita.com/Hayao0819/items/a8740a17301fafa2fdab
725 if [[ -z "$(pacman -Ssq "${_package}" 2>/dev/null | grep -o ".*${_package}$")" ]]; then
734 # 引数で指定されたパッケージが既にインストールされている場合は正常終了します。
735 check_installed_package() {
736 local _package="${1}"
737 if "${pacman_command}" -Qq "${_package}" > /dev/null 2>&1; then
744 # ~/.cacheに相当するディレクトリを返します
746 local _user_config_dir _cache_dir
747 if [[ -v XDG_CONFIG_HOME ]]; then
748 _user_config_dir="${XDG_CONFIG_HOME}"
750 _use_config_dir="${HOME}/.config"
752 if [[ -f "${_use_config_dir}/user-dirs.dirs" ]]; then
753 source "${_use_config_dir}/user-dirs.dirs"
755 if [[ -v XDG_CACHE_HOME ]]; then
756 _cache_dir="${XDG_CACHE_HOME}"
758 _cache_dir="${HOME}/.cache"
760 echo -n "${_cache_dir}"
763 # Usage: get_srcinfo_data <path> <var>
764 # 参考: https://qiita.com/withelmo/items/b0e1ffba639dd3ae18c0
766 local _srcinfo="${1}" _ver="${2}"
767 local _srcinfo_json=$(python << EOF
768 from srcinfo.parse import parse_srcinfo; import json
772 parsed, errors = parse_srcinfo(text)
773 print(json.dumps(parsed))
776 echo "${_srcinfo_json}" | jq -rc "${2}" | tr '\n' ' '
780 # AURからパッケージをビルドしてインストールします
781 # 現在1つのパッケージしか指定できません
782 install_aur_package() {
783 local _package="${1}"
786 if [[ ! -v wfa_cache_dir ]]; then
787 wfa_cache_dir="$(get_cache_dir)/wfa"
789 mkdir -p "${wfa_cache_dir}/archive"
790 mkdir -p "${wfa_cache_dir}/build/${_package}"
793 msg_info "Searching in AUR ..."
794 local _aur_json=$(curl -sL "https://aur.archlinux.org/rpc/?v=5&type=search&by=name&arg=${_package}" | jq -r)
795 if (( "$(echo "${_aur_json}" | jq -r ".resultcount")" == 0 )); then
796 msg_error "Could not find all required packages:\n ${_package}"
800 local _found_packages="$(echo "${_aur_json}" | jq -r --tab '.results[].Name')"
801 #msg_debug "Found package: $(echo ${_found_packages} | tr '\n' ' ')"
803 if [[ -n "$(echo "${_found_packages}" | grep -x "${_package}" )" ]]; then
804 msg_debug "Select a package %s with an exact name match" "${_package}"
806 msg_error "No package with an exact name match was found"
811 msg_info "Download PKGBUILD of %s" "${_package}"
812 _aur_json=$(echo "${_aur_json}" | jq -r ".results[] | select(.Name == \"${_package}\")" )
813 local _aur_snapshot_url="${aururl%/}$(echo "${_aur_json}" | jq -r ".URLPath")"
814 local _aur_version="$(echo "${_aur_json}" | jq -r ".Version")"
815 msg_debug "Get PKGBUILD from %s" "${_aur_snapshot_url}"
817 local _pkgbuild_archive_path="${wfa_cache_dir}/archive/${_package}-${_aur_version}"
818 local _download_pkgbuild=true
819 if [[ -f "${_pkgbuild_archive_path}" ]]; then
820 msg_warn "PKGBUILD has already been downloaded"
821 msg_warn -n "Do you want to overwrite and download? [n] :"
823 if [[ "${noconfirm}" = true ]]; then
829 case "${_yes_or_no}" in
830 "y" | "Y" | "yes" | "Yes" | "YES" ) _download_pkgbuild=true ;;
831 * ) _download_pkgbuild=false ;;
834 if [[ "${_download_pkgbuild}" = true ]]; then
835 remove "${_pkgbuild_archive_path}"
836 curl -L -C - -f -o "${_pkgbuild_archive_path}" "${_aur_snapshot_url}"
840 msg_info "Unpacking the tarball of PKGBUILD ..."
841 tar -xv -f "${_pkgbuild_archive_path}" -C "${wfa_cache_dir}/build/" > /dev/null 2>&1
844 local _build_dir="${wfa_cache_dir}/build/${_package}"
845 if [[ ! -f "${_build_dir}/.SRCINFO" ]]; then
846 msg_warn ".SRCINFO was not found.\nGenerating it using makepkg"
849 "${makepkg_command}" --printsrcinfo > "${_build_dir}/.SRCINFO"
853 local _makedepends="$(get_srcinfo_data "${_build_dir}/.SRCINFO" ".makedepends[]?")"
854 local _depends="$(get_srcinfo_data "${_build_dir}/.SRCINFO" ".depends[]?")"
855 local _conflicts="$(get_srcinfo_data "${_build_dir}/.SRCINFO" ".conflicts[]?")"
856 msg_debug "makedepends: %s" "${_makedepends}"
857 msg_debug "depends: %s" "${_depends}"
858 msg_debug "conflicts: %s " "${_conflicts}"
862 local _pkg _conflicts_found=false
863 for _pkg in ${_conflicts[@]}; do
864 if "${pacman_command}" -Qq "${_pkg}" > /dev/null 2>&1 ; then
865 _conflicts_found=true
866 msg_error "${_package} is colliding with ${_pkg}"
869 if "${pacman_command}" -Qq "${_package}" > /dev/null 2>&1 && [[ ! "$("${pacman_command}" -Qq "${_package}" 2> /dev/null)" = "${_package}" ]]; then
870 msg_error "${_package} is colliding with $("${pacman_command}" -Qq "${_package}")"
871 _conflicts_found=true
873 if [[ "${_conflicts_found}" = true ]]; then
874 msg_error "Conflict(s) was found"
880 if [[ "${nodeps}" = false ]]; then
881 msg_info "Install dependent packages..."
882 local _force_aur="${force_aur}"
884 install_package "${_depends}"
885 force_aur="${_force_aur}"
891 if [[ -d "${_build_dir}/src" ]]; then
892 msg_info "Found %s" "${_build_dir}/src"
893 msg_info -n "Packages to cleanBuild? [n] :"
896 if [[ "${noconfirm}" = true ]]; then
902 case "${_yes_or_no}" in
903 "y" | "Y" | "yes" | "Yes" | "YES" ) add_args makepkg "--clean" ;;
909 add_args "makepkg" "-sf"
912 "${makepkg_command}" "${makepkg_args}"
919 "${makepkg_command}" --printsrcinfo > "${_build_dir}/.SRCINFO"
921 local _pkgnames=($(get_srcinfo_data "${_build_dir}/.SRCINFO" ".packages | keys[]"))
922 local _pkgver="$(get_srcinfo_data "${_build_dir}/.SRCINFO" ".pkgver" | sed 's/ //g')"
923 local _pkgrel="$(get_srcinfo_data "${_build_dir}/.SRCINFO" ".pkgrel" | sed 's/ //g')"
924 local _arch_array=($(get_srcinfo_data "${_build_dir}/.SRCINFO" ".arch[]"))
926 if [[ "${_arch_array[*]}" = "any" ]]; then
932 source "${makepkg_config}"
935 local _pkgfilelist=()
936 for _pkgname in ${_pkgnames[@]}; do
937 _pkgfilelist+=("${_build_dir}/${_pkgname}-${_pkgver}-${_pkgrel}-${_arch}${_PKGEXT}")
941 run_pacman -U --noconfirm ${_pkgfilelist[@]}
945 search_aur_package() {
946 local _package="${1}"
947 #msg_info "Searching in AUR ..."
948 local _aur_json=$(curl -sL "https://aur.archlinux.org/rpc/?v=5&type=search&by=name-desc&arg=${_package}" | jq -r )
949 local _found_result_count="$(echo "${_aur_json}" | jq -r ".resultcount")"
950 if (( "${_found_result_count}" == 0 )); then
951 msg_error "Could not find all required packages:\n %s" "${_package}"
954 _aur_json=$(echo "${_aur_json}" | jq -r ".results[]")
956 local _found_pkgname=($(echo "${_aur_json}" | jq -r ".Name" ))
958 if [[ "${quiet}" = true ]]; then
961 echo "${_found_pkgname[*]}"
964 local _found_package __pkgver __popularity __vote __pkgdesc __orphaned __installed __output_text=()
965 for _found_package in ${_found_pkgname[@]}; do
968 _found_json="$(echo ${_aur_json} | jq "select(.Name == \"${_found_package}\")")"
970 #echo "${_found_json}"
971 __pkgver="$(echo "${_found_json}" | jq -r ".Version" )"
972 __popularity="$(echo "${_found_json}" | jq -r ".Popularity" )"
973 __vote="$(echo "${_found_json}" | jq -r ".NumVotes" )"
974 __pkgdesc="$(echo "${_found_json}" | jq -r ".Description" )"
977 # 参考: http://www.rivhiro-weather.com/knowledge/?p=536
978 msg_debug "Row popularity: %s" "${__popularity}"
979 __popularity="$(printf "%g\n" "${__popularity}" | awk '{printf("%4.2f", $1)}')"
982 #参考: https://www.366service.com/jp/qa/7c95f46e5236039134ff5b862ae2cd13
983 if ! echo "${_found_json}" | jq -r --exit-status ".Maintainer" 1> /dev/null 2> /dev/null ; then
988 if check_installed_package "${_found_package}"; then
993 "$(text -c blue -b "aur")/$(text -b "${_found_package}") $(text -c cyan "${__pkgver}") (+$(text -b "${__vote} ${__popularity}"))"
996 if [[ "${__orphaned}" = true ]]; then
997 __output_text+=("$(text -bc red "(Orphaned)")")
1000 if [[ "${__installed}" = true ]]; then
1001 __output_text+=("$(text -bc cyan "[Installed]")")
1003 echo "${__output_text[*]}"
1004 echo " ${__pkgdesc}"
1005 unset __pkgver __popularity __vote __pkgdesc _found_json __orphaned __installed __output_text
1011 operation_version() {
1012 # Pyalpmからlibalpmの値を取得
1013 # 参考: https://pyalpm.readthedocs.io/en/latest/pyalpm/pyalpm.html
1014 local _libalpm_version="$(python3 -c 'import pyalpm; print(pyalpm.alpmversion())')"
1015 local _pacman_version="$("${pacman_command}" -Q pacman | cut -d ' ' -f 2)"
1016 echo "wfa v${wfa_version} - pacman v${_pacman_version} - libalpm v${_libalpm_version}"
1019 operation_remove() {
1020 run_pacman ${pacman_args} "${specified_packages[@]}"
1023 # Usage: install_package <package1> <package2>...
1026 for _package in ${@}; do
1027 if ! check_installed_package "${_package}"; then
1028 if ! check_aur_package "${_package}"; then
1029 # 公式パッケージなのでpacmanでそのままインストール
1030 run_pacman ${pacman_args} "${_package}"
1033 install_aur_package "${_package}"
1034 #msg_error "Getting the AUR package has not been implemented yet.
1041 upgrade_aur_package() {
1043 msg_error "This is a feature that has not been implemented yet"
1048 if (( "${sync_clean_count}" >= 1 )); then
1049 remove "$(get_cache_dir)/wfa"
1050 run_pacman ${pacman_args} $(
1052 for _count in $(seq 1 ${sync_clean_count}); do
1059 if [[ "${sync_search}" = true ]]; then
1060 for _package in ${specified_packages[@]}; do
1061 search_aur_package "${_package}"
1063 "${pacman_command}" ${pacman_args} ${specified_packages[@]} || :
1065 if [[ "${sync_upgrade}" = true ]]; then
1067 run_pacman ${pacman_args} --sysupgrade
1069 for _package in ${specified_packages[@]}; do
1070 if ! check_aur_package "${_package}" && [[ "${force_aur}" = false ]]; then
1071 # 公式パッケージなのでpacmanでそのままインストール
1072 run_pacman ${pacman_args} "${_package}"
1075 install_aur_package "${_package}"
1076 #msg_error "Getting the AUR package has not been implemented yet."
1086 _opt_short="QRShVdb:aysuc"q
1087 _opt_long="query,remove,sync,help,version,debug,dbpath:,aururl,aur,noconfirm,config:,makepkg:,mflags:,pacman:,git:,gitflags:,gpg:,gpgflags:,makepkgconf:,nomakepkgconf,nodeps,refresh,bash-debug,msg-debug,sysupgrade,color:,nocolor,clean,quiet"
1089 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- ${ARGUMENT})
1090 [[ ${?} != 0 ]] && exit 1
1091 unset _opt_short _opt_long
1093 eval set -- "${OPT}"
1094 msg_debug "Argument: ${OPT}"
1099 set_operation "query"
1103 set_operation "remove"
1107 set_operation "sync"
1111 set_operation "version"
1124 eval set -- "${OPT}"
1130 msg_debug "Assume targets are from the AUR"
1135 add_args pacman "--debug"
1140 add_args pacman "--nodeps"
1144 add_args pacman "--dbpath '${2}'"
1148 option_y_count=$(( option_y_count + 1 ))
1152 add_args pacman "--search"
1161 sync_clean_count=$(( sync_clean_count + 1 ))
1166 add_args pacman "--quiet"
1174 add_args pacman "--noconfirm"
1179 pacman_config="${2}"
1180 add_args pacman "--config ${2}"
1184 makepkg_command="${2}"
1192 pacman_command="${2}"
1204 if [[ "${nomakepkgconf}" = false ]]; then
1205 makepkg_config="${2}"
1207 msg_warn "--nomakepkgconf is specified.\n--makepkgconf has been ignored."
1212 makepkg_config="/etc/makepkg.conf"
1229 add_args pacman "--color never"
1233 add_args pacman "--color always"
1236 msg_error "auto is not currently supported."
1237 add_args pacman "--color auto"
1243 add_args pacman "--color never"
1261 specified_packages=(${@})
1263 # Run database update
1264 if (( "${option_y_count}" == 1 )); then
1266 elif (( "${option_y_count}" >= 2 )); then
1270 case "${operation}" in
1284 msg_error "Undefined operation"