Compare commits

..

1 Commits

Author SHA1 Message Date
0160524097 set repo topics on migrate 2023-06-23 18:22:50 +02:00
14 changed files with 66 additions and 179 deletions

View File

@@ -1,55 +0,0 @@
#!/hint/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
[[ -z ${ARTOOLS_INCLUDE_ADMIN_SH:-} ]] || return 0
ARTOOLS_INCLUDE_ADMIN_SH=1
set -e
artixpkg_admin_usage() {
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
cat <<- _EOF_
Usage: ${COMMAND} [COMMAND] [OPTIONS]
COMMANDS
transfer Clone a package repository
OPTIONS
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} transfer libfoo libbar
_EOF_
}
artixpkg_admin() {
if (( $# < 1 )); then
artixpkg_admin_usage
exit 0
fi
# option checking
while (( $# )); do
case $1 in
-h|--help)
artixpkg_admin_usage
exit 0
;;
transfer)
_ARTOOLS_COMMAND+=" $1"
shift
# shellcheck source=src/lib/pkg/admin/transfer.sh
source "${LIBDIR}"/pkg/admin/transfer.sh
artixpkg_admin_transfer "$@"
exit 0
;;
-*)
die "invalid argument: %s" "$1"
;;
*)
die "invalid command: %s" "$1"
;;
esac
done
}

View File

@@ -1,64 +0,0 @@
#!/bin/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
[[ -z ${ARTOOLS_INCLUDE_ADMIN_TRANSFER_SH:-} ]] || return 0
ARTOOLS_INCLUDE_ADMIN_TRANSFER_SH=1
set -e
artixpkg_admin_transfer_usage() {
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
cat <<- _EOF_
Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} libfoo
$ ${COMMAND} libfoo libbar
_EOF_
}
artixpkg_admin_transfer() {
if (( $# < 1 )); then
artixpkg_admin_transfer_usage
exit 0
fi
# options
local pkgbases=()
local pkgbase
local waste_org="landfill"
local command=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
while (( $# )); do
case $1 in
-h|--help)
artixpkg_admin_transfer_usage
exit 0
;;
--)
shift
break
;;
-*)
die "invalid argument: %s" "$1"
;;
*)
break
;;
esac
done
pkgbases+=("$@")
for pkgbase in "${pkgbases[@]}"; do
transfer_repo "${pkgbase}" "${waste_org}"
done
}

View File

