Compare commits

..

5 Commits

Author SHA1 Message Date
fbcfa79426 artixpkg admin: config archive org (#112)
All checks were successful
Artools shellcheck / lint (push) Successful in 42s
Reviewed-on: #112
2024-03-21 23:31:05 +01:00
87bd203d3e artixpkg: rename completion and update "admin topic" args (#113)
All checks were successful
Artools shellcheck / lint (push) Successful in 51s
bash completion file needs to be the same name as the command it's for

Reviewed-on: #113
Co-authored-by: Cory Sanin <corysanin@artixlinux.org>
Co-committed-by: Cory Sanin <corysanin@artixlinux.org>
2024-03-21 23:29:51 +01:00
ac0472d9ff Merge pull request 'artixpkg admin: add --delete topics' (#111) from rm-all-topics into master
All checks were successful
Artools shellcheck / lint (push) Successful in 45s
Reviewed-on: #111
2024-03-21 02:21:31 +01:00
e80c07d2fc artixpkg admin: add --delete topics
All checks were successful
Artools shellcheck / lint (pull_request) Successful in 46s
2024-03-21 02:04:11 +01:00
7584684bea artixpkg admin: archive repo after landfill transfer (#109)
All checks were successful
Artools shellcheck / lint (push) Successful in 48s
Reviewed-on: #109
Co-authored-by: Artoo <artoo@artixlinux.org>
Co-committed-by: Artoo <artoo@artixlinux.org>
2024-03-21 01:10:34 +01:00
7 changed files with 80 additions and 62 deletions

View File

@@ -115,7 +115,7 @@ install_pkg: binprogs_pkg
for a in $(SETARCH_ALIASES); do install -m0644 $$a -t $(DESTDIR)$(DATADIR)/setarch-aliases.d; done
ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides
install -Dm0644 $(BUILDDIR)/contrib/completion/bash/$(TOOLS) $(DESTDIR)$(PREFIX)/share/bash-completion/completions/$(TOOLS)
install -Dm0644 $(BUILDDIR)/contrib/completion/bash/artixpkg $(DESTDIR)$(PREFIX)/share/bash-completion/completions/artixpkg
install_iso: binprogs_iso
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)

View File

@@ -32,3 +32,6 @@
# default packaging org
# GIT_ORG='packages'
# default archiving org
# GIT_ORG_ARCHIVE='landfill'

View File

@@ -1,57 +1,20 @@
#/usr/bin/env bash
LIBDIR=${LIBDIR:-'@libdir@'}
_artixpkg_pkgbase() {
local LIBDIR
LIBDIR=${LIBDIR:-'/usr/share/artools/lib'}
source "${LIBDIR}"/pkg/git/config.sh
source "${LIBDIR}"/pkg/util.sh
ls -1 "${TREE_DIR_ARTIX}" | tr '\n' ' '
}
_artixpkg_completion() {
local cur prev comps comps_all repos autorepos teams agents ARTIX_DB ARTIX_TEAMS AGENTS ARTIX_DB_MAP cwords comp_cword_exflag
# TODO: get list, from /src/lib/pkg/db/db.sh?
ARTIX_DB=(
system-goblins
system-gremlins
system
world-goblins
world-gremlins
world
lib32-goblins
lib32-gremlins
lib32
galaxy-goblins
galaxy-gremlins
galaxy
)
# TODO: get from db.sh
ARTIX_TEAMS=(
"${ARTIX_DB[2]}"
"${ARTIX_DB[5]}"
"${ARTIX_DB[8]}"
"${ARTIX_DB[11]}"
)
# TODO: get from db.sh
AGENTS=(
orion
taurus
)
# TODO: get from db.sh
ARTIX_DB_MAP=(
goblins
gremlins
stable
)
local cur prev comps comps_all repos autorepos teams agents cwords comp_cword_exflag
source "${LIBDIR}"/pkg/db/db.sh 2>/dev/null
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
for ((i = COMP_CWORD - 1; i >= 0; i--)); do
if [[ ${COMP_WORDS[i]} != -* ]]; then
last_non_flag_word="${COMP_WORDS[i]}"
@@ -308,12 +271,12 @@ _artixpkg_completion() {
;;
"artixpkg admin topic"*)
case "${prev}" in
"-a"|"--add"|"-d"|"--del"|"-j"|"--jobs")
"-a"|"--add"|"-r"|"--remove"|"-j"|"--jobs")
# this flag expects a parameter
COMPREPLY=()
;;
*)
COMPREPLY=($(compgen -W "-a --add -d --del -j --jobs -h --help $(_artixpkg_pkgbase)" -- ${cur}))
COMPREPLY=($(compgen -W "-a --add -r --remove -d --del -j --jobs -h --help $(_artixpkg_pkgbase)" -- ${cur}))
;;
esac
;;

View File

@@ -15,15 +15,17 @@ artixpkg_admin_topic_usage() {
OPTIONS
-a, --add NAME Add a topic to repo
-d, --del NAME Delete a topic from repo
-r, --remove NAME Remove a topic from repo
-d, --delete Delete all topics from repo
-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} --remove mytopic libbar
$ ${COMMAND} --add mytopic libfoo libbar
$ ${COMMAND} --del mytopic libfoo libbar
$ ${COMMAND} --remove mytopic libfoo libbar
$ ${COMMAND} --delete libfoo
_EOF_
}
@@ -40,8 +42,9 @@ artixpkg_admin_topic() {
local pkgbase
local ADD_TOPIC
local DEL_TOPIC
local RM_TOPIC
local ADD=0
local RM=0
local DEL=0
local jobs=
jobs=$(nproc)
@@ -50,23 +53,28 @@ artixpkg_admin_topic() {
while (( $# )); do
case $1 in
-h|--help)
artixpkg_admin_topic_usage
exit 0
;;
-a|--add)
(( $# <= 1 )) && die "missing argument for %s" "$1"
ADD_TOPIC="$2"
ADD=1
RUNCMD+=" -a ${ADD_TOPIC}"
RUNCMD+=" $1 ${ADD_TOPIC}"
shift 2
;;
-d|--del)
-r|--remove)
(( $# <= 1 )) && die "missing argument for %s" "$1"
DEL_TOPIC="$2"
DEL=1
RUNCMD+=" -d ${DEL_TOPIC}"
RM_TOPIC="$2"
RM=1
RUNCMD+=" $1 ${RM_TOPIC}"
shift 2
;;
-h|--help)
artixpkg_admin_topic_usage
exit 0
-d|--delete)
DEL=1
RUNCMD+=" $1"
shift
;;
-j|--jobs)
(( $# <= 1 )) && die "missing argument for %s" "$1"
@@ -109,13 +117,19 @@ artixpkg_admin_topic() {
# topics meta
if (( ADD )); then
if ! add_topic "${gitname}" "${ADD_TOPIC}"; then
warning "failed to add the topic: ${ADD_TOPIC}"
warning "failed to add topic: ${ADD_TOPIC}"
fi
fi
if (( RM )); then
if ! remove_topic "${gitname}" "${RM_TOPIC}"; then
warning "failed to remove topic: ${RM_TOPIC}"
fi
fi
if (( DEL )); then
if ! remove_topic "${gitname}" "${DEL_TOPIC}"; then
warning "failed to delete the topic: ${DEL_TOPIC}"
if ! remove_all_topics "${gitname}" "${GIT_ORG}"; then
warning "failed to delete all topics: ${gitname}"
fi
fi

View File

@@ -33,7 +33,6 @@ artixpkg_admin_transfer() {
# options
local pkgbases=()
local pkgbase
local waste_org="landfill"
local command=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
@@ -63,7 +62,9 @@ artixpkg_admin_transfer() {
local gitname
gitname=$(get_compliant_name "${pkgbase}")
transfer_repo "${gitname}" "${waste_org}"
transfer_repo "${gitname}" "${GIT_ORG_ARCHIVE}"
archive_repo "${gitname}" "${GIT_ORG_ARCHIVE}"
remove_all_topics "${gitname}" "${GIT_ORG_ARCHIVE}"
done
fi
}

View File

@@ -78,7 +78,7 @@ transfer_repo() {
local pkgbase="$1"
local new_owner="$2"
local json url
json="{ \"new_owner\": \"$new_owner\", \"team_ids\": [] }"
json="{ \"new_owner\": \"$new_owner\", \"team_ids\": [], \"archived\": \"true\" }"
url="${API_URL}/repos/${GIT_ORG}/$pkgbase/transfer"
stat_busy "Transfer package repo [$pkgbase] in org ($new_owner)"
@@ -164,4 +164,39 @@ check_repo_team() {
stat_done
}
archive_repo() {
local pkgbase="$1"
local org="$2"
local url
local json
url="${API_URL}/repos/$org/$pkgbase"
json="{ \"archived\": true }"
stat_busy "Archive repo [$pkgbase] in org ($org)"
api_patch "$url" \
-H "accept: application/json" \
-H "content-type: application/json" \
-H "Authorization: token ${GIT_TOKEN}" \
-d "$json"
stat_done
}
remove_all_topics() {
local pkgbase="$1"
local org="$2"
local url
local json
url="${API_URL}/repos/$org/$pkgbase/topics"
json="{ \"topics\": [] }"
stat_busy "Delete all topics from [$pkgbase]"
api_put "$url" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: token ${GIT_TOKEN}" \
-d "$json"
stat_done
}
#}}}

View File

@@ -50,6 +50,8 @@ load_pkg_config(){
GIT_UPSTREAM_URL=${GIT_UPSTREAM_URL:-"https://gitlab.archlinux.org/archlinux/packaging/packages"}
GIT_ORG_ARCHIVE=${GIT_ORG_ARCHIVE:-'landfill'}
TREE_DIR_ARTIX=${TREE_DIR_ARTIX:-"${WORKSPACE_DIR}/artixlinux"}
REPOS_ROOT=${REPOS_ROOT:-"${WORKSPACE_DIR}/repos"}