Compare commits

..

10 Commits

Author SHA1 Message Date
52e51b2b49 Merge branch 'artools/0.34.x' into no-shallow 2024-04-15 11:46:46 +02:00
52617ccb58 Merge pull request 'artixpkg: read optional env.txt file on import' (#127) from env-list into artools/0.34.x
Reviewed-on: artix/artools#127
Reviewed-by: Cory Sanin <corysanin@artixlinux.org>
2024-04-15 11:46:38 +02:00
5165e7d9b2 Merge branch 'artools/0.34.x' into env-list 2024-04-15 11:46:23 +02:00
335499b83e Merge pull request 'artixpkg: add a config option for patching maintainer line on import' (#126) from patch-maintainer into artools/0.34.x
Reviewed-on: artix/artools#126
Reviewed-by: Cory Sanin <corysanin@artixlinux.org>
2024-04-15 11:46:13 +02:00
f7a597f9a3 Merge branch 'artools/0.34.x' into patch-maintainer 2024-04-15 11:45:51 +02:00
7b89b421d3 Merge pull request 'artixpkg: fix ci subcommand completions' (#130) from corysanin/artools:ci-completion into artools/0.34.x
Reviewed-on: artix/artools#130
2024-04-15 11:45:25 +02:00
70e7fbaf14 artixpkg: fix ci subcommand completions 2024-04-14 20:27:26 -05:00
caf3a3a24e artixpkg: no shallow clone 2024-04-08 10:06:56 -05:00
74a9d0296b artixpkg: read optional env.txt file on import
For integration with artix-patches. Simple key-value pairs are read and
exported as environment variables.
2024-04-05 17:24:41 -05:00
c40718c027 artixpkg: add a config option for patching maintainer line on import 2024-04-05 12:56:28 -05:00
9 changed files with 38 additions and 254 deletions

View File

@@ -116,7 +116,6 @@ install_pkg: binprogs_pkg
ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides
install -Dm0644 $(BUILDDIR)/contrib/completion/bash/artixpkg $(DESTDIR)$(PREFIX)/share/bash-completion/completions/artixpkg
install -Dm0644 $(BUILDDIR)/contrib/completion/zsh/_artixpkg $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_artixpkg
install_iso: binprogs_iso
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)

View File

@@ -40,7 +40,4 @@
# AGENTS=(orion taurus)
# whether to include custom maintainer line when importing from arch
# PATCH_MAINTAINER=false
# override the default git url for patches repo
# PATCH_URL=${GIT_SSH}:artix/artix-patches.git
# PATCH_MAINTAINER=yes

View File

@@ -8,14 +8,6 @@ _artixpkg_pkgbase() {
ls -1 "${TREE_DIR_ARTIX}" | tr '\n' ' '
}
_artixpkg_remotepkgbase() {
curl -s "https://checkupdates.artixlinux.org/api/1.0/packages?startswith=$1"
}
_artixpkg_maintainers() {
curl -s "https://checkupdates.artixlinux.org/api/1.0/maintainers"
}
_artixpkg_completion() {
local cur prev comps comps_all repos autorepos teams agents cwords comp_cword_exflag
source "${LIBDIR}"/pkg/db/db.sh 2>/dev/null
@@ -155,15 +147,12 @@ _artixpkg_completion() {
"-t"|"--team")
COMPREPLY=($(compgen -W "$teams" -- ${cur}))
;;
"-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-s"|"--search"|"-j"|"--jobs")
"-m"|"--maintainer"|"-s"|"--search"|"-t"|"--team"|"-j"|"--jobs")
# these flags expect a parameter
COMPREPLY=()
;;
*)
COMPREPLY=($(compgen -W "-m --maintainer --protocol -s --search -t --team -a --agent -j --jobs --all -h --help $(_artixpkg_remotepkgbase ${cur})" -- ${cur}))
COMPREPLY=($(compgen -W "-m --maintainer --protocol -s --search -t --team -a --agent -j --jobs --all -h --help" -- ${cur}))
;;
esac
;;
@@ -196,10 +185,7 @@ _artixpkg_completion() {
;;
"artixpkg git pull"*)
case "${prev}" in
"-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-t"|"--topic"|"-j"|"--jobs")
"-t"|"--topic"|"-m"|"--maintainer"|"-j"|"--jobs")
# these flags expect a parameter
COMPREPLY=()
;;
@@ -217,10 +203,7 @@ _artixpkg_completion() {
;;
"artixpkg git push"*)
case "${prev}" in
"-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-t"|"--topic"|"-j"|"--jobs")
"-m"|"--maintainer"|"-t"|"--topic"|"-j"|"--jobs")
# this flag expects a parameter
COMPREPLY=()
;;
@@ -251,10 +234,7 @@ _artixpkg_completion() {
;;
"artixpkg admin query"*)
case "${prev}" in
"-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-t"|"--topic")
"-m"|"--maintainer"|"-t"|"--topic")
# this flag expects a parameter
COMPREPLY=()
;;