@@ -4,15 +4,24 @@
#{{{ gitea api
get_compliant_name() {
get_compliant() {
local name=$1
printf "%s\n" "${name}" \
printf "%s" "${name}" \
| sed -E 's/([a-zA-Z0-9]+)\+([a-zA-Z]+)/\1-\2/g' \
| sed -E 's/\+/plus/g' \
| sed -E 's/[^a-zA-Z0-9_\-\.]/-/g' \
| sed -E 's/[_\-]{2,}/-/g'
}
get_compliant_name(){
local gitname="$1"
case "$gitname" in
*+) gitname=${gitname//+/plus} ;;
*+*) gitname=${gitname//+/-} ;;
esac
printf "%s\n" "$gitname"
}
api_put() {
curl -s -X PUT "$@"
}
@@ -98,6 +107,23 @@ list_all_repos() {
-H "accept: application/json"
}
replace_topic() {
local url
local repo="$1"
local maintainer="$2"
url="${GIT_HTTPS}/api/v1/repos/${GIT_ORG}/$repo/topics"
api_put "$url" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: token ${GIT_TOKEN}" \
-d "{
\"topics\": [
\"${maintainer}\"
]
}"
}
list_topics() {
local url
local pkgbase="$1"

View File

@@ -19,8 +19,6 @@ readonly ARTIX_DB=(
readonly REPO_DB='.artixlinux/pkgbase.yaml'
readonly REPO_CI='.artixlinux/Jenkinsfile'
yaml_array() {
local array

View File

@@ -70,7 +70,7 @@ migrate_to_yaml() {
topic="${REPO_MAP[$r]}"
if ! add_topic "${gitname}" "${topic}"; then
warning "failed to add topic: ${topic}"
warning "failed to set topic: ${topic}"
fi
topic="${r}"
@@ -89,11 +89,6 @@ migrate_to_yaml() {
if [[ -f .gitignore ]]; then
update_gitignore
fi
if [[ -f Jenkinsfile ]]; then
git mv Jenkinsfile "${REPO_CI}"
fi
git add .
git commit -m "migrate to new layout"
fi

View File

@@ -14,13 +14,15 @@ set -e
commit_ci(){
printf "@Library('artix-ci') import org.artixlinux.RepoPackage\n" > "${REPO_CI}"
local ci=Jenkinsfile
printf "@Library('artix-ci') import org.artixlinux.RepoPackage\n" > "${ci}"
{
printf '\n'
printf 'PackagePipeline(new RepoPackage(this))\n'
} >> "${REPO_CI}"
} >> "${ci}"
git add "${REPO_CI}"
git add "${ci}"
git commit -m "initial ci commit"
}
@@ -30,7 +32,7 @@ artixpkg_git_config_usage() {
Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS
-m, --maintainer Set the maintainer topic via gitea api
-t, --topic Set the maintainer topic via gitea api
-u, --upstream Add upstream arch remote
--protocol https Configure remote url to use https
-j, --jobs N Run up to N jobs in parallel (default: $(nproc))
@@ -115,7 +117,7 @@ artixpkg_git_config() {
artixpkg_git_config_usage
exit 0
;;
-m|--maintainer)
-t|--topic)
SET_TOPIC=1
shift
;;
@@ -264,12 +266,7 @@ artixpkg_git_config() {
migrate_to_yaml
if [[ -f Jenkinsfile ]]; then
git mv Jenkinsfile "${REPO_CI}"
git commit -m "move jenkinsfile"
fi
if [[ ! -f ${REPO_CI} ]]; then
if [[ ! -f Jenkinsfile ]]; then
msg "Adding ci support ..."
commit_ci
fi

View File

@@ -69,7 +69,6 @@ artixpkg_repo_add() {
done
DEST="$1"
shift
pkgbases+=("$@")
if ! in_array "${DEST}" "${ARTIX_DB[@]}"; then

View File

@@ -22,7 +22,7 @@ patch_pkgbase(){
-e '/nscd.service/d' \
-i "${pkgbuild}"
;;
linux|linux-lts|linux-zen|linux-hardened|linux-rt|linux-rt-lts)
linux|linux-lts)
msg "Patching %s" "${name}"
sed -e 's|KBUILD_BUILD_HOST=.*|KBUILD_BUILD_HOST=artixlinux|' -i "${pkgbuild}"
sed -e 's|CONFIG_DEFAULT_HOSTNAME=.*|CONFIG_DEFAULT_HOSTNAME="artixlinux"|' \
@@ -65,7 +65,7 @@ artixpkg_repo_import() {
local TAG
local rsync_args=()
rsync_args+=(-aWxvci --progress --delete-before --no-R --no-implied-dirs)
rsync_args+=(--exclude '.git' --exclude '.gitignore' --exclude 'README.md')
rsync_args+=(--exclude '.git' --exclude 'Jenkinsfile' --exclude '.gitignore' --exclude 'README.md')
while (( $# )); do
case $1 in

View File

@@ -56,7 +56,6 @@ artixpkg_repo_remove() {
done
DEST="$1"
shift
pkgbases=("$@")
if ! in_array "${DEST}" "${ARTIX_DB[@]}"; then

View File

@@ -68,14 +68,6 @@ while (( $# )); do
artixpkg_git "$@"
exit 0
;;
admin)
_ARTOOLS_COMMAND+=" $1"
shift
# shellcheck source=src/lib/pkg/admin.sh
source "${LIBDIR}"/pkg/admin.sh
artixpkg_admin "$@"
exit 0
;;
version|--version|-V)
_ARTOOLS_COMMAND+=" $1"
shift