mirror of
https://gitlab.archlinux.org/archlinux/devtools.git
synced 2025-11-24 19:24:41 +01:00
Compare commits
16 Commits
anthraxx/d
...
anthraxx/g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa938224d1 | ||
|
|
02d04a7c43 | ||
|
|
9860819976 | ||
|
|
c2271745c4 | ||
|
|
4aaa7e67fd | ||
|
|
653759343a | ||
|
|
900f675385 | ||
|
|
9d009de849 | ||
|
|
7003aecba1 | ||
|
|
6517dd780e | ||
|
|
f484f9eccb | ||
|
|
3a41c91524 | ||
|
|
fbe8028e82 | ||
|
|
7659b2f6ab | ||
|
|
9f75e17adf | ||
|
|
e21f2085b2 |
@@ -2,89 +2,431 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
_devtools_compgen() {
|
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
||||||
local i r
|
# shellcheck source=src/lib/valid-tags.sh
|
||||||
COMPREPLY=($(compgen -W '$*' -- "$cur"))
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-tags.sh
|
||||||
for ((i=1; i < ${#COMP_WORDS[@]}-1; i++)); do
|
# shellcheck source=src/lib/valid-repos.sh
|
||||||
for r in "${!COMPREPLY[@]}"; do
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-repos.sh
|
||||||
if [[ ${COMP_WORDS[i]} = "${COMPREPLY[r]}" ]]; then
|
|
||||||
unset 'COMPREPLY[r]'; break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
_pkgrepo_pkg() {
|
_binary_arch=${_arch[*]:0:-1}
|
||||||
_devtools_compgen "$(
|
_colors=(never always auto)
|
||||||
command pacman "-$1"
|
|
||||||
)"
|
|
||||||
}
|
|
||||||
|
|
||||||
_pkgrepo() {
|
|
||||||
local cur prev
|
|
||||||
COMPREPLY=()
|
|
||||||
cur=$(_get_cword)
|
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
||||||
|
|
||||||
_pkgrepo_pkg Slq
|
_makechrootpkg_args=(
|
||||||
true
|
-h
|
||||||
} &&
|
-c
|
||||||
complete -F _pkgrepo pkgrepo
|
-d
|
||||||
|
-D
|
||||||
_makechrootpkg() {
|
-u
|
||||||
local cur
|
-r
|
||||||
COMPREPLY=()
|
-I
|
||||||
_get_comp_words_by_ref cur
|
-l
|
||||||
|
-n
|
||||||
case $cur in
|
-T
|
||||||
-*)
|
-U
|
||||||
COMPREPLY=( $( compgen -W '-I -c -h -l -r -u' -- "$cur" ) )
|
)
|
||||||
;;
|
_makechrootpkg_args_d_opts() { _filedir -d; }
|
||||||
*)
|
_makechrootpkg_args_D_opts() { _filedir -d; }
|
||||||
_filedir
|
_makechrootpkg_args_r_opts() { _filedir -d; }
|
||||||
return 0
|
_makechrootpkg_args_I_opts() { _filedir '*.pkg.tar.*'; }
|
||||||
;;
|
_makechrootpkg_args_l_opts() { _filedir -d; }
|
||||||
esac
|
_makechrootpkg_args_U_opts() { :; }
|
||||||
|
_makechrootpkg() { __devtools_complete _makechrootpkg; }
|
||||||
true
|
|
||||||
} &&
|
|
||||||
complete -F _makechrootpkg makechrootpkg
|
complete -F _makechrootpkg makechrootpkg
|
||||||
|
|
||||||
_mkarchroot() {
|
|
||||||
local cur
|
|
||||||
COMPREPLY=()
|
|
||||||
_get_comp_words_by_ref cur
|
|
||||||
|
|
||||||
case $cur in
|
_makerepropkg_args=(
|
||||||
-*)
|
-h
|
||||||
COMPREPLY=( $( compgen -W '-C -M -c -h' -- "$cur" ) )
|
-d
|
||||||
;;
|
-c
|
||||||
*)
|
-M
|
||||||
_filedir
|
)
|
||||||
return 0
|
_makerepropkg_args_c_opts() { _filedir -d; }
|
||||||
;;
|
_makerepropkg_args_M_opts() { _filedir '*.conf'; }
|
||||||
esac
|
_makerepropkg_opts() { _filedir '*.pkg.tar.*'; }
|
||||||
|
_makerepropkg() { __devtools_complete _makerepropkg; }
|
||||||
|
complete -F _makerepropkg makerepropkg
|
||||||
|
|
||||||
true
|
|
||||||
} &&
|
_mkarchroot_args=(
|
||||||
|
-U
|
||||||
|
-C
|
||||||
|
-M
|
||||||
|
-c
|
||||||
|
-h
|
||||||
|
)
|
||||||
|
_mkarchroot_args_U_opts() { _filedir '*.pkg.tar.*'; }
|
||||||
|
_mkarchroot_args_C_opts() { _filedir '*.conf'; }
|
||||||
|
_mkarchroot_args_M_opts() { _filedir '*.conf'; }
|
||||||
|
_mkarchroot_args_c_opts() { _filedir -d; }
|
||||||
|
_mkarchroot_opts() {
|
||||||
|
local args
|
||||||
|
args=$(__pkgctl_word_count_after_subcommand)
|
||||||
|
if (( args == 0 )); then
|
||||||
|
_filedir -d
|
||||||
|
elif (( args >= 1 )); then
|
||||||
|
_devtools_completions_all_packages
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
_mkarchroot() { __devtools_complete _mkarchroot; }
|
||||||
complete -F _mkarchroot mkarchroot
|
complete -F _mkarchroot mkarchroot
|
||||||
|
|
||||||
_arch-nspawn() {
|
|
||||||
local cur
|
|
||||||
COMPREPLY=()
|
|
||||||
_get_comp_words_by_ref cur
|
|
||||||
|
|
||||||
case $cur in
|
_arch_nspawn_args=(
|
||||||
-*)
|
-C
|
||||||
COMPREPLY=( $( compgen -W '-C -M -c -h' -- "$cur" ) )
|
-M
|
||||||
;;
|
-c
|
||||||
*)
|
-f
|
||||||
_filedir
|
-s
|
||||||
return 0
|
-h
|
||||||
;;
|
)
|
||||||
esac
|
_arch_nspawn_args_C_opts() { _filedir '*.conf'; }
|
||||||
|
_arch_nspawn_args_M_opts() { _filedir '*.conf'; }
|
||||||
|
_arch_nspawn_args_c_opts() { _filedir -d; }
|
||||||
|
_arch_nspawn_args_f_opts() { _filedir; }
|
||||||
|
_arch_nspawn_opts() {
|
||||||
|
local args
|
||||||
|
args=$(__pkgctl_word_count_after_subcommand)
|
||||||
|
if (( args == 0 )); then
|
||||||
|
_filedir -d
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
_arch_nspawn() { __devtools_complete _arch_nspawn; }
|
||||||
|
complete -F _arch_nspawn arch-nspawn
|
||||||
|
|
||||||
true
|
|
||||||
} &&
|
_sogrep_args=(
|
||||||
complete -F _arch-nspawn arch-nspawn
|
-v --verbose
|
||||||
# ex:et ts=2 sw=2 ft=sh
|
-r --refresh
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
_sogrep_opts() {
|
||||||
|
local args
|
||||||
|
args=$(__pkgctl_word_count_after_subcommand)
|
||||||
|
if (( args == 0 )); then
|
||||||
|
_devtools_completions_repo all
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
_sogrep() { __devtools_complete _sogrep; }
|
||||||
|
complete -F _sogrep sogrep
|
||||||
|
|
||||||
|
|
||||||
|
_offload_build_args=(
|
||||||
|
-r --repo
|
||||||
|
-a --arch
|
||||||
|
-s --server
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
_offload_build_args__repo_opts() { _devtools_completions_build_repo; }
|
||||||
|
_offload_build_args_r_opts() { _offload_build_args__repo_opts; }
|
||||||
|
_offload_build_args__arch_opts() { _devtools_completions_arch; }
|
||||||
|
_offload_build_args_a_opts() { _offload_build_args__arch_opts; }
|
||||||
|
_offload_build_args__server_opts() { :; }
|
||||||
|
_offload_build_args_s_opts() { _offload_build_args__server_opts; }
|
||||||
|
_offload_build() { __devtools_complete _offload_build; }
|
||||||
|
complete -F _offload_build offload-build
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_cmds=(
|
||||||
|
auth
|
||||||
|
build
|
||||||
|
db
|
||||||
|
diff
|
||||||
|
release
|
||||||
|
repo
|
||||||
|
version
|
||||||
|
)
|
||||||
|
_pkgctl_args=(
|
||||||
|
-V --version
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_auth_cmds=(
|
||||||
|
login
|
||||||
|
status
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_auth_login_args=(
|
||||||
|
-g --gen-access-token
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_auth_status_args=(
|
||||||
|
-t --show-token
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_build_args=(
|
||||||
|
--arch
|
||||||
|
--repo
|
||||||
|
|
||||||
|
-s --staging
|
||||||
|
-t --testing
|
||||||
|
-o --offload
|
||||||
|
-c --clean
|
||||||
|
|
||||||
|
--pkgver
|
||||||
|
--pkgrel
|
||||||
|
--rebuild
|
||||||
|
-e --edit
|
||||||
|
|
||||||
|
-r --release
|
||||||
|
-m --message
|
||||||
|
-u --db-update
|
||||||
|
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
_pkgctl_build_args__arch_opts() { _devtools_completions_arch; }
|
||||||
|
_pkgctl_build_args__repo_opts() { _devtools_completions_repo; }
|
||||||
|
_pkgctl_build_args__pkgver_opts() { :; }
|
||||||
|
_pkgctl_build_args__pkgrel_opts() { :; }
|
||||||
|
_pkgctl_build_args__message_opts() { :; }
|
||||||
|
_pkgctl_build_args_m_opts() { _pkgctl_build_args__message_opts; }
|
||||||
|
_pkgctl_build_opts() { _filedir -d; }
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_db_cmds=(
|
||||||
|
move
|
||||||
|
remove
|
||||||
|
update
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_db_move_args=(
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
_pkgctl_db_move_opts() {
|
||||||
|
local subcommand args
|
||||||
|
subcommand=(db move)
|
||||||
|
args=$(__pkgctl_word_count_after_subcommand "${subcommand[@]}")
|
||||||
|
|
||||||
|
if (( args == 0 )); then
|
||||||
|
_devtools_completions_repo
|
||||||
|
elif (( args == 1 )); then
|
||||||
|
_devtools_completions_repo
|
||||||
|
elif (( args >= 2 )); then
|
||||||
|
_devtools_completions_all_packages
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_db_remove_args=(
|
||||||
|
-a --arch
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
_pkgctl_db_remove_opts() {
|
||||||
|
local subcommand args
|
||||||
|
subcommand=(db remove)
|
||||||
|
args=$(__pkgctl_word_count_after_subcommand "${subcommand[@]}")
|
||||||
|
|
||||||
|
if (( args == 0 )); then
|
||||||
|
_devtools_completions_repo
|
||||||
|
elif (( args >= 1 )); then
|
||||||
|
_devtools_completions_all_packages
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_db_update_args=(
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_release_args=(
|
||||||
|
-m --message
|
||||||
|
-r --repo
|
||||||
|
-s --staging
|
||||||
|
-t --testing
|
||||||
|
-u --db-update
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
_pkgctl_release_args__message_opts() { :; }
|
||||||
|
_pkgctl_release_args_m_opts() { _pkgctl_release_args__message_opts; }
|
||||||
|
_pkgctl_release_args__repo_opts() { _devtools_completions_repo; }
|
||||||
|
_pkgctl_release_args_r_opts() { _pkgctl_release_args__repo_opts; }
|
||||||
|
_pkgctl_release_opts() { _filedir -d; }
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_repo_cmds=(
|
||||||
|
clone
|
||||||
|
configure
|
||||||
|
create
|
||||||
|
web
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_repo_clone_args=(
|
||||||
|
-m --maintainer
|
||||||
|
-u --unprivileged
|
||||||
|
--universe
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
_pkgctl_repo_clone_args__maintainer_opts() { :; }
|
||||||
|
_pkgctl_repo_clone_args_m_opts() { _pkgctl_repo_clone_args__maintainer_opts; }
|
||||||
|
_pkgctl_repo_clone_opts() { _devtools_completions_all_packages; }
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_repo_configure_args=(
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
_pkgctl_repo_configure_opts() { _filedir -d; }
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_repo_create_args=(
|
||||||
|
-c --clone
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_repo_web_args=(
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
_pkgctl_repo_web_opts() { _filedir -d; }
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_diff_args=(
|
||||||
|
-l --list
|
||||||
|
-d --diffoscope
|
||||||
|
-p --pkginfo
|
||||||
|
-b --buildinfo
|
||||||
|
-m --makepkg-config
|
||||||
|
-u -U --unified
|
||||||
|
-y --side-by-side
|
||||||
|
--color
|
||||||
|
-W --width
|
||||||
|
-P --pool
|
||||||
|
-v --verbose
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
_pkgctl_diff_args__makepkg_config_opts() { _filedir '*.conf'; }
|
||||||
|
_pkgctl_diff_args_m_opts() { _pkgctl_diff_args__makepkg_config_opts; }
|
||||||
|
_pkgctl_diff_args__width_opts() { :; }
|
||||||
|
_pkgctl_diff_args_W_opts() { _pkgctl_diff_args__width_opts; }
|
||||||
|
_pkgctl_diff_args__color_opts() { _devtools_completions_color; }
|
||||||
|
_pkgctl_diff_args__pool_opts() { _filedir -d; }
|
||||||
|
_pkgctl_diff_args_P_opts() { _pkgctl_diff_args__pool_opts; }
|
||||||
|
_pkgctl_diff_opts() { _devtools_completions_all_packages; }
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl_version_args=(
|
||||||
|
-h --help
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_devtools_completions_color() {
|
||||||
|
mapfile -t COMPREPLY < <(compgen -W "${_colors[*]}" -- "$cur")
|
||||||
|
}
|
||||||
|
_devtools_completions_arch() {
|
||||||
|
mapfile -t COMPREPLY < <(compgen -W "${_arch[*]}" -- "$cur")
|
||||||
|
}
|
||||||
|
_devtools_completions_repo() {
|
||||||
|
local optional=${1:-}
|
||||||
|
mapfile -t COMPREPLY < <(compgen -W "${optional} ${_repos[*]}" -- "$cur")
|
||||||
|
}
|
||||||
|
_devtools_completions_build_repo() {
|
||||||
|
mapfile -t COMPREPLY < <(compgen -W "${_build_repos[*]}" -- "$cur")
|
||||||
|
}
|
||||||
|
_devtools_completions_all_packages() {
|
||||||
|
mapfile -t COMPREPLY < <(compgen -W "$(pacman -Sql)" -- "$cur")
|
||||||
|
}
|
||||||
|
|
||||||
|
__devtools_complete() {
|
||||||
|
local service=$1
|
||||||
|
local cur prev
|
||||||
|
|
||||||
|
# Don't break words at : and =
|
||||||
|
COMP_WORDBREAKS=${COMP_WORDBREAKS//[:=]}
|
||||||
|
|
||||||
|
cur=$(_get_cword)
|
||||||
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
|
__pkgctl_handle_subcommands "${service}"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
__pkgctl_has_func() {
|
||||||
|
declare -f -- "${1}" &>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
__pkgctl_has_array() {
|
||||||
|
declare -p -- "${1}" &>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
__pkgctl_is_subcommand() {
|
||||||
|
__pkgctl_has_array "${1}"_args || \
|
||||||
|
__pkgctl_has_array "${1}"_cmds
|
||||||
|
}
|
||||||
|
|
||||||
|
__pkgctl_words_after_subcommand() {
|
||||||
|
local subcommand=("$@")
|
||||||
|
local subcommand_idx=0
|
||||||
|
local word prev_word
|
||||||
|
for ((i = 1; i < ${#COMP_WORDS[@]}; ++i)); do
|
||||||
|
word=${COMP_WORDS[i]}
|
||||||
|
prev_word=${COMP_WORDS[i-1]}
|
||||||
|
# skip options and the current typing
|
||||||
|
if [[ ${word} == -* ]] || [[ ${word} == "${cur}" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# skip until we resolved the passed subcommand
|
||||||
|
if (( subcommand_idx < ${#subcommand[@]} )); then
|
||||||
|
if [[ $word == "${subcommand[$subcommand_idx]}" ]]; then
|
||||||
|
subcommand_idx=$(( subcommand_idx + 1 ))
|
||||||
|
fi
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# skip previous options as they belong to the argument
|
||||||
|
if [[ ${prev_word} == -* ]] && __pkgctl_has_func "${service_name}_args${prev_word//-/_}_opts"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
printf "%s\n" "${word}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
__pkgctl_word_count_after_subcommand() {
|
||||||
|
local subcommand=("$@")
|
||||||
|
mapfile -t words < <(__pkgctl_words_after_subcommand "${subcommand[@]}")
|
||||||
|
echo "${#words[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
__pkgctl_handle_subcommands() {
|
||||||
|
local service_name=${1}
|
||||||
|
local index=${2:-0}
|
||||||
|
local word ref
|
||||||
|
|
||||||
|
# recurse into nested subcommands
|
||||||
|
for ((i = index + 1; i < ${#COMP_WORDS[@]}; ++i)); do
|
||||||
|
word=${COMP_WORDS[i]}
|
||||||
|
if [[ ${word} == -* ]] || [[ ${word} == "${cur}" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if __pkgctl_is_subcommand "${service_name}_${word}"; then
|
||||||
|
__pkgctl_handle_subcommands "${service_name}_${word}" "${i}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# dynamic argument options
|
||||||
|
if [[ $prev == -* ]] && word=${prev//-/_} && __pkgctl_has_func "${service_name}_args${word}_opts"; then
|
||||||
|
"${service_name}_args${word}_opts"
|
||||||
|
# dynamic subcommand options
|
||||||
|
elif [[ $cur != -* ]] && __pkgctl_has_func "${service_name}_opts"; then
|
||||||
|
"${service_name}_opts"
|
||||||
|
# subcommand argument array
|
||||||
|
elif ( ! __pkgctl_has_array "${service_name}"_cmds || [[ $cur == -* ]] ) && __pkgctl_has_array "${service_name}_args"; then
|
||||||
|
declare -n ref="${service_name}_args"
|
||||||
|
mapfile -t COMPREPLY < <(compgen -W "${ref[*]}" -- "$cur")
|
||||||
|
# subcommand array
|
||||||
|
elif __pkgctl_has_array "${service_name}"_cmds; then
|
||||||
|
declare -n ref="${service_name}_cmds"
|
||||||
|
mapfile -t COMPREPLY < <(compgen -W "${ref[*]}" -- "$cur")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_pkgctl() { __devtools_complete _pkgctl; }
|
||||||
|
complete -F _pkgctl pkgctl
|
||||||
|
# ex:noet ts=4 sw=4 ft=sh
|
||||||
|
|||||||
@@ -231,6 +231,16 @@ _pkgctl_cmds=(
|
|||||||
"diff[Compare package files using different modes]"
|
"diff[Compare package files using different modes]"
|
||||||
"release[Release step to commit, tag and upload build artifacts]"
|
"release[Release step to commit, tag and upload build artifacts]"
|
||||||
"repo[Manage Git packaging repositories and their configuration]"
|
"repo[Manage Git packaging repositories and their configuration]"
|
||||||
|
"version[Show pkgctl version information]"
|
||||||
|
)
|
||||||
|
|
||||||
|
_pkgctl_args=(
|
||||||
|
'(-V --version)'{-V,--version}'[Show pkgctl version information]'
|
||||||
|
'(-h --help)'{-h,--help}'[Display usage]'
|
||||||
|
)
|
||||||
|
|
||||||
|
_pkgctl_version_args=(
|
||||||
|
'(-h --help)'{-h,--help}'[Display usage]'
|
||||||
)
|
)
|
||||||
|
|
||||||
_pkgctl_diff_args=("${_diffpkg_args[@]}")
|
_pkgctl_diff_args=("${_diffpkg_args[@]}")
|
||||||
@@ -243,8 +253,13 @@ _handle_subcommands() {
|
|||||||
'*::arg:->args'
|
'*::arg:->args'
|
||||||
case $state in
|
case $state in
|
||||||
cmds)
|
cmds)
|
||||||
local service_cmds=${service_name}_cmds[@]
|
if [[ "${line[-1]}" == -* ]] && typeset -p ${service_name}_args &> /dev/null; then
|
||||||
_values "${(P)service_cmds}"
|
local argname="${service_name}_args[@]"
|
||||||
|
_arguments -s "${(P)argname}"
|
||||||
|
else
|
||||||
|
local service_cmds=${service_name}_cmds[@]
|
||||||
|
_values "${(P)service_cmds}"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
args)
|
args)
|
||||||
local service_sub=${service_name}_$line[1]
|
local service_sub=${service_name}_$line[1]
|
||||||
|
|||||||
23
doc/man/pkgctl-version.1.asciidoc
Normal file
23
doc/man/pkgctl-version.1.asciidoc
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
pkgctl-version(1)
|
||||||
|
=================
|
||||||
|
|
||||||
|
Name
|
||||||
|
----
|
||||||
|
pkgctl-version - Show pkgctl version information
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
pkgctl version [OPTIONS]
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Shows the current version information of pkgctl.
|
||||||
|
|
||||||
|
Options
|
||||||
|
-------
|
||||||
|
|
||||||
|
*-h, --help*::
|
||||||
|
Show a help text
|
||||||
|
|
||||||
|
include::include/footer.asciidoc[]
|
||||||
@@ -14,6 +14,15 @@ Description
|
|||||||
|
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
|
Options
|
||||||
|
-------
|
||||||
|
|
||||||
|
*-V, --version*::
|
||||||
|
Show pkgctl version information
|
||||||
|
|
||||||
|
*-h, --help*::
|
||||||
|
Show a help text
|
||||||
|
|
||||||
Subcommands
|
Subcommands
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
@@ -35,6 +44,9 @@ pkgctl release::
|
|||||||
pkgctl repo::
|
pkgctl repo::
|
||||||
Manage Git packaging repositories and their configuration
|
Manage Git packaging repositories and their configuration
|
||||||
|
|
||||||
|
pkgctl version::
|
||||||
|
Show pkgctl version information
|
||||||
|
|
||||||
See Also
|
See Also
|
||||||
--------
|
--------
|
||||||
|
|
||||||
@@ -44,5 +56,6 @@ linkman:pkgctl-db[1]
|
|||||||
linkman:pkgctl-diff[1]
|
linkman:pkgctl-diff[1]
|
||||||
linkman:pkgctl-release[1]
|
linkman:pkgctl-release[1]
|
||||||
linkman:pkgctl-repo[1]
|
linkman:pkgctl-repo[1]
|
||||||
|
linkman:pkgctl-version[1]
|
||||||
|
|
||||||
include::include/footer.asciidoc[]
|
include::include/footer.asciidoc[]
|
||||||
|
|||||||
46
opts.sh
Executable file
46
opts.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# NOTE: This requires GNU getopt
|
||||||
|
if ! ARGS=$(getopt --options vdm:D: \
|
||||||
|
--long verbose,debug,memory:,debugfile: \
|
||||||
|
--name 'pkgctl foo' -- "$@"); then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
eval set -- "$ARGS"
|
||||||
|
|
||||||
|
echo "${ARGS}"
|
||||||
|
|
||||||
|
while (( $# )); do
|
||||||
|
case "$1" in
|
||||||
|
-v | --verbose ) echo verbose; shift ;;
|
||||||
|
-d | --debug ) echo debug; shift ;;
|
||||||
|
-m | --memory ) echo "memory=$2"; shift 2 ;;
|
||||||
|
-D | --debugfile ) echo "debugfile=$2"; shift 2 ;;
|
||||||
|
--)
|
||||||
|
echo --
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
echo "invalid argument: %s" "$1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo STAR "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo main
|
||||||
|
|
||||||
|
if (( ! $# )); then
|
||||||
|
echo missing positional param: version
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
version=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
echo "version $version"
|
||||||
|
echo "$@"
|
||||||
@@ -5,8 +5,6 @@
|
|||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
||||||
# shellcheck source=src/lib/common.sh
|
# shellcheck source=src/lib/common.sh
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
||||||
# shellcheck source=src/lib/util/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/util.sh
|
|
||||||
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
@@ -28,8 +26,6 @@ usage() {
|
|||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-M, --makepkg-config Set an alternate makepkg configuration file
|
-M, --makepkg-config Set an alternate makepkg configuration file
|
||||||
-M, --pacman-config Set an alternate pacman configuration file
|
|
||||||
--dbpath Set an alternate pacman database path
|
|
||||||
-P, --pool=DIR Search diff target in pool dir (default '/srv/ftp/pool')
|
-P, --pool=DIR Search diff target in pool dir (default '/srv/ftp/pool')
|
||||||
-v, --verbose Provide more detailed/unfiltered output
|
-v, --verbose Provide more detailed/unfiltered output
|
||||||
-h, --help Show this help text
|
-h, --help Show this help text
|
||||||
@@ -41,14 +37,12 @@ usage() {
|
|||||||
-y, --side-by-side Output in two columns
|
-y, --side-by-side Output in two columns
|
||||||
-W, --width=NUM Output at most NUM (default 'auto') print columns
|
-W, --width=NUM Output at most NUM (default 'auto') print columns
|
||||||
NUM can be 'auto', 'columns' or a number
|
NUM can be 'auto', 'columns' or a number
|
||||||
--summary Print a summary or warning message on disparity
|
|
||||||
|
|
||||||
MODES
|
MODES
|
||||||
-l, --list Activate content list diff mode (default)
|
-l, --list Activate content list diff mode (default)
|
||||||
-d, --diffoscope Activate diffoscope diff mode
|
-d, --diffoscope Activate diffoscope diff mode
|
||||||
-p, --pkginfo Activate .PKGINFO diff mode
|
-p, --pkginfo Activate .PKGINFO diff mode
|
||||||
-b, --buildinfo Activate .BUILDINFO diff mode
|
-b, --buildinfo Activate .BUILDINFO diff mode
|
||||||
-s, --soname Activate library SONAME diff mode
|
|
||||||
_EOF_
|
_EOF_
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,13 +54,11 @@ TARLIST=0
|
|||||||
DIFFOSCOPE=0
|
DIFFOSCOPE=0
|
||||||
PKGINFO=0
|
PKGINFO=0
|
||||||
BUILDINFO=0
|
BUILDINFO=0
|
||||||
SONAME=0
|
|
||||||
SUMMARY=0
|
|
||||||
|
|
||||||
DIFFMODE=--side-by-side
|
DIFFMODE=--side-by-side
|
||||||
DIFFCOLOR=--color=auto
|
DIFFCOLOR=--color=auto
|
||||||
DIFFWIDTH=--width=auto
|
DIFFWIDTH=--width=auto
|
||||||
DIFFOPTIONS=(--expand-tabs --suppress-common-lines)
|
DIFFOPTIONS=(--expand-tabs)
|
||||||
|
|
||||||
# option checking
|
# option checking
|
||||||
while (( $# )); do
|
while (( $# )); do
|
||||||
@@ -96,18 +88,10 @@ while (( $# )); do
|
|||||||
BUILDINFO=1
|
BUILDINFO=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-s|--soname)
|
|
||||||
SONAME=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-v|--verbose)
|
-v|--verbose)
|
||||||
VERBOSE=1
|
VERBOSE=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--summary)
|
|
||||||
SUMMARY=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-u|-U|--unified)
|
-u|-U|--unified)
|
||||||
DIFFMODE=--unified
|
DIFFMODE=--unified
|
||||||
shift
|
shift
|
||||||
@@ -151,7 +135,7 @@ while (( $# )); do
|
|||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
-*)
|
-*|--*)
|
||||||
die "invalid argument: %s" "$1"
|
die "invalid argument: %s" "$1"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -174,9 +158,6 @@ fi
|
|||||||
if [[ $DIFFWIDTH != --width=auto ]]; then
|
if [[ $DIFFWIDTH != --width=auto ]]; then
|
||||||
DIFFOPTIONS+=("${DIFFWIDTH}")
|
DIFFOPTIONS+=("${DIFFWIDTH}")
|
||||||
fi
|
fi
|
||||||
if [[ $DIFFCOLOR == --color=auto ]] && is_tty; then
|
|
||||||
DIFFCOLOR="--color=always"
|
|
||||||
fi
|
|
||||||
DIFFOPTIONS+=("${DIFFMODE}" "${DIFFCOLOR}")
|
DIFFOPTIONS+=("${DIFFMODE}" "${DIFFCOLOR}")
|
||||||
|
|
||||||
if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then
|
if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then
|
||||||
@@ -251,31 +232,23 @@ diff_pkgs() {
|
|||||||
bsdtar xOqf "$newpkg" .BUILDINFO > "$TMPDIR/new"
|
bsdtar xOqf "$newpkg" .BUILDINFO > "$TMPDIR/new"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( SONAME )); then
|
if (( TARLIST || PKGINFO || BUILDINFO )); then
|
||||||
find-libprovides "$oldpkg" 2>/dev/null | sort > "$TMPDIR/old"
|
|
||||||
find-libprovides "$newpkg" 2>/dev/null | sort > "$TMPDIR/new"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( TARLIST || PKGINFO || BUILDINFO || SONAME )); then
|
|
||||||
# Resolve dynamic auto width one we know the content to diff
|
# Resolve dynamic auto width one we know the content to diff
|
||||||
if [[ $DIFFWIDTH == --width=auto ]]; then
|
if [[ $DIFFWIDTH == --width=auto ]]; then
|
||||||
AUTOLENGTH=$(file_diff_columns "$TMPDIR/old" "$TMPDIR/new")
|
AUTOLENGTH=$(file_diff_columns "$TMPDIR/old" "$TMPDIR/new")
|
||||||
DIFFOPTIONS+=("--width=${AUTOLENGTH}")
|
DIFFOPTIONS+=("--width=${AUTOLENGTH}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! output=$(diff "${DIFFOPTIONS[@]}" "$TMPDIR/old" "$TMPDIR/new"); then
|
# Print a header for side-by-side view as it lacks labels
|
||||||
# Print a header for side-by-side view as it lacks labels
|
if [[ $DIFFMODE == --side-by-side ]]; then
|
||||||
if [[ $DIFFMODE == --side-by-side ]]; then
|
printf -- "--- %s\n+++ %s\n" "${oldpkg}" "${newpkg}"
|
||||||
printf -- "%s--- %s\n+++ %s%s\n" "${BOLD}" "${oldpkg}" "${newpkg}" "${ALL_OFF}"
|
|
||||||
fi
|
|
||||||
printf "%s\n" "${output}"
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
diff "${DIFFOPTIONS[@]}" "$TMPDIR/old" "$TMPDIR/new"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( DIFFOSCOPE )); then
|
if (( DIFFOSCOPE )); then
|
||||||
diffoscope "${DIFFCOLOR/--color/--text-color}" "$oldpkg" "$newpkg"
|
diffoscope "${DIFFCOLOR/--color/--text-color}" "$oldpkg" "$newpkg"
|
||||||
return $?
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,14 +277,13 @@ fetch_pkg() {
|
|||||||
fi
|
fi
|
||||||
# Search via pacman database if no pool file exists
|
# Search via pacman database if no pool file exists
|
||||||
if [[ ! -f ${pkgurl} ]]; then
|
if [[ ! -f ${pkgurl} ]]; then
|
||||||
pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm -- "$pkg") ||
|
pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$pkg") ||
|
||||||
die "Couldn't download previous package for %s." "$pkg"
|
die "Couldn't download previous package for %s." "$pkg"
|
||||||
# TODO: check and download via Swdd so we also do signatures checks before processing
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pkg=${pkgurl##*/}
|
pkg=${pkgurl##*/}
|
||||||
pkgdest=$(mktemp -t -d -- "${pkg}-XXXXXX")/${pkg}
|
pkgdest=$(mktemp -t -d "${pkg}-XXXXXX")/${pkg}
|
||||||
|
|
||||||
if [[ $pkgurl = file://* || ( $pkgurl = /* && -f $pkgurl ) ]]; then
|
if [[ $pkgurl = file://* || ( $pkgurl = /* && -f $pkgurl ) ]]; then
|
||||||
ln -sf "${pkgurl#file://}" "$pkgdest"
|
ln -sf "${pkgurl#file://}" "$pkgdest"
|
||||||
@@ -341,7 +313,6 @@ if (( $# < 2 )); then
|
|||||||
CARCH='any'
|
CARCH='any'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ret=0
|
|
||||||
for _pkgname in "${pkgname[@]}"; do
|
for _pkgname in "${pkgname[@]}"; do
|
||||||
comparepkg=$_pkgname
|
comparepkg=$_pkgname
|
||||||
pkgurl=
|
pkgurl=
|
||||||
@@ -359,13 +330,10 @@ if (( $# < 2 )); then
|
|||||||
oldpkg=$(fetch_pkg "$comparepkg") || exit 1
|
oldpkg=$(fetch_pkg "$comparepkg") || exit 1
|
||||||
|
|
||||||
diff_pkgs "$oldpkg" "$pkgfile"
|
diff_pkgs "$oldpkg" "$pkgfile"
|
||||||
ret+=$?
|
|
||||||
done
|
done
|
||||||
exit $ret
|
|
||||||
else
|
else
|
||||||
file1=$(fetch_pkg "$1") || exit 1
|
file1=$(fetch_pkg "$1") || exit 1
|
||||||
file2=$(fetch_pkg "$2") || exit 1
|
file2=$(fetch_pkg "$2") || exit 1
|
||||||
|
|
||||||
diff_pkgs "$file1" "$file2"
|
diff_pkgs "$file1" "$file2"
|
||||||
exit $?
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ pkgctl_build() {
|
|||||||
local WORKER="${USER}-${PTS}"
|
local WORKER="${USER}-${PTS}"
|
||||||
|
|
||||||
# variables
|
# variables
|
||||||
local path pkgbase pkgrepo source soname_changed=0
|
local path pkgbase pkgrepo source
|
||||||
|
|
||||||
while (( $# )); do
|
while (( $# )); do
|
||||||
case $1 in
|
case $1 in
|
||||||
@@ -169,6 +169,8 @@ pkgctl_build() {
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--rebuild)
|
--rebuild)
|
||||||
|
# shellcheck source=src/lib/util/git.sh
|
||||||
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
|
||||||
pkgctl_build_check_option_group_ver '--rebuild' "${PKGVER}" "${PKGREL}" "${REBUILD}"
|
pkgctl_build_check_option_group_ver '--rebuild' "${PKGVER}" "${PKGREL}" "${REBUILD}"
|
||||||
REBUILD=1
|
REBUILD=1
|
||||||
shift
|
shift
|
||||||
@@ -266,7 +268,6 @@ pkgctl_build() {
|
|||||||
. ./PKGBUILD
|
. ./PKGBUILD
|
||||||
pkgbase=${pkgbase:-$pkgname}
|
pkgbase=${pkgbase:-$pkgname}
|
||||||
pkgrepo=${REPO}
|
pkgrepo=${REPO}
|
||||||
soname_changed=0
|
|
||||||
msg "Building ${pkgbase}"
|
msg "Building ${pkgbase}"
|
||||||
|
|
||||||
# auto-detection of build target
|
# auto-detection of build target
|
||||||
@@ -395,11 +396,6 @@ pkgctl_build() {
|
|||||||
|
|
||||||
# release the build
|
# release the build
|
||||||
if (( RELEASE )); then
|
if (( RELEASE )); then
|
||||||
if [[ ${pkgrepo} != *-staging ]] && ! diffpkg --soname >/dev/null; then
|
|
||||||
die "abort none staging auto-release: package contains soname differences"
|
|
||||||
fi
|
|
||||||
echo RELEASE, ABORT
|
|
||||||
exit 0
|
|
||||||
pkgctl_release --repo "${pkgrepo}" "${RELEASE_OPTIONS[@]}"
|
pkgctl_release --repo "${pkgrepo}" "${RELEASE_OPTIONS[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#!/hint/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_UTIL_UTIL_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_UTIL_UTIL_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
|
|
||||||
|
|
||||||
is_tty() {
|
|
||||||
if [ ! -t 1 ] || [ -p /dev/stdout ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ $TERM == dumb ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
47
src/lib/version/version.sh
Normal file
47
src/lib/version/version.sh
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/hint/bash
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
[[ -z ${DEVTOOLS_INCLUDE_VERSION_SH:-} ]] || return 0
|
||||||
|
DEVTOOLS_INCLUDE_VERSION_SH=1
|
||||||
|
|
||||||
|
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
||||||
|
|
||||||
|
source /usr/share/makepkg/util/message.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
|
||||||
|
pkgctl_version_usage() {
|
||||||
|
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
||||||
|
cat <<- _EOF_
|
||||||
|
Usage: ${COMMAND} [OPTIONS]
|
||||||
|
|
||||||
|
Shows the current version information of pkgctl
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-h, --help Show this help text
|
||||||
|
_EOF_
|
||||||
|
}
|
||||||
|
|
||||||
|
pkgctl_version_print() {
|
||||||
|
cat <<- _EOF_
|
||||||
|
pkgctl @buildtoolver@
|
||||||
|
_EOF_
|
||||||
|
}
|
||||||
|
|
||||||
|
pkgctl_version() {
|
||||||
|
while (( $# )); do
|
||||||
|
case $1 in
|
||||||
|
-h|--help)
|
||||||
|
pkgctl_version_usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "invalid argument: %s" "$1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
pkgctl_version_print
|
||||||
|
}
|
||||||
@@ -25,6 +25,7 @@ usage() {
|
|||||||
diff Compare package files using different modes
|
diff Compare package files using different modes
|
||||||
release Release step to commit, tag and upload build artifacts
|
release Release step to commit, tag and upload build artifacts
|
||||||
repo Manage Git packaging repositories and their configuration
|
repo Manage Git packaging repositories and their configuration
|
||||||
|
version Show pkgctl version information
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-h, --help Show this help text
|
-h, --help Show this help text
|
||||||
@@ -93,6 +94,14 @@ while (( $# )); do
|
|||||||
pkgctl_release "$@"
|
pkgctl_release "$@"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
version|--version|-V)
|
||||||
|
_DEVTOOLS_COMMAND+=" $1"
|
||||||
|
shift
|
||||||
|
# shellcheck source=src/lib/version/version.sh
|
||||||
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/version/version.sh
|
||||||
|
pkgctl_version "$@"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
die "invalid command: %s" "$1"
|
die "invalid command: %s" "$1"
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user