From c4b485bca7df7e7b63ddeca25ed7d854aab59ef2 Mon Sep 17 00:00:00 2001 From: Erick Cafferata Date: Sat, 19 Jan 2019 15:51:04 -0500 Subject: add upstream option - add -u option. This makes asp32 behave as upstream's asp (skips arch32 patching) --- asp32.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-54-g00ecf From 4494fd2afb566fc906dcb86f01f93d58ca42da37 Mon Sep 17 00:00:00 2001 From: Erick Cafferata Date: Sat, 19 Jan 2019 15:56:00 -0500 Subject: update shell completion and documentation --- man/asp32.1.txt | 3 +++ shell/bash-completion | 2 +- shell/zsh-completion | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) 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/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' -- cgit v1.2.3-54-g00ecf From 8f9432ff83f64399f756260dc6d579d7af78ab96 Mon Sep 17 00:00:00 2001 From: Erick Cafferata Date: Sat, 19 Jan 2019 13:31:57 -0500 Subject: add support for patch to arch32 build - add package_patch_arch32() function - enables patching for export and checkout commands --- package.inc.sh | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/package.inc.sh b/package.inc.sh index da6a253..1f9f824 100644 --- a/package.inc.sh +++ b/package.inc.sh @@ -33,6 +33,12 @@ package_init() { remote_is_tracking "${!2}" "$pkgname" || remote_update_refs "${!2}" "packages/$pkgname" + + #fetch arch32/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() { @@ -121,6 +127,26 @@ 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/ || /any/) {print $1" "$2; exit}') + subtree=${1:-repos/${repo}-${arch}} + # borrowed from archlinux32/builder/lib/common-functions' mangle_pkgbuild() + sed -i ' + /^arch=[^#]*any/!{ + /^arch=(/s/(/(i486 i686 pentium3 / + } + ' "$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 @@ -153,12 +179,10 @@ package_export() { 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() { @@ -176,6 +200,10 @@ package_checkout() { --branch "$remote/packages/$pkgname" \ --config "pull.rebase=true" \ "$ASPROOT" "$pkgname" || return + + if ! (( OPT_UPSTREAM )); then + package_patch_arch32 + fi } package_get_repos_with_arch() { -- cgit v1.2.3-54-g00ecf From 23e50952efdc355fa3583baaef6accaf34efd0b6 Mon Sep 17 00:00:00 2001 From: Erick Cafferata Date: Thu, 31 Jan 2019 14:39:32 -0500 Subject: replace sed oneliner with awk Upstream asp depends only on awk for string manipulation. asp32 added a sed oneliner for inplace substitution (from builder repo). To avoid having to add an extra dependency for asp32, let's replace it with an awk equivalent. --- package.inc.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/package.inc.sh b/package.inc.sh index 1f9f824..2d7ead2 100644 --- a/package.inc.sh +++ b/package.inc.sh @@ -132,12 +132,8 @@ package_patch_arch32() { read -r repo arch < <(package_get_repos_with_arch "$pkgname" "$remote" \ | awk '!/testing/ && (/x86_64/ || /any/) {print $1" "$2; exit}') subtree=${1:-repos/${repo}-${arch}} - # borrowed from archlinux32/builder/lib/common-functions' mangle_pkgbuild() - sed -i ' - /^arch=[^#]*any/!{ - /^arch=(/s/(/(i486 i686 pentium3 / - } - ' "$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 -- cgit v1.2.3-54-g00ecf From b24995c644ac9c955daf7f0283f24eac24f5be41 Mon Sep 17 00:00:00 2001 From: Erick Cafferata Date: Fri, 1 Feb 2019 15:41:45 -0500 Subject: add checkout/export support for arch32-only packages --- package.inc.sh | 75 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/package.inc.sh b/package.inc.sh index 2d7ead2..5f1d961 100644 --- a/package.inc.sh +++ b/package.inc.sh @@ -31,8 +31,10 @@ package_init() { (( do_update )) || return 0 - remote_is_tracking "${!2}" "$pkgname" || - remote_update_refs "${!2}" "packages/$pkgname" + if ! [[ ${!2} = arch32__* ]]; then + remote_is_tracking "${!2}" "$pkgname" || + remote_update_refs "${!2}" "packages/$pkgname" + fi #fetch arch32/master #test if master exists, if not, then fetch(very slow first time) @@ -60,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 "arch32__"$1;exit}')" + if [[ $2 ]]; then + return 0 + fi + fi + return 1 } @@ -129,9 +140,15 @@ package_list_files() { package_patch_arch32() { local arch repo subtree - read -r repo arch < <(package_get_repos_with_arch "$pkgname" "$remote" \ - | awk '!/testing/ && (/x86_64/ || /any/) {print $1" "$2; exit}') + if [[ $remote == arch32__* ]]; then + arch=arch32 + repo=${remote#arch32__*} + else + read -r repo arch < <(package_get_repos_with_arch "$pkgname" "$remote" \ + | awk '!/testing/ && (/x86_64/ || /any/) {print $1" "$2; exit}') + fi 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 @@ -157,24 +174,26 @@ 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 = arch32__* ]]; 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 - fi - if (( ! OPT_FORCE )); then - # shellcheck disable=SC2154 - mkdir "$pkgname" || return - fi + if (( ! OPT_FORCE )); then + # shellcheck disable=SC2154 + mkdir "$pkgname" || return + fi - log_info 'exporting %s:%s' "$pkgname" "$subtree" - git archive --format=tar "remotes/$remote/packages/$pkgname" "$subtree/" | - tar --transform "s,^$subtree,$pkgname," -xf - "$subtree/" + log_info 'exporting %s:%s' "$pkgname" "$subtree" + git archive --format=tar "remotes/$remote/packages/$pkgname" "$subtree/" | + tar --transform "s,^$subtree,$pkgname," -xf - "$subtree/" + fi if ! (( OPT_UPSTREAM )); then package_patch_arch32 . @@ -187,15 +206,17 @@ 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 = arch32__* ]]; 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 + quiet_git clone \ + --shared \ + --single-branch \ + --branch "$remote/packages/$pkgname" \ + --config "pull.rebase=true" \ + "$ASPROOT" "$pkgname" || return + fi if ! (( OPT_UPSTREAM )); then package_patch_arch32 -- cgit v1.2.3-54-g00ecf From 58484a20c811c4eb2d158554f8fee7f345cda53a Mon Sep 17 00:00:00 2001 From: Erick Cafferata Date: Thu, 7 Feb 2019 14:48:56 -0500 Subject: fix detection of arch32-only packages - some value passed by reference was addressed wrongly. fixed --- package.inc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.inc.sh b/package.inc.sh index 5f1d961..4c5db80 100644 --- a/package.inc.sh +++ b/package.inc.sh @@ -66,7 +66,7 @@ package_find_remote() { 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 "arch32__"$1;exit}')" - if [[ $2 ]]; then + if [[ ${!2} ]]; then return 0 fi fi -- cgit v1.2.3-54-g00ecf From ae7317b856777e455984d675453d4884d9a59d39 Mon Sep 17 00:00:00 2001 From: Erick Cafferata Date: Wed, 6 Feb 2019 03:59:34 -0500 Subject: cleanup checkout/export support for arch32-only packages --- package.inc.sh | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/package.inc.sh b/package.inc.sh index 4c5db80..2650301 100644 --- a/package.inc.sh +++ b/package.inc.sh @@ -31,12 +31,12 @@ package_init() { (( do_update )) || return 0 - if ! [[ ${!2} = arch32__* ]]; then + if ! [[ ${!2} = packages32 ]]; then remote_is_tracking "${!2}" "$pkgname" || remote_update_refs "${!2}" "packages/$pkgname" fi - #fetch arch32/master + #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 @@ -65,7 +65,7 @@ package_find_remote() { # 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 "arch32__"$1;exit}')" + | awk -F/ -v pkg="${pkgname}" ' $0 ~ "/"pkg"/PKGBUILD" {print "packages32";exit}')" if [[ ${!2} ]]; then return 0 fi @@ -140,13 +140,8 @@ package_list_files() { package_patch_arch32() { local arch repo subtree - if [[ $remote == arch32__* ]]; then - arch=arch32 - repo=${remote#arch32__*} - else - read -r repo arch < <(package_get_repos_with_arch "$pkgname" "$remote" \ - | awk '!/testing/ && (/x86_64/ || /any/) {print $1" "$2; exit}') - fi + 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}' \ @@ -174,7 +169,7 @@ package_export() { subtree=repos/$repo-$OPT_ARCH fi - if ! [[ $remote = arch32__* ]]; then + 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" @@ -206,7 +201,7 @@ package_checkout() { package_init "$pkgname" remote || return - if ! [[ $remote = arch32__* ]]; then + if ! [[ $remote = packages32 ]]; then git show-ref -q "refs/heads/$remote/packages/$pkgname" || git branch -qf --no-track {,}"$remote/packages/$pkgname" @@ -227,12 +222,20 @@ 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() { -- cgit v1.2.3-54-g00ecf From 5cd27dc16d8b1ae256a97feb70c54490ca4f8d45 Mon Sep 17 00:00:00 2001 From: Erick Cafferata Date: Fri, 8 Feb 2019 17:21:07 -0500 Subject: add asp32 support for *log commands --- package.inc.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/package.inc.sh b/package.inc.sh index 2650301..dcdc331 100644 --- a/package.inc.sh +++ b/package.inc.sh @@ -95,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() { -- cgit v1.2.3-54-g00ecf