Compare commits

...

8 Commits
0.30 ... 0.30.2

Author SHA1 Message Date
f8075b7bd4 artixpkg: fix more help examples 2023-05-23 21:53:02 +02:00
0912e6f74a artixpkg: update all help 2023-05-22 23:31:01 +02:00
9af4fe14f2 artixpkg: fix repo help examples 2023-05-22 23:25:23 +02:00
943350f4ec artixpkg: fix repo help cmd 2023-05-22 23:17:08 +02:00
e8075e436d merge branch 'bug-fixes' 2023-05-22 22:49:35 +02:00
48804b67f1 artixpkg git: fix redirection 2023-05-22 22:22:47 +02:00
cf60c6f544 artixpkg repo import: fix typo 2023-05-22 17:38:16 +02:00
e39aeb62ca merge branch 'import' 2023-05-22 17:26:27 +02:00
10 changed files with 130 additions and 22 deletions

View File

@@ -2,6 +2,11 @@
#{{{ base conf
prepare_dir(){
[[ ! -d $1 ]] && mkdir -p "$1"
return 0
}
if [[ -n $SUDO_USER ]]; then
eval "USER_HOME=~$SUDO_USER"
else
@@ -10,10 +15,7 @@ fi
USER_CONF_DIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/artools"
prepare_dir(){
[[ ! -d $1 ]] && mkdir -p "$1"
return 0
}
prepare_dir "${USER_CONF_DIR}"
load_base_config(){
@@ -33,7 +35,8 @@ load_base_config(){
#}}}
load_base_config "${USER_CONF_DIR}" || load_base_config "${SYSCONFDIR}"
prepare_dir "${WORKSPACE_DIR}"
prepare_dir "${USER_CONF_DIR}"

View File

@@ -2,6 +2,15 @@
#{{{ gitea api
get_compliant() {
local name=$1
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
@@ -90,7 +99,7 @@ transfer_repo() {
list_all_repos() {
local url
url="${GIT_URL}/api/v1/orgs/packages/repos"
url="${GIT_URL}/api/v1/orgs/packages/repos?limit=10000"
api_get "$url" \
-H "accept: application/json"

View File

@@ -22,8 +22,9 @@ artixpkg_git_usage() {
EXAMPLES
$ ${COMMAND} clone libfoo linux libbar
$ ${COMMAND} clone --maintainer mynickname
$ ${COMMAND} config *
$ ${COMMAND} clone --maintainer maintainer-mynickname
$ ${COMMAND} config -t libfoo
$ ${COMMAND} config -u libfoo
$ ${COMMAND} create libfoo
_EOF_
}

View File

@@ -16,7 +16,7 @@ artixpkg_git_config_usage() {
OPTIONS
-t, --topic Set the maintainer topic via gitea api
-u, --upstream add upstream arch remote
-u, --upstream Add upstream arch remote
-j, --jobs N Run up to N jobs in parallel (default: $(nproc))
-h, --help Show this help text
@@ -217,7 +217,7 @@ artixpkg_git_config() {
local topic gitname
topic="maintainer-${packager_name}"
gitname=$(get_compliant_name "${pkgbase}")
if ! add_topic "${gitname}" "${topic}" >/dev/null; then
if ! add_topic "${gitname}" "${topic}"; then
warning "failed to set the maintainer topic: ${topic}"
fi
fi
@@ -225,7 +225,7 @@ artixpkg_git_config() {
if (( UPSTREAM )); then
local remote_url
remote_url="${GIT_UPSTREAM_URL}/$pkgbase".git
if ! git remote add upstream "${remote_url}" >/dev/null; then
if ! git remote add upstream "${remote_url}"; then
warning "failed to set the upstream: ${remote_url}"
fi
fi

View File

@@ -19,7 +19,7 @@ artixpkg_git_create_usage() {
OPTIONS
-c, --clone Clone the Git repository after creation
-t, --team=NAME Clone the Git repository after creation
-t, --team=NAME Assign team name [default: world]
-h, --help Show this help text
EXAMPLES

View File

@@ -8,7 +8,7 @@ ARTOOLS_INCLUDE_REPO_SH=1
set -e
artixpkg_repo_usage() {
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
cat <<- _EOF_
Usage: ${COMMAND} [COMMAND] [OPTIONS]
@@ -16,14 +16,16 @@ artixpkg_repo_usage() {
add add and commit pkg to repo
move move and commit pkg between repos
remove remove and commit pkg from repo
import import latest tag from arch upstream
OPTIONS
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} add libfoo extra
$ ${COMMAND} remove libfoo extra
$ ${COMMAND} move libfoo extra-testing extra
$ ${COMMAND} add extra libfoo
$ ${COMMAND} remove extra libfoo
$ ${COMMAND} move extra-testing extra libfoo
$ ${COMMAND} import libfoo
_EOF_
}
@@ -60,7 +62,7 @@ artixpkg_repo() {
add)
_ARTOOLS_COMMAND+=" $1"
shift
# shellcheck source=lib/repo/add.sh
# shellcheck source=lib/pkg/repo/add.sh
source "${LIBDIR}"/pkg/repo/add.sh
artixpkg_repo_add "$@"
exit 0
@@ -68,7 +70,7 @@ artixpkg_repo() {
move)
_ARTOOLS_COMMAND+=" $1"
shift
# shellcheck source=lib/repo/move.sh
# shellcheck source=lib/pkg/repo/move.sh
source "${LIBDIR}"/pkg/repo/move.sh
artixpkg_repo_move "$@"
exit 0
@@ -76,11 +78,19 @@ artixpkg_repo() {
remove)
_ARTOOLS_COMMAND+=" $1"
shift
# shellcheck source=lib/repo/remove.sh
# shellcheck source=lib/pkg/repo/remove.sh
source "${LIBDIR}"/pkg/repo/remove.sh
artixpkg_repo_remove "$@"
exit 0
;;
import)
_ARTOOLS_COMMAND+=" $1"
shift
# shellcheck source=lib/pkg/repo/import.sh
source "${LIBDIR}"/pkg/repo/import.sh
artixpkg_repo_import "$@"
exit 0
;;
-*)
die "invalid argument: %s" "$1"
;;

View File

@@ -24,7 +24,7 @@ artixpkg_repo_add_usage() {
EXAMPLES
$ ${COMMAND} extra-testing libfoo
$ ${COMMAND} -p extra-testing libfoo
$ ${COMMAND} -tp extra-testing libfoo
$ ${COMMAND} -t -p extra-testing libfoo
_EOF_
}

85
lib/pkg/repo/import.sh Normal file
View File

@@ -0,0 +1,85 @@
#!/hint/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
[[ -z ${ARTOOLS_INCLUDE_REPO_IMPORT_SH:-} ]] || return 0
ARTOOLS_INCLUDE_REPO_IMPORT_SH=1
set -e
artixpkg_repo_import_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
_EOF_
}
artixpkg_repo_import() {
if (( $# < 1 )); then
artixpkg_repo_import_usage
exit 0
fi
# options
local pkgbases=()
local pkgbase
while (( $# )); do
case $1 in
-h|--help)
artixpkg_repo_import_usage
exit 0
;;
-*)
die "invalid argument: %s" "$1"
;;
*)
break
;;
esac
done
pkgbases+=("$@")
for pkgbase in "${pkgbases[@]}"; do
if [[ -d "${pkgbase}" ]];then
if [[ ! -d "${pkgbase}/.git" ]]; then
error "Not a Git repository: ${pkgbase}"
continue
fi
( cd "${pkgbase}" || return
stat_busy "Checking for upstream url"
if ! git config --local --get remote.upstream.url &>/dev/null; then
git remote add upstream https://gitlab.archlinux.org/archlinux/packaging/packages/${pkgbase}.git
fi
stat_done
stat_busy "Fetching upstream tags"
git fetch upstream --tags
stat_done
local latest
latest=$(git describe --tags FETCH_HEAD)
stat_busy "Importing upstream changeset for ${latest}"
git checkout "${latest}" -b "${latest}" &>/dev/null
temp=$(mktemp -d --tmpdir "${pkgbase}.XXXXXXXXXX")
local rsync_args=(-aWxvci --progress --delete-before --no-R --no-implied-dirs --exclude '.git')
rsync "${rsync_args[@]}" "$(pwd)"/ "${temp}"/ &>/dev/null
git checkout master &>/dev/null
git branch -D "${latest}" &>/dev/null
rsync "${rsync_args[@]}" "${temp}"/ "$(pwd)"/trunk/ &>/dev/null
stat_done
)
fi
done
}

View File

@@ -21,7 +21,7 @@ artixpkg_repo_move_usage() {
EXAMPLES
$ ${COMMAND} extra-testing extra libfoo
$ ${COMMAND} -p extra-testing extra libfoo
$ ${COMMAND} -tp extra-testing extra libfoo
$ ${COMMAND} -t -p extra-testing extra libfoo
_EOF_
}

View File

@@ -21,7 +21,7 @@ artixpkg_repo_remove_usage() {
EXAMPLES
$ ${COMMAND} extra-testing libfoo
$ ${COMMAND} -p extra-testing libfoo
$ ${COMMAND} -tp extra-testing libfoo
$ ${COMMAND} -t -p extra-testing libfoo
_EOF_
}