Compare commits

..

7 Commits

Author SHA1 Message Date
20bb1bb92a artixpkg: enable admin 2023-06-26 15:36:02 +02:00
4b9a6b9314 artixpkg: add admin subcmd 2023-06-26 15:36:02 +02:00
10fe40eccb artixpkg: make maintainer flags consistent 2023-06-26 15:33:16 +02:00
6ce9a5b751 artixpkg: fix repo args (#79)
Co-authored-by: Artoo <artoo@artixlinux.org>
Reviewed-on: artix/artools#79
2023-06-26 15:10:30 +02:00
108dcf620a migrate-ci (#78)
Co-authored-by: Artoo <artoo@artixlinux.org>
Reviewed-on: artix/artools#78
2023-06-25 17:16:55 +02:00
7fc2909a29 Merge pull request 'Add other kernels to patch_pkgbase()' (#77) from Qontinuum/artools:master into master
Reviewed-on: artix/artools#77
2023-06-25 17:16:22 +02:00
Qontinuum
f248c20401 Add other kernels to patch_pkgbase() 2023-06-24 14:56:24 +02:00
14 changed files with 179 additions and 66 deletions

55
src/lib/pkg/admin.sh Normal file
View File

@@ -0,0 +1,55 @@
#!/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

@@ -0,0 +1,64 @@
#!/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,24 +4,15 @@
#{{{ gitea api #{{{ gitea api
get_compliant() { get_compliant_name() {
local name=$1 local name=$1
printf "%s" "${name}" \ printf "%s\n" "${name}" \
| sed -E 's/([a-zA-Z0-9]+)\+([a-zA-Z]+)/\1-\2/g' \ | sed -E 's/([a-zA-Z0-9]+)\+([a-zA-Z]+)/\1-\2/g' \
| sed -E 's/\+/plus/g' \ | sed -E 's/\+/plus/g' \
| sed -E 's/[^a-zA-Z0-9_\-\.]/-/g' \ | sed -E 's/[^a-zA-Z0-9_\-\.]/-/g' \
| sed -E 's/[_\-]{2,}/-/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() { api_put() {
curl -s -X PUT "$@" curl -s -X PUT "$@"
} }
@@ -107,23 +98,6 @@ list_all_repos() {
-H "accept: application/json" -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() { list_topics() {
local url local url
local pkgbase="$1" local pkgbase="$1"

View File

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

View File

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

View File

@@ -17,12 +17,12 @@ artixpkg_git_clone_usage() {
Usage: ${COMMAND} [OPTIONS] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS OPTIONS
-m, --maintainer=NAME Clone all packages of the named maintainer -m, --maintainer=NAME Clone all packages of the named maintainer
--protocol https Clone the repository over https --protocol https Clone the repository over https
-t, --topic=NAME Clone all packages of the named topic -t, --topic=NAME Clone all packages of the named topic
-j, --jobs N Run up to N jobs in parallel (default: $(nproc)) -j, --jobs N Run up to N jobs in parallel (default: $(nproc))
--universe Clone all existing packages, useful for cache warming --universe Clone all existing packages, useful for cache warming
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} libfoo linux libbar $ ${COMMAND} libfoo linux libbar

View File

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

View File

@@ -19,9 +19,9 @@ artixpkg_git_create_usage() {
Usage: ${COMMAND} [OPTIONS] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS OPTIONS
-c, --clone Clone the Git repository after creation -c, --clone Clone the Git repository after creation
-t, --team=NAME Assign team name [default: world] -t, --team=NAME Assign team name [default: world]
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} libfoo $ ${COMMAND} libfoo

View File

@@ -17,11 +17,11 @@ artixpkg_git_pull_usage() {
Usage: ${COMMAND} [OPTIONS] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
OPTIONS OPTIONS
-m, --maintainer=NAME Pull all packages of the named maintainer -m, --maintainer=NAME Pull all packages of the named maintainer
-t, --topic=NAME Pull all packages of the named topic -t, --topic=NAME Pull all packages of the named topic
-j, --jobs N Run up to N jobs in parallel (default: $(nproc)) -j, --jobs N Run up to N jobs in parallel (default: $(nproc))
--universe Pull all existing packages --universe Pull all existing packages
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} libfoo linux libbar $ ${COMMAND} libfoo linux libbar

View File

@@ -17,11 +17,11 @@ artixpkg_repo_usage() {
Usage: ${COMMAND} [COMMAND] [OPTIONS] Usage: ${COMMAND} [COMMAND] [OPTIONS]
COMMANDS COMMANDS
add Add built pkgbase to repo add Add built pkgbase to repo
move Move built pkgbase between repos move Move built pkgbase between repos
remove Remove built pkgbase from repo remove Remove built pkgbase from repo
import Import latest tag from arch upstream import Import latest tag from arch upstream
show Show the pkgbase's repo db show Show the pkgbase's repo db
OPTIONS OPTIONS
-h, --help Show this help text -h, --help Show this help text

View File

@@ -14,10 +14,10 @@ artixpkg_repo_add_usage() {
Usage: ${COMMAND} [OPTIONS] [DEST_REPO] [PKGBASE]... Usage: ${COMMAND} [OPTIONS] [DEST_REPO] [PKGBASE]...
OPTIONS OPTIONS
-p, --push Push pkgbase -p, --push Push pkgbase
-r, --rebuild Triggers a rebuild -r, --rebuild Triggers a rebuild
-n, --nocheck Disable the check function -n, --nocheck Disable the check function
-h, --help Show this help text -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} world-gremlins libfoo $ ${COMMAND} world-gremlins libfoo
@@ -69,6 +69,7 @@ artixpkg_repo_add() {
done done
DEST="$1" DEST="$1"
shift
pkgbases+=("$@") pkgbases+=("$@")
if ! in_array "${DEST}" "${ARTIX_DB[@]}"; then if ! in_array "${DEST}" "${ARTIX_DB[@]}"; then

View File

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

View File

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

View File

@@ -68,6 +68,14 @@ while (( $# )); do
artixpkg_git "$@" artixpkg_git "$@"
exit 0 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) version|--version|-V)
_ARTOOLS_COMMAND+=" $1" _ARTOOLS_COMMAND+=" $1"
shift shift