View File

@@ -1,205 +0,0 @@
#compdef artixpkg
local -a addcmd admincmd cicmd clonecmd configcmd createcmd gitcmd importcmd \
initialcmd maintainercmd movecmd querycmd pullcmd pushcmd removecmd \
repocmd showcmd teamcmd topiccmd transfercmd versioncmd
_regex_words maintainer '' \
'-a' \
'--adopt' \
'-h' \
'--help' \
'-o' \
'--orphan'
maintainercmd=("$reply[@]")
_regex_words query '' \
'-h' \
'--help' \
'-m' \
'-t'
querycmd=("$reply[@]")
_regex_words team '' \
'-a' \
'--add' \
'-c' \
'--check' \
'-h' \
'--help' \
'-r' \
'--remove'
teamcmd=("$reply[@]")
_regex_words topic '' \
'-a' \
'--add' \
'-d' \
'--delete' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-r' \
'--remove'
topiccmd=("$reply[@]")
_regex_words transfer '' \
'-h' \
'--help'
transfercmd=("$reply[@]")
_regex_words admin '' \
'-h:Help text' \
'--help:Help text' \
'maintainer:Manage repo maintainer:$maintainercmd' \
'query:Query maintainers and topics:$querycmd' \
'team:Manage repo team:$teamcmd' \
'topic:Manage topics:$topiccmd' \
'transfer:Transfer obsolete repositories to landfill:$transfercmd'
admincmd=("$reply[@]")
_regex_words ci '' \
'-a' \
'--agent' \
'-h' \
'--help'
cicmd=("$reply[@]")
_regex_words clone '' \
'-a' \
'--agent' \
'--all' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-m' \
'--maintainer' \
'--protocol' \
'-s' \
'--search' \
'-t' \
'--team'
clonecmd=("$reply[@]")
_regex_words config '' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'--protocol'
configcmd=("$reply[@]")
_regex_words create '' \
'-a' \
'--agent' \
'-c' \
'--create' \
'-h' \
'--help' \
'-t' \
'--team'
createcmd=("$reply[@]")
_regex_words pull '' \
'--all' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-m' \
'--maintainer' \
'-t' \
'--topic'
pullcmd=("$reply[@]")
_regex_words push '' \
'-h' \
'--help' \
'-j' \
'--jobs' \
'-m' \
'--maintainer' \
'-t' \
'--topic'
pushcmd=("$reply[@]")
_regex_words git '' \
'ci:Configure CI agent:$cicmd' \
'clone:Clone a package:$clonecmd' \
'config:Configure a clone:$configcmd' \
'create:Create a new gitea package repository:$createcmd' \
'-h:Help text' \
'--help:Help text' \
'pull:Pull a package repository:$pullcmd' \
'push:Push a package repository:$pushcmd'
gitcmd=("$reply[@]")
_regex_words add '' \
'-h' \
'--help' \
'-n' \
'--nocheck' \
'-p' \
'--push' \
'-r' \
'--rebuild'
addcmd=("$reply[@]")
_regex_words import '' \
'--del' \
'-h' \
'--help' \
'--tag'
importcmd=("$reply[@]")
_regex_words move '' \
'-h' \
'--help' \
'-p' \
'--push'
movecmd=("$reply[@]")
_regex_words remove '' \
'-h' \
'--help' \
'-p' \
'--push'
removecmd=("$reply[@]")
_regex_words show '' \
'-b' \
'--base' \
'-h' \
'--help' \
'-p' \
'--pkgs'
showcmd=("$reply[@]")
_regex_words repo '' \
'add:Add pkgbase to repo:$addcmd' \
'-h:Help text' \
'--help:Help text' \
'import:Import latest tag from arch upstream:$importcmd' \
'move:Move pkgbase between repos:$movecmd' \
'remove:Remove pkgbase from repo:$removecmd' \
'show:Show pkgbase repo db:$showcmd'
repocmd=("$reply[@]")
_regex_words version '' \
'-h' \
'--help'
versioncmd=("$reply[@]")
_regex_words initial '' \
'admin:Manage topics:$admincmd' \
'git:Manage git:$gitcmd' \
'-h:Help text' \
'--help:Help text' \
'repo:Pacman database modification:$repocmd' \
'version:Show artixpkg version:$versioncmd'
initialcmd=("$reply[@]")
_regex_arguments _artixpkg /$'[^\0]##\0'/ "${initialcmd[@]}"
_artixpkg "$@"

View File

