Compare commits

..

1 Commits

Author SHA1 Message Date
13d6f8ba37 artools/0.31rc (#75)
Co-authored-by: Artoo <artoo@artixlinux.org>
Reviewed-on: artix/artools#75
2023-06-22 20:19:42 +02:00
12 changed files with 163 additions and 89 deletions

View File

@@ -72,7 +72,7 @@ create_repo() {
local pkgbase="$1"
local url json
url="${GIT_HTTPS}/api/v1/org/${GIT_ORG}/repos"
json="{ \"auto_init\": true, \"name\": \"$pkgbase\", \"gitignores\": \"ArchLinuxPackages\", \"readme\": \"Default\" }"
json="{ \"auto_init\": true, \"name\": \"$pkgbase\", \"gitignores\": \"ArtixLinuxPackages\", \"readme\": \"Default\" }"
stat_busy "Create package repo [$pkgbase] in org (${GIT_ORG})"
api_post "$url" \

View File

@@ -277,3 +277,11 @@ show_db() {
yq -rP '. | .repos |= with_entries(select(.value.version))' "${REPO_DB}"
return 0
}
show_srcinfo_base() {
pkg2yaml . | yq '.pkgbase'
}
show_srcinfo_pkgs() {
pkg2yaml . | yq '.pkgnames'
}

View File

@@ -1,35 +0,0 @@
#!/hint/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
local_head(){
git log --pretty=%H ...refs/heads/master^ | head -n 1
}
remote_head(){
git ls-remote origin -h refs/heads/master | cut -f1
}
has_changeset(){
msg "Checking remote for changes"
if [[ "$(local_head)" != "$(remote_head)" ]]; then
msg2 "remote changes: yes"
return 0
fi
msg2 "remote changes: no"
return 1
}
commit_ci(){
local ci=Jenkinsfile
printf "@Library('artix-ci') import org.artixlinux.RepoPackage\n" > "${ci}"
{
printf '\n'
printf 'PackagePipeline(new RepoPackage(this))\n'
} >> "${ci}"
git add "${ci}"
git commit -m "initial ci commit"
}

View File

@@ -19,6 +19,14 @@ declare -rA REPO_MAP=(
[community]=galaxy
)
update_gitignore() {
{
printf '*.service\n'
printf '*.timer\n'
printf '*.socket\n'
} >> .gitignore
}
migrate_to_yaml() {
if [[ -f trunk/PKGBUILD ]]; then
cp -r trunk/* ./
@@ -62,6 +70,9 @@ migrate_to_yaml() {
if [[ -f .artixlinux/agent.yaml ]]; then
git rm .artixlinux/agent.yaml
fi
if [[ -f .gitignore ]]; then
update_gitignore
fi
git add .
git commit -m "migrate to new layout"
fi

View File

@@ -7,14 +7,25 @@ ARTOOLS_INCLUDE_GIT_CONFIG_SH=1
# shellcheck source=src/lib/pkg/db/db.sh
source "${LIBDIR}"/pkg/db/db.sh
# shellcheck source=src/lib/pkg/db/git.sh
source "${LIBDIR}"/pkg/db/git.sh
# shellcheck source=src/lib/pkg/db/migrate.sh
source "${LIBDIR}"/pkg/db/migrate.sh
set -e
commit_ci(){
local ci=Jenkinsfile
printf "@Library('artix-ci') import org.artixlinux.RepoPackage\n" > "${ci}"
{
printf '\n'
printf 'PackagePipeline(new RepoPackage(this))\n'
} >> "${ci}"
git add "${ci}"
git commit -m "initial ci commit"
}
artixpkg_git_config_usage() {
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
cat <<- _EOF_
@@ -201,7 +212,7 @@ artixpkg_git_config() {
for path in "${paths[@]}"; do
if ! realpath=$(realpath -e "${path}"); then
error "No such directory: ${path}"
# continue
continue
fi
pkgbase=$(basename "${realpath}")
@@ -210,7 +221,7 @@ artixpkg_git_config() {
if [[ ! -d "${path}/.git" ]]; then
error "Not a Git repository: ${path}"
# continue
continue
fi
( cd "${path}" || return
git config pull.rebase true
@@ -262,7 +273,7 @@ artixpkg_git_config() {
if [[ ! -f ${REPO_DB} ]]; then
msg "Adding repo db ..."
msg "Creating repo db ..."
create_repo_db
if [[ -f PKGBUILD ]]; then

View File

@@ -21,7 +21,6 @@ artixpkg_git_pull_usage() {
-t, --topic=NAME Pull all packages of the named topic
-j, --jobs N Run up to N jobs in parallel (default: $(nproc))
--universe Pull all existing packages
--fetch Fetch only
-h, --help Show this help text
EXAMPLES
@@ -42,7 +41,6 @@ artixpkg_git_pull() {
# options
local PULL_ALL=0
local FETCH=0
local MAINTAINER=
local TOPIC=
local CONFIGURE_OPTIONS=()
@@ -79,10 +77,6 @@ artixpkg_git_pull() {
PULL_ALL=1
shift
;;
--fetch)
FETCH=1
shift
;;
-j|--jobs)
(( $# <= 1 )) && die "missing argument for %s" "$1"
jobs=$2
@@ -140,17 +134,12 @@ artixpkg_git_pull() {
for pkgbase in "${pkgbases[@]}"; do
if [[ -d ${pkgbase} ]]; then
( cd ${pkgbase} || return
if (( FETCH )); then
msg "Fetching ${pkgbase} ..."
if ! git fetch origin; then
die 'failed to fetch %s' "${pkgbase}"
fi
else
msg "Pulling ${pkgbase} ..."
if ! git pull origin master; then
die 'failed to pull %s' "${pkgbase}"
fi
msg "Pulling ${pkgbase} ..."
if ! git pull origin master; then
die 'failed to pull %s' "${pkgbase}"
fi
)
else
warning "Skip pulling ${pkgbase}: Directory does not exist"

View File

@@ -5,9 +5,6 @@
[[ -z ${ARTOOLS_INCLUDE_REPO_ADD_SH:-} ]] || return 0
ARTOOLS_INCLUDE_REPO_ADD_SH=1
# shellcheck source=src/lib/pkg/db/git.sh
source "${LIBDIR}"/pkg/db/git.sh
set -e
@@ -88,10 +85,6 @@ artixpkg_repo_add() {
fi
( cd "${pkgbase}" || return
# if has_changeset; then
# die "Remote changes detected! Please pull (%s)" "${pkgbase}"
# fi
if [[ ! -f PKGBUILD ]]; then
die "No PKGBUILD found in (%s)" "${pkgbase}"
fi

View File

@@ -98,10 +98,6 @@ artixpkg_repo_import() {
fi
( cd "${pkgbase}" || return
# if has_changeset; then
# die "Remote changes detected! Please pull (%s)" "${pkgbase}"
# fi
stat_busy "Checking for upstream url"
if ! git config --local --get remote.upstream.url &>/dev/null; then
git remote add upstream "${GIT_UPSTREAM_URL}/${pkgbase}".git

View File

@@ -5,9 +5,6 @@
[[ -z ${ARTOOLS_INCLUDE_REPO_MOVE_SH:-} ]] || return 0
ARTOOLS_INCLUDE_REPO_MOVE_SH=1
# shellcheck source=src/lib/pkg/db/git.sh
source "${LIBDIR}"/pkg/db/git.sh
set -e
@@ -83,10 +80,6 @@ artixpkg_repo_move() {
fi
( cd "${pkgbase}" || return
# if has_changeset; then
# die "Remote changes detected! Please pull (%s)" "${pkgbase}"
# fi
if [[ ! -f PKGBUILD ]]; then
die "No PKGBUILD found in (%s)" "${pkgbase}"
fi

View File

@@ -5,9 +5,6 @@
[[ -z ${ARTOOLS_INCLUDE_REPO_REMOVE_SH:-} ]] || return 0
ARTOOLS_INCLUDE_REPO_REMOVE_SH=1
# shellcheck source=src/lib/pkg/db/git.sh
source "${LIBDIR}"/pkg/db/git.sh
set -e
@@ -75,10 +72,6 @@ artixpkg_repo_remove() {
fi
( cd "${pkgbase}" || return
# if has_changeset; then
# die "Remote changes detected! Please pull (%s)" "${pkgbase}"
# fi
if [[ ! -f PKGBUILD ]]; then
die "No PKGBUILD found in (%s)" "${pkgbase}"
fi

114
src/lib/pkg/repo/show.sh Normal file
View File

@@ -0,0 +1,114 @@
#!/hint/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
[[ -z ${ARTOOLS_INCLUDE_REPO_SHOW_SH:-} ]] || return 0
ARTOOLS_INCLUDE_REPO_SHOW_SH=1
set -e
has_changeset(){
git fetch origin &>/dev/null
if [[ $(git rev-parse HEAD) != $(git rev-parse @{u}) ]]; then
msg2 "remote changes: yes"
return 0
fi
msg2 "remote changes: no"
return 1
}
artixpkg_repo_show_usage() {
local -r COMMAND=${_ARTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
cat <<- _EOF_
Usage: ${COMMAND} [OPTIONS] [DEST_REPO] [PKGBASE]...
OPTIONS
-b, --base Show srcinfo base
-p, --pkgs Show srcinfo pkgs
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} libfoo
$ ${COMMAND} -b libfoo
$ ${COMMAND} -p libfoo
_EOF_
}
artixpkg_repo_show() {
if (( $# < 1 )); then
artixpkg_repo_show_usage
exit 0
fi
# options
local pkgbases=()
local pkgbase
local SRC_BASE=0
local SRC_PKGS=0
while (( $# )); do
case $1 in
-h|--help)
artixpkg_repo_show_usage
exit 0
;;
-b|--base)
SRC_BASE=1
shift
;;
-p|--pkgs)
SRC_PKGS=1
shift
;;
-*)
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
msg "Checking origin for changes"
if has_changeset; then
warning "Remote changes detected! Please update (%s)" "${pkgbase}"
fi
if [[ ! -f PKGBUILD ]]; then
die "No PKGBUILD found in (%s)" "${pkgbase}"
fi
msg "Querying ${pkgbase} ..."
if ! show_db; then
warning "Could not query ${REPO_DB}"
fi
if (( SRC_BASE )); then
msg "Showing srcinfo base ..."
show_srcinfo_base
fi
if (( SRC_PKGS )); then
msg "Showing srcinfo pkgs ..."
show_srcinfo_pkgs
fi
)
fi
done
}

View File

@@ -46,7 +46,7 @@ pkgbuild_extract_to_yaml() {
if get_pkgbuild_attribute "$pkgname" "$attrname" "$isarray" 'outvalue'; then
[[ -z $pkgname ]] && srcyaml_write_attr 2 4 2 "$attrname" "${outvalue[@]}"
[[ -n $pkgname ]] && srcyaml_write_attr 6 8 4 "$attrname" "${outvalue[@]}"
[[ -n $pkgname ]] && srcyaml_write_attr 4 6 2 "$attrname" "${outvalue[@]}"
fi
}
@@ -82,12 +82,8 @@ yaml_write_global() {
noextract options backup
source validpgpkeys "${known_hash_algos[@]/%/sums}")
local version
version=$(get_full_version)
Yaml+=$(write_yaml_map 0 "pkgbase")
Yaml+=$(write_yaml_map 2 "name" "${pkgbase:-${pkgname}}")
Yaml+=$(write_yaml_map 2 "version" "${version}")
srcyaml_write_section_details ""
}
@@ -97,9 +93,9 @@ yaml_write_package() {
local multivalued=(arch groups license checkdepends depends optdepends
provides conflicts replaces options backup)
Yaml+=$(write_yaml_map 2 "packages")
Yaml+=$(write_yaml_map 0 "pkgnames")
for pkg in "${pkgname[@]}"; do
Yaml+=$(write_yaml_seq_map 4 "pkgname" "$pkg")
Yaml+=$(write_yaml_seq_map 2 "pkgname" "$pkg")
srcyaml_write_section_details "$pkg"
done
}
@@ -108,6 +104,11 @@ write_srcyaml() {
Yaml=$(write_yaml_header)
yaml_write_global
yaml_write_package
# local version
# version=$(get_full_version)
# Yaml+=$(write_yaml_map 2 "version" "${version}")
printf '%s\n' "${Yaml}"
}