Compare commits

..

4 Commits
0.30 ... 0.30.1

Author SHA1 Message Date
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
5 changed files with 117 additions and 11 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

@@ -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

@@ -16,6 +16,7 @@ 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
@@ -60,7 +61,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 +69,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 +77,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"
;;

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
}