@@ -33,7 +33,6 @@ artixpkg_git_ci() {
local AGENT=${AGENTS[0]}
local SWITCH=0
local CREATED=0
# variables
local path realpath pkgbase
@@ -98,8 +97,6 @@ artixpkg_git_ci() {
git add "${REPO_CI}"
git commit -m "add ci support"
CREATED=1
fi
if [[ ! -f ${REPO_DB} ]]; then
@@ -114,17 +111,14 @@ artixpkg_git_ci() {
fi
git add "${REPO_DB}"
git commit -m "create repo db"
fi
if (( SWITCH )); then
msg "Switching to agent (${AGENT}) ..."
write_jenkinsfile "${AGENT}"
if (( ! CREATED )); then
git add "${REPO_CI}"
git commit -m "switch agent"
fi
git add "${REPO_CI}"
git commit -m "switch agent"
fi
)

View File

@@ -16,12 +16,14 @@ artixpkg_git_push_usage() {
OPTIONS
-m, --maintainer NAME Push all packages of the named maintainer
-t, --topic NAME Push all packages of the named topic
-j, --jobs N Run up to N jobs in parallel (default: $(nproc))
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} libfoo linux libbar
$ ${COMMAND} --maintainer tux
$ ${COMMAND} --topic mytopic
$ ${COMMAND} -j 8 --topic mytopic
_EOF_
}
@@ -36,6 +38,11 @@ artixpkg_git_push() {
# options
local MAINTAINER=
local TOPIC=
local CONFIGURE_OPTIONS=()
local jobs=
jobs=$(nproc)
local command=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
while (( $# )); do
case $1 in
@@ -53,6 +60,11 @@ artixpkg_git_push() {
TOPIC="$2"
shift 2
;;
-j|--jobs)
(( $# <= 1 )) && die "missing argument for %s" "$1"
jobs=$2
shift 2
;;
--)
shift
break
@@ -78,6 +90,19 @@ artixpkg_git_push() {
mapfile -t pkgbases < <(search_topic "${TOPIC}" | yq -P -r '.data | .[].name' | sort)
fi
# parallelization
if [[ ${jobs} != 1 ]] && (( ${#pkgbases[@]} > 1 )); then
# force colors in parallel if parent process is colorized
if [[ -n ${BOLD} ]]; then
export ARTOOLS_COLOR=always
fi
if ! parallel --bar --jobs "${jobs}" "${command}" ::: "${pkgbases[@]}"; then
die 'Failed to push some packages, please check the output'
exit 1
fi
exit 0
fi
for pkgbase in "${pkgbases[@]}"; do
if [[ -d ${pkgbase} ]]; then
( cd "${pkgbase}" || return

View File

@@ -12,12 +12,12 @@ PATCHDIR=${PATCHDIR:-"${WORKSPACE_DIR}/artix-patches"}
update_patches(){
if [[ ! -d "${PATCHDIR}" ]]; then
# ${GIT_ORG}
if ! git clone "${PATCH_URL}" "${PATCHDIR}"; then
error "failed to clone %s" "${PATCHDIR}"
if ! git clone "${GIT_SSH}:artix/artix-patches.git" "${PATCHDIR}"; then
>&2 echo 'failed to clone %s' "${PATCHDIR}"
fi
else
if ! git -C "${PATCHDIR}" pull; then
error "Failed to pull artix-patches"
>&2 echo "Failed to pull artix-patches"
fi
fi
}
@@ -30,7 +30,7 @@ patch_pkgbase(){
-e 's|arch-meson|artix-meson|' \
-i PKGBUILD
if "${PATCH_MAINTAINER}" && [ -n "${PACKAGER}" ]; then
if [ "${PATCH_MAINTAINER}" = "yes" ] && [ -n "${PACKAGER}" ]; then
sed -e 's|# Maintainer:|# Contributor:|' -i PKGBUILD
printf '%s\n%s\n' "# Maintainer: ${PACKAGER}" "$(cat "PKGBUILD")" >"PKGBUILD"
fi

View File

@@ -60,10 +60,6 @@ load_pkg_config(){
DBEXT=${DBEXT:-'gz'}
PATCH_MAINTAINER=${PATCH_MAINTAINER:-false}
PATCH_URL=${PATCH_URL:-"${GIT_SSH}:artix/artix-patches.git"}
if [[ -z "${AGENTS[*]}" ]]; then
AGENTS=(orion taurus)
fi

View File

@@ -181,9 +181,7 @@ else
set_arch="${CARCH}"
fi
chroot_args=(/usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/bin)
${CARCH:+setarch "${set_arch}"} chroot "${working_dir}" "${chroot_args[@]}" "$@"
${CARCH:+setarch "${set_arch}"} chroot "${working_dir}" "$@"
ret=$?