Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
5e7decee42
|
|||
dc606af137 | |||
5253f81f0a | |||
00ed72f96e | |||
70839d8609
|
@@ -15,6 +15,7 @@ artixpkg_admin_usage() {
|
|||||||
COMMANDS
|
COMMANDS
|
||||||
transfer Transfer obsolete repository to landfill
|
transfer Transfer obsolete repository to landfill
|
||||||
query Query maintainers and topics
|
query Query maintainers and topics
|
||||||
|
topic Manage topics
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-h, --help Show this help text
|
-h, --help Show this help text
|
||||||
@@ -55,6 +56,14 @@ artixpkg_admin() {
|
|||||||
artixpkg_admin_query "$@"
|
artixpkg_admin_query "$@"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
topic)
|
||||||
|
_ARTOOLS_COMMAND+=" $1"
|
||||||
|
shift
|
||||||
|
# shellcheck source=src/lib/pkg/admin/query.sh
|
||||||
|
source "${LIBDIR}"/pkg/admin/topic.sh
|
||||||
|
artixpkg_admin_topic "$@"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
-*)
|
-*)
|
||||||
die "invalid argument: %s" "$1"
|
die "invalid argument: %s" "$1"
|
||||||
;;
|
;;
|
||||||
|
139
src/lib/pkg/admin/topic.sh
Normal file
139
src/lib/pkg/admin/topic.sh
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
[[ -z ${ARTOOLS_INCLUDE_ADMIN_TOPIC_SH:-} ]] || return 0
|
||||||
|
ARTOOLS_INCLUDE_ADMIN_TOPIC_SH=1
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
|
||||||
|
artixpkg_admin_topic_usage() {
|
||||||
|
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
||||||
|
cat <<- _EOF_
|
||||||
|
Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-a, --add Add a topic
|
||||||
|
-d, --del Delete a topic
|
||||||
|
-j, --jobs N Run up to N jobs in parallel (default: $(nproc))
|
||||||
|
-h, --help Show this help text
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
$ ${COMMAND} --add mytopic libfoo
|
||||||
|
$ ${COMMAND} --del mytopic libbar
|
||||||
|
$ ${COMMAND} --add mytopic libfoo libbar
|
||||||
|
$ ${COMMAND} --del mytopic libfoo libbar
|
||||||
|
_EOF_
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
artixpkg_admin_topic() {
|
||||||
|
if (( $# < 1 )); then
|
||||||
|
artixpkg_admin_topic_usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# options
|
||||||
|
local pkgbases=()
|
||||||
|
local pkgbase
|
||||||
|
|
||||||
|
local ADD_TOPIC
|
||||||
|
local DEL_TOPIC
|
||||||
|
local ADD=0
|
||||||
|
local DEL=0
|
||||||
|
local jobs=
|
||||||
|
jobs=$(nproc)
|
||||||
|
|
||||||
|
local RUNCMD=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
||||||
|
|
||||||
|
while (( $# )); do
|
||||||
|
case $1 in
|
||||||
|
-a|--add)
|
||||||
|
(( $# <= 1 )) && die "missing argument for %s" "$1"
|
||||||
|
ADD_TOPIC="$2"
|
||||||
|
ADD=1
|
||||||
|
RUNCMD+=" -a ${ADD_TOPIC}"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--add=*)
|
||||||
|
ADD_TOPIC="${1#*=}"
|
||||||
|
ADD=1
|
||||||
|
RUNCMD+=" --add=${ADD_TOPIC}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-d|--del)
|
||||||
|
(( $# <= 1 )) && die "missing argument for %s" "$1"
|
||||||
|
DEL_TOPIC="$2"
|
||||||
|
DEL=1
|
||||||
|
RUNCMD+=" -d ${DEL_TOPIC}"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--del=*)
|
||||||
|
DEL_TOPIC="${1#*=}"
|
||||||
|
DEL=1
|
||||||
|
RUNCMD+=" --del=${DEL_TOPIC}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
artixpkg_admin_topic_usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-j|--jobs)
|
||||||
|
(( $# <= 1 )) && die "missing argument for %s" "$1"
|
||||||
|
jobs=$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
die "invalid argument: %s" "$1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
pkgbases+=("$@")
|
||||||
|
|
||||||
|
if [[ -n ${GIT_TOKEN} ]]; then
|
||||||
|
|
||||||
|
# parallelization
|
||||||
|
if [[ ${jobs} != 1 ]] && (( ${#pkgbases[@]} > 1 )); then
|
||||||
|
if [[ -n ${BOLD} ]]; then
|
||||||
|
export ARTOOLS_COLOR=always
|
||||||
|
fi
|
||||||
|
if ! parallel --bar --jobs "${jobs}" "${RUNCMD}" ::: "${pkgbases[@]}"; then
|
||||||
|
die 'Failed to manage some topic, please check the output'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for pkgbase in "${pkgbases[@]}"; do
|
||||||
|
|
||||||
|
# topics meta
|
||||||
|
if (( ADD )); then
|
||||||
|
local gitname
|
||||||
|
gitname=$(get_compliant_name "${pkgbase}")
|
||||||
|
if ! add_topic "${gitname}" "${ADD_TOPIC}"; then
|
||||||
|
warning "failed to add the topic: ${ADD_TOPIC}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( DEL )); then
|
||||||
|
local gitname
|
||||||
|
gitname=$(get_compliant_name "${pkgbase}")
|
||||||
|
if ! remove_topic "${gitname}" "${DEL_TOPIC}"; then
|
||||||
|
warning "failed to delete the topic: ${DEL_TOPIC}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
@@ -99,6 +99,10 @@ artixpkg_repo_add() {
|
|||||||
local commit_msg
|
local commit_msg
|
||||||
commit_msg=$(get_commit_msg 'add' "${DEST}")
|
commit_msg=$(get_commit_msg 'add' "${DEST}")
|
||||||
|
|
||||||
|
if [[ -f .SRCINFO ]]; then
|
||||||
|
rm .SRCINFO
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n $(git status --porcelain --untracked-files=no) ]]; then
|
if [[ -n $(git status --porcelain --untracked-files=no) ]]; then
|
||||||
|
|
||||||
stat_busy 'Staging files'
|
stat_busy 'Staging files'
|
||||||
|
@@ -23,7 +23,7 @@ patch_pkgbase(){
|
|||||||
-i PKGBUILD
|
-i PKGBUILD
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
git diff PKGBUILD
|
git --no-pager diff PKGBUILD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -64,8 +64,9 @@ artixpkg_repo_import() {
|
|||||||
--exclude '.gitignore'
|
--exclude '.gitignore'
|
||||||
--exclude 'README.md'
|
--exclude 'README.md'
|
||||||
--exclude '*.service'
|
--exclude '*.service'
|
||||||
--exclude '*.timer'
|
--exclude '.SRCINFO'
|
||||||
--exclude '*.socket'
|
--exclude '*.socket'
|
||||||
|
--exclude '*.timer'
|
||||||
)
|
)
|
||||||
|
|
||||||
while (( $# )); do
|
while (( $# )); do
|
||||||
|
@@ -99,6 +99,10 @@ artixpkg_repo_move() {
|
|||||||
|
|
||||||
update_yaml_move "${SRC}" "${DEST}"
|
update_yaml_move "${SRC}" "${DEST}"
|
||||||
|
|
||||||
|
if [[ -f .SRCINFO ]]; then
|
||||||
|
rm .SRCINFO
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n $(git status --porcelain --untracked-files=no) ]]; then
|
if [[ -n $(git status --porcelain --untracked-files=no) ]]; then
|
||||||
|
|
||||||
stat_busy 'Staging files'
|
stat_busy 'Staging files'
|
||||||
|
Reference in New Issue
Block a user