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(-) (limited to 'package.inc.sh') 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(-) (limited to 'package.inc.sh') 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(-) (limited to 'package.inc.sh') 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(-) (limited to 'package.inc.sh') 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(-) (limited to 'package.inc.sh') 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(-) (limited to 'package.inc.sh') 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