Compare commits

...

7 Commits

Author SHA1 Message Date
828844fd9a artixpkg git push: remove parallel 2024-05-13 17:03:59 +02:00
760f5e8281 artools/0.34.x (#135)
Co-authored-by: Dudemanguy <dudemanguy@artixlinux.org>
Co-authored-by: Cory Sanin <corysanin@artixlinux.org>
Reviewed-on: artix/artools#135
2024-05-13 15:41:42 +02:00
bb1585ad7b add initial zsh completions (#132)
Not as advanced as the bash completions but better than nothing.

Co-authored-by: artoo <artoo@artixlinux.org>
Reviewed-on: artix/artools#132
Co-authored-by: Dudemanguy <dudemanguy@artixlinux.org>
Co-committed-by: Dudemanguy <dudemanguy@artixlinux.org>
2024-04-27 22:02:55 +02:00
be6506d6ee artixpkg git ci: fix team (#133)
Reviewed-on: artix/artools#133
2024-04-17 23:08:48 +02:00
35a9c2f305 artools/0.34.x (#131)
Co-authored-by: Dudemanguy <dudemanguy@artixlinux.org>
Co-authored-by: Cory Sanin <corysanin@artixlinux.org>
Reviewed-on: artix/artools#131
Co-authored-by: Artoo <artoo@artixlinux.org>
Co-committed-by: Artoo <artoo@artixlinux.org>
2024-04-17 17:05:39 +02:00
5347f45cc5 Merge pull request 'chroot-run: set PATH in chroot' (#129) from env-fix into master
Reviewed-on: artix/artools#129
2024-04-10 23:08:20 +02:00
c7f11a5bd5 chroot-run: set PATH in chroot 2024-04-10 23:05:38 +02:00
9 changed files with 274 additions and 49 deletions

View File

@@ -116,6 +116,7 @@ install_pkg: binprogs_pkg
ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides 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/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_iso: binprogs_iso
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/$(TOOLS) install -dm0755 $(DESTDIR)$(SYSCONFDIR)/$(TOOLS)

View File

@@ -38,3 +38,9 @@
# default jenkins agents # default jenkins agents
# AGENTS=(orion taurus) # 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

View File

@@ -8,6 +8,14 @@ _artixpkg_pkgbase() {
ls -1 "${TREE_DIR_ARTIX}" | tr '\n' ' ' 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() { _artixpkg_completion() {
local cur prev comps comps_all repos autorepos teams agents cwords comp_cword_exflag local cur prev comps comps_all repos autorepos teams agents cwords comp_cword_exflag
source "${LIBDIR}"/pkg/db/db.sh 2>/dev/null source "${LIBDIR}"/pkg/db/db.sh 2>/dev/null
@@ -70,7 +78,7 @@ _artixpkg_completion() {
case "${comp_cword_exflag}" in case "${comp_cword_exflag}" in
1) 1)
COMPREPLY=($(compgen -W "admin ci git repo version -h --help" -- "${cur}")) COMPREPLY=($(compgen -W "admin git repo version -h --help" -- "${cur}"))
return 0 return 0
;; ;;
2) 2)
@@ -78,11 +86,8 @@ _artixpkg_completion() {
admin) admin)
COMPREPLY=($(compgen -W "maintainer query team topic transfer -h --help" -- ${cur})) COMPREPLY=($(compgen -W "maintainer query team topic transfer -h --help" -- ${cur}))
;; ;;
ci)
COMPREPLY=($(compgen -W "config -h --help" -- ${cur}))
;;
git) git)
COMPREPLY=($(compgen -W "clone config create pull push -h --help" -- ${cur})) COMPREPLY=($(compgen -W "ci clone config create pull push -h --help" -- ${cur}))
;; ;;
repo) repo)
COMPREPLY=($(compgen -W "add remove move import show -h --help" -- ${cur})) COMPREPLY=($(compgen -W "add remove move import show -h --help" -- ${cur}))
@@ -150,12 +155,15 @@ _artixpkg_completion() {
"-t"|"--team") "-t"|"--team")
COMPREPLY=($(compgen -W "$teams" -- ${cur})) COMPREPLY=($(compgen -W "$teams" -- ${cur}))
;; ;;
"-m"|"--maintainer"|"-s"|"--search"|"-t"|"--team"|"-j"|"--jobs") "-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-s"|"--search"|"-j"|"--jobs")
# these flags expect a parameter # these flags expect a parameter
COMPREPLY=() COMPREPLY=()
;; ;;
*) *)
COMPREPLY=($(compgen -W "-m --maintainer --protocol -s --search -t --team -a --agent -j --jobs --all -h --help" -- ${cur})) COMPREPLY=($(compgen -W "-m --maintainer --protocol -s --search -t --team -a --agent -j --jobs --all -h --help $(_artixpkg_remotepkgbase ${cur})" -- ${cur}))
;; ;;
esac esac
;; ;;
@@ -188,7 +196,10 @@ _artixpkg_completion() {
;; ;;
"artixpkg git pull"*) "artixpkg git pull"*)
case "${prev}" in case "${prev}" in
"-t"|"--topic"|"-m"|"--maintainer"|"-j"|"--jobs") "-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-t"|"--topic"|"-j"|"--jobs")
# these flags expect a parameter # these flags expect a parameter
COMPREPLY=() COMPREPLY=()
;; ;;
@@ -206,7 +217,10 @@ _artixpkg_completion() {
;; ;;
"artixpkg git push"*) "artixpkg git push"*)
case "${prev}" in case "${prev}" in
"-m"|"--maintainer"|"-t"|"--topic"|"-j"|"--jobs") "-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-t"|"--topic"|"-j"|"--jobs")
# this flag expects a parameter # this flag expects a parameter
COMPREPLY=() COMPREPLY=()
;; ;;
@@ -215,17 +229,13 @@ _artixpkg_completion() {
;; ;;
esac esac
;; ;;
"artixpkg ci config"*) "artixpkg git ci"*)
case "${prev}" in case "${prev}" in
"-j"|"--jobs")
# this flag expects a parameter
COMPREPLY=()
;;
"-a"|"--agent") "-a"|"--agent")
COMPREPLY=($(compgen -W "$agents" -- ${cur})) COMPREPLY=($(compgen -W "$agents" -- ${cur}))
;; ;;
*) *)
COMPREPLY=($(compgen -W "-a --agent -s --switch -j --jobs -h --help $(_artixpkg_pkgbase)" -- ${cur})) COMPREPLY=($(compgen -W "-a --agent -h --help $(_artixpkg_pkgbase)" -- ${cur}))
;; ;;
esac esac
;; ;;
@@ -241,7 +251,10 @@ _artixpkg_completion() {
;; ;;
"artixpkg admin query"*) "artixpkg admin query"*)
case "${prev}" in case "${prev}" in
"-m"|"--maintainer"|"-t"|"--topic") "-m"|"--maintainer")
COMPREPLY=($(compgen -W "$(_artixpkg_maintainers)" -- ${cur}))
;;
"-t"|"--topic")
# this flag expects a parameter # this flag expects a parameter
COMPREPLY=() COMPREPLY=()
;; ;;

