Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asp32.in7
-rw-r--r--man/asp32.1.txt3
-rw-r--r--package.inc.sh126
-rw-r--r--shell/bash-completion2
-rw-r--r--shell/zsh-completion1
5 files changed, 101 insertions, 38 deletions
diff --git a/asp32.in b/asp32.in
index e467a3e..6b384cc 100644
--- a/asp32.in
+++ b/asp32.in
@@ -5,6 +5,7 @@ ARCH_GIT_REPOS=(packages64 community64 packages32)
OPT_ARCH=$(uname -m)
OPT_FORCE=0
+OPT_UPSTREAM=0
: "${ASPROOT:=${XDG_CACHE_HOME:-$HOME/.cache}/asp32}"
: "${ASPCACHE:=$ASPROOT/cache}"
@@ -23,6 +24,7 @@ Options:
-a ARCH Specify an architecture other than the host's
-f Allow files to be overwritten
-h Show this help
+ -u Behave as upstream asp
-V Show package version
Package Commands:
@@ -346,7 +348,7 @@ dispatch_action() {
initialize || log_fatal 'failed to initialize asp repository in %s' "$ASPROOT"
-while getopts ':a:fhV' flag; do
+while getopts ':a:fhuV' flag; do
case $flag in
a)
OPT_ARCH=$OPTARG
@@ -358,6 +360,9 @@ while getopts ':a:fhV' flag; do
usage
exit 0
;;
+ u)
+ OPT_UPSTREAM=1
+ ;;
V)
version
exit 0
diff --git a/man/asp32.1.txt b/man/asp32.1.txt
index c91f987..998c560 100644
--- a/man/asp32.1.txt
+++ b/man/asp32.1.txt
@@ -109,6 +109,9 @@ Options
*-h*::
Print a short help text and exit.
+*-u*::
+ Force upstream asp behavior.
+
*-V*::
Print a short version string and exit.
diff --git a/package.inc.sh b/package.inc.sh
index da6a253..dcdc331 100644
--- a/package.inc.sh
+++ b/package.inc.sh
@@ -31,8 +31,16 @@ package_init() {
(( do_update )) || return 0
- remote_is_tracking "${!2}" "$pkgname" ||
- remote_update_refs "${!2}" "packages/$pkgname"
+ if ! [[ ${!2} = packages32 ]]; then
+ remote_is_tracking "${!2}" "$pkgname" ||
+ remote_update_refs "${!2}" "packages/$pkgname"
+ fi
+
+ #fetch packages32/master
+ #test if master exists, if not, then fetch(very slow first time)
+ if ! (( OPT_UPSTREAM )); then
+ git show-ref -q packages32/master || quiet_git fetch packages32 master
+ fi
}
package_find_remote() {
@@ -54,6 +62,15 @@ package_find_remote() {
fi
done
+ # arch32-only packages
+ if ! (( OPT_UPSTREAM )); then
+ printf -v "$2" %s "$(git ls-tree -r --name-only packages32/master \
+ | awk -F/ -v pkg="${pkgname}" ' $0 ~ "/"pkg"/PKGBUILD" {print "packages32";exit}')"
+ if [[ ${!2} ]]; then
+ return 0
+ fi
+ fi
+
return 1
}
@@ -78,7 +95,13 @@ package_log() {
;;
esac
- git log "${logargs[@]}" "$remote/packages/$pkgname" -- trunk/
+ if ! (( OPT_UPSTREAM )); then
+ repo=$(package_get_repos_with_arch "$pkgname" packages32|awk '{print $1}')
+ [[ $repo ]] && git log "${logargs[@]}" "packages32/master" -- "$repo/$pkgname" \
+ || log_info 'There is no Arch32 patch for %s' "$pkgname"
+ else
+ git log "${logargs[@]}" "$remote/packages/$pkgname" -- trunk/
+ fi
}
package_show_file() {
@@ -121,6 +144,23 @@ package_list_files() {
awk -v "prefix=$subtree/" 'sub(prefix, "")'
}
+package_patch_arch32() {
+ local arch repo subtree
+ read -r repo arch < <(package_get_repos_with_arch "$pkgname" "$remote" \
+ | awk '!/testing/ && (/x86_64/ || /arch32/ || /any/) {print $1" "$2; exit}')
+ subtree=${1:-repos/${repo}-${arch}}
+ mkdir -p ${pkgname}/${subtree} && touch ${pkgname}/${subtree}/PKGBUILD
+ awk -i inplace '!/^arch=[^#]*any/ {gsub(/^arch=\(/,"arch=(i486 i686 pentium3 ")}; {print}' \
+ "$pkgname/${subtree}/PKGBUILD"
+ for line in $(git ls-tree -r --name-only remotes/packages32/master ${repo}/${pkgname}); do
+ if [[ "${line##*/}" = "PKGBUILD" ]]; then
+ git show remotes/packages32/master:${line} >> ${pkgname}/${subtree}/PKGBUILD
+ else
+ git show remotes/packages32/master:${line} > ${pkgname}/${subtree}/${line##*/}
+ fi
+ done
+}
+
package_export() {
local remote repo arch path subtree=trunk
pkgname=$1
@@ -135,30 +175,30 @@ package_export() {
subtree=repos/$repo-$OPT_ARCH
fi
- if ! git show "remotes/$remote/packages/$pkgname:$subtree/" &>/dev/null; then
- if [[ $repo ]]; then
- log_error "package '%s' not found in repo '%s-%s'" "$pkgname" "$repo" "$OPT_ARCH"
- return 1
- else
- log_error "package '%s' has no trunk directory!" "$pkgname"
- return 1
+ if ! [[ $remote = packages32 ]]; then
+ if ! git show "remotes/$remote/packages/$pkgname:$subtree/" &>/dev/null; then
+ if [[ $repo ]]; then
+ log_error "package '%s' not found in repo '%s-%s'" "$pkgname" "$repo" "$OPT_ARCH"
+ return 1
+ else
+ log_error "package '%s' has no trunk directory!" "$pkgname"
+ return 1
+ fi
+ fi
+
+ if (( ! OPT_FORCE )); then
+ # shellcheck disable=SC2154
+ mkdir "$pkgname" || return
fi
- fi
- if (( ! OPT_FORCE )); then
- # shellcheck disable=SC2154
- mkdir "$pkgname" || return
+ log_info 'exporting %s:%s' "$pkgname" "$subtree"
+ git archive --format=tar "remotes/$remote/packages/$pkgname" "$subtree/" |
+ tar --transform "s,^$subtree,$pkgname," -xf - "$subtree/"
fi
- log_info 'exporting %s:%s' "$pkgname" "$subtree"
- git archive --format=tar "remotes/$remote/packages/$pkgname" "$subtree/" |
- tar --transform "s,^$subtree,$pkgname," -xf - "$subtree/"
- # borrowed from archlinux32/builder/lib/common-functions' mangle_pkgbuild()
- sed -i '
- /^arch=[^#]*any/!{
- /^arch=(/s/(/(i486 i686 pentium3 /
- }
- ' "$pkgname/PKGBUILD"
+ if ! (( OPT_UPSTREAM )); then
+ package_patch_arch32 .
+ fi
}
package_checkout() {
@@ -167,27 +207,41 @@ package_checkout() {
package_init "$pkgname" remote || return
- git show-ref -q "refs/heads/$remote/packages/$pkgname" ||
- git branch -qf --no-track {,}"$remote/packages/$pkgname"
+ if ! [[ $remote = packages32 ]]; then
+ git show-ref -q "refs/heads/$remote/packages/$pkgname" ||
+ git branch -qf --no-track {,}"$remote/packages/$pkgname"
+
+ quiet_git clone \
+ --shared \
+ --single-branch \
+ --branch "$remote/packages/$pkgname" \
+ --config "pull.rebase=true" \
+ "$ASPROOT" "$pkgname" || return
+ fi
- quiet_git clone \
- --shared \
- --single-branch \
- --branch "$remote/packages/$pkgname" \
- --config "pull.rebase=true" \
- "$ASPROOT" "$pkgname" || return
+ if ! (( OPT_UPSTREAM )); then
+ package_patch_arch32
+ fi
}
package_get_repos_with_arch() {
local remote=$2 path arch repo
pkgname=$1
- while read -r path; do
- path=${path##*/}
- repo=${path%-*}
- arch=${path##*-}
+ if [[ $remote == packages32 ]]; then
+ repo="$(git ls-tree -r --name-only packages32/master \
+ | awk -F/ -v pkg="${pkgname}" ' $0 ~ "/"pkg"/PKGBUILD" {print $1;exit}')"
+ [[ $repo ]] && arch=arch32
printf '%s %s\n' "$repo" "$arch"
- done < <(git ls-tree --name-only "remotes/$remote/packages/$pkgname" repos/)
+ else
+ while read -r path; do
+ path=${path##*/}
+ repo=${path%-*}
+ arch=${path##*-}
+ printf '%s %s\n' "$repo" "$arch"
+ done < <(git ls-tree --name-only "remotes/$remote/packages/$pkgname" repos/)
+ fi
+
}
package_get_arches() {
diff --git a/shell/bash-completion b/shell/bash-completion
index 3eebbd3..881ab3d 100644
--- a/shell/bash-completion
+++ b/shell/bash-completion
@@ -23,7 +23,7 @@ _asp() {
# flags
local -A opts=(
[UNKNOWN]='-a'
- [NONE]='-f -h -V'
+ [NONE]='-f -h -u -V'
)
if in_array "$prev" ${opts[UNKNOWN]}; then
diff --git a/shell/zsh-completion b/shell/zsh-completion
index 13ede7c..20aa550 100644
--- a/shell/zsh-completion
+++ b/shell/zsh-completion
@@ -43,6 +43,7 @@ _arguments \
'-a[architecture]' \
'-f[overwrite files]' \
'-h[print help and exit]' \
+ '-u[Force upstream asp behavior]' \
'-V[print version and exit]' \
'*::asp command:_asp_command'