Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/package.inc.sh
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2017-03-25 08:59:38 -0400
committerDave Reisner <dreisner@archlinux.org>2017-03-25 09:18:50 -0400
commitc2b33327aa7b8faf3c88aeaa007e7eb4bba4869f (patch)
tree15b46e42eb771e2c095e31ba7e27ee3fe6dcab02 /package.inc.sh
parentf638242d6e81b72f8e0ea11a4f8c3c84099fd5b6 (diff)
Handle split packages
When a basic lookup fails, attempt to resolve the package name through archweb to get the pkgbase, under the assumption that this might be a split package. This adds jq as a new dependency. Closes #8.
Diffstat (limited to 'package.inc.sh')
-rw-r--r--package.inc.sh57
1 files changed, 41 insertions, 16 deletions
diff --git a/package.inc.sh b/package.inc.sh
index a415415..a0515c9 100644
--- a/package.inc.sh
+++ b/package.inc.sh
@@ -1,13 +1,32 @@
+package_resolve() {
+ local pkgbase
+
+ [[ -v pkgname ]] || log_fatal 'BUG: package_resolve called without pkgname var set'
+
+ if package_find_remote "$1" "$2"; then
+ return 0
+ fi
+
+ if pkgbase=$(archweb_get_pkgbase "$1") && package_find_remote "$pkgbase" "$2"; then
+ log_info '%s is part of package %s' "$1" "$pkgbase"
+ printf -v pkgname %s "$pkgbase"
+ return 0
+ fi
+
+ log_error 'unknown package: %s' "$pkgname"
+}
+
package_init() {
- local do_update=1 pkgname=$1
+ local do_update=1
if [[ $1 = -n ]]; then
do_update=0
shift
- pkgname=$1
fi
- package_find_remote "$pkgname" "$2" || return 1
+ pkgname=$1
+
+ package_resolve "$pkgname" "$2" || return 1
(( do_update )) || return 0
@@ -16,7 +35,7 @@ package_init() {
}
package_find_remote() {
- local pkgname=$1
+ pkgname=$1
# fastpath, checks local caches only
for r in "${ARCH_GIT_REPOS[@]}"; do
@@ -34,13 +53,12 @@ package_find_remote() {
fi
done
- log_error 'unknown package: %s' "$pkgname"
-
return 1
}
package_log() {
- local pkgname=$1 method=$2 logargs remote
+ local method=$2 logargs remote
+ pkgname=$1
package_init "$pkgname" remote || return
@@ -63,7 +81,8 @@ package_log() {
}
package_show_file() {
- local pkgname=$1 file=${2:-PKGBUILD} remote repo subtree
+ local file=${2:-PKGBUILD} remote repo subtree
+ pkgname=$1
if [[ $pkgname = */* ]]; then
IFS=/ read -r repo pkgname <<<"$pkgname"
@@ -83,7 +102,8 @@ package_show_file() {
}
package_list_files() {
- local pkgname=$1 remote
+ local remote
+ pkgname=$1
if [[ $pkgname = */* ]]; then
IFS=/ read -r repo pkgname <<<"$pkgname"
@@ -103,7 +123,8 @@ package_list_files() {
}
package_export() {
- local pkgname=$1 remote repo arch path
+ local remote repo arch path
+ pkgname=$1
if [[ $pkgname = */* ]]; then
IFS=/ read -r repo pkgname <<<"$pkgname"
@@ -138,7 +159,8 @@ package_export() {
}
package_checkout() {
- local pkgname=$1 remote
+ local remote
+ pkgname=$1
package_init "$pkgname" remote || return 1
@@ -152,8 +174,8 @@ package_checkout() {
}
package_get_repos_with_arch() {
- local pkgname=$1 remote=$2
- local path arch repo
+ local remote=$2 path arch repo
+ pkgname=$1
while read -r path; do
IFS=/- read -r _ repo arch <<<"$path"
@@ -162,8 +184,9 @@ package_get_repos_with_arch() {
}
package_get_arches() {
- local pkgname=$1 remote arch
+ local remote arch
declare -A arches
+ pkgname=$1
package_init "$pkgname" remote || return 1
@@ -175,8 +198,9 @@ package_get_arches() {
}
package_get_repos() {
- local pkgname=$1 remote repo
+ local remote repo
declare -A repos
+ pkgname=$1
package_init "$pkgname" remote || return 1
@@ -188,7 +212,8 @@ package_get_repos() {
}
package_untrack() {
- local pkgname=$1 remote=$2
+ local remote=$2
+ pkgname=$1
if git show-ref -q "refs/heads/$remote/packages/$pkgname"; then
git branch -D "$remote/packages/$pkgname"