View File

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

View File

@@ -16,14 +16,12 @@ artixpkg_git_push_usage() {
OPTIONS OPTIONS
-m, --maintainer NAME Push all packages of the named maintainer -m, --maintainer NAME Push all packages of the named maintainer
-t, --topic NAME Push all packages of the named topic -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 -h, --help Show this help text
EXAMPLES EXAMPLES
$ ${COMMAND} libfoo linux libbar $ ${COMMAND} libfoo linux libbar
$ ${COMMAND} --maintainer tux $ ${COMMAND} --maintainer tux
$ ${COMMAND} --topic mytopic $ ${COMMAND} --topic mytopic
$ ${COMMAND} -j 8 --topic mytopic
_EOF_ _EOF_
} }
@@ -38,11 +36,6 @@ artixpkg_git_push() {
# options # options
local MAINTAINER= local MAINTAINER=
local TOPIC= local TOPIC=
local CONFIGURE_OPTIONS=()
local jobs=
jobs=$(nproc)
local command=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
while (( $# )); do while (( $# )); do
case $1 in case $1 in
@@ -60,11 +53,6 @@ artixpkg_git_push() {
TOPIC="$2" TOPIC="$2"
shift 2 shift 2
;; ;;
-j|--jobs)
(( $# <= 1 )) && die "missing argument for %s" "$1"
jobs=$2
shift 2
;;
--) --)
shift shift
break break
@@ -90,19 +78,6 @@ artixpkg_git_push() {
mapfile -t pkgbases < <(search_topic "${TOPIC}" | yq -P -r '.data | .[].name' | sort) mapfile -t pkgbases < <(search_topic "${TOPIC}" | yq -P -r '.data | .[].name' | sort)
fi 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 for pkgbase in "${pkgbases[@]}"; do
if [[ -d ${pkgbase} ]]; then if [[ -d ${pkgbase} ]]; then
( cd "${pkgbase}" || return ( cd "${pkgbase}" || return

View File

@@ -12,12 +12,12 @@ PATCHDIR=${PATCHDIR:-"${WORKSPACE_DIR}/artix-patches"}
update_patches(){ update_patches(){
if [[ ! -d "${PATCHDIR}" ]]; then if [[ ! -d "${PATCHDIR}" ]]; then
# ${GIT_ORG} # ${GIT_ORG}
if ! git clone --depth=1 "${GIT_SSH}:artix/artix-patches.git" "${PATCHDIR}"; then if ! git clone "${PATCH_URL}" "${PATCHDIR}"; then
>&2 echo 'failed to clone %s' "${PATCHDIR}" error "failed to clone %s" "${PATCHDIR}"
fi fi
else else
if ! git -C "${PATCHDIR}" pull; then if ! git -C "${PATCHDIR}" pull; then
>&2 echo "Failed to pull artix-patches" error "Failed to pull artix-patches"
fi fi
fi fi
} }
@@ -28,13 +28,26 @@ patch_pkgbase(){
sed -e 's|https://www.archlinux.org/|https://www.artixlinux.org/|' \ sed -e 's|https://www.archlinux.org/|https://www.artixlinux.org/|' \
-e 's|(Arch Linux)|(Artix Linux)|' \ -e 's|(Arch Linux)|(Artix Linux)|' \
-e 's|arch-meson|artix-meson|' \ -e 's|arch-meson|artix-meson|' \
-e 's|# Maintainer:|# Contributor:|' \
-i PKGBUILD -i PKGBUILD
if [ -n "${PACKAGER}" ]; then
if "${PATCH_MAINTAINER}" && [ -n "${PACKAGER}" ]; then
sed -e 's|# Maintainer:|# Contributor:|' -i PKGBUILD
printf '%s\n%s\n' "# Maintainer: ${PACKAGER}" "$(cat "PKGBUILD")" >"PKGBUILD" printf '%s\n%s\n' "# Maintainer: ${PACKAGER}" "$(cat "PKGBUILD")" >"PKGBUILD"
fi fi
if [ -d "${patches}" ]; then if [ -d "${patches}" ]; then
if [ -f "${patches}/env.txt" ]; then
while read -r line; do
IFS="=" read -r key value <<< "$line"
if [[ -z "${key}" ]] || [[ -z "${value}" ]]; then
die "Invalid key value pair in env.txt"
fi
if declare -p "${key}" &> /dev/null; then
die "Environment variable %s already exists." "${key}"
fi
export "${key}=${value}"
done < "${patches}/env.txt"
fi
for file in "${patches}"/*; do for file in "${patches}"/*; do
if [ -x "${file}" ]; then if [ -x "${file}" ]; then
echo "$> ${name}/$(basename "${file}")" echo "$> ${name}/$(basename "${file}")"

View File

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

View File

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