diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | Makefile | 21 | ||||
-rw-r--r-- | README.md | 18 | ||||
-rw-r--r-- | asp32.in (renamed from asp.in) | 25 | ||||
-rw-r--r-- | man/asp32.1.txt (renamed from man/asp.1.txt) | 30 | ||||
-rw-r--r-- | package.inc.sh | 142 | ||||
-rw-r--r-- | shell/bash-completion | 10 | ||||
-rw-r--r-- | shell/zsh-completion | 1 |
8 files changed, 183 insertions, 69 deletions
@@ -1,2 +1,3 @@ -asp -asp.1 +asp32 +asp32.1 +asp32-*.tar.gz* @@ -1,14 +1,14 @@ -PACKAGE_NAME = asp +PACKAGE_NAME = asp32 VERSION := $(shell git describe --dirty 2>/dev/null) PREFIX = /usr/local BINPROGS = \ - asp + asp32 MANPAGES = \ - man/asp.1 + man/asp32.1 BASH_COMPLETION = \ shell/bash-completion @@ -38,8 +38,8 @@ man/%: man/%.txt Makefile $(V_GEN) a2x \ -d manpage \ -f manpage \ - -a manversion="$(PACKAGE_NAME) $(VERSION)" \ - -a manmanual="$(PACKAGE_NAME) manual" $< + -a manversion="asp32 $(VERSION)" \ + -a manmanual="asp32 manual" $< check: $(BINPROGS) @for f in $(BINPROGS); do bash -O extglob -n $$f; done @@ -54,7 +54,14 @@ install: all install -dm755 $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/share/man/man1 install -m755 $(BINPROGS) $(DESTDIR)$(PREFIX)/bin install -m644 $(MANPAGES) $(DESTDIR)$(PREFIX)/share/man/man1 - install -Dm644 $(BASH_COMPLETION) $(DESTDIR)$(PREFIX)/share/bash-completion/completions/asp - install -Dm644 $(ZSH_COMPLETION) $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_asp + install -Dm644 $(BASH_COMPLETION) $(DESTDIR)$(PREFIX)/share/bash-completion/completions/asp32 + install -Dm644 $(ZSH_COMPLETION) $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_asp32 + +dist: + git archive --format=tar --prefix=asp32-$(VERSION)/ $(VERSION) | gzip -9 > asp32-$(VERSION).tar.gz + gpg --detach-sign --use-agent asp32-$(VERSION).tar.gz + +upload: + scp asp32-$(VERSION).tar.gz asp32-$(VERSION).tar.gz.sig sources.archlinux32.org:sources/ .PHONY: all clean install @@ -1,6 +1,10 @@ -# asp +# asp32 -`asp` is a tool to manage the build source files used to create Arch Linux +asp32 is a fork of `asp` to work with the Archlinux32 packages. +It is currently hosted on https://git.archlinux32.org/archlinux32/asp32. +The original for Archlinux can be found at https://github.com/falconindy/asp. + +`asp32` is a tool to manage the build source files used to create Arch Linux packages. It replaces the `abs` tool, offering more up to date sources (via the svntogit repositories) and uses a sparse checkout model to conserve diskspace. This probably won't be interesting to users who want a full checkout (for @@ -9,26 +13,26 @@ whatever reason that may be). # Setup None! Though, it should be noted that the `ASPROOT` environment variable -will control where `asp` keeps its local git repo. By default, this is -`${XDG_CACHE_HOME:-$HOME/.cache}/asp`. +will control where `asp32` keeps its local git repo. By default, this is +`${XDG_CACHE_HOME:-$HOME/.cache}/asp32`. # Examples Get the source files for some packages: ~~~ -asp export pacman testing/systemd extra/pkgfile +asp32 export pacman testing/systemd extra/pkgfile ~~~ Get a fully functional git checkout of a single package: ~~~ -asp checkout pkgfile +asp32 checkout pkgfile ~~~ List the repositories a package has been pushed to: ~~~ -asp list-repos pacman +asp32 list-repos pacman ~~~ @@ -1,11 +1,12 @@ #!/bin/bash ASP_VERSION=@ASP_VERSION@ -ARCH_GIT_REPOS=(packages community) +ARCH_GIT_REPOS=(packages64 community64 packages32) OPT_ARCH=$(uname -m) OPT_FORCE=0 -: "${ASPROOT:=${XDG_CACHE_HOME:-$HOME/.cache}/asp}" +OPT_UPSTREAM=0 +: "${ASPROOT:=${XDG_CACHE_HOME:-$HOME/.cache}/asp32}" : "${ASPCACHE:=$ASPROOT/cache}" m4_include(util.inc.sh) @@ -15,7 +16,7 @@ m4_include(archweb.inc.sh) usage() { cat<<EOF -asp $ASP_VERSION [OPTIONS...] {COMMAND} ... +asp32 $ASP_VERSION [OPTIONS...] {COMMAND} ... Manage build sources for Arch packages. @@ -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: @@ -132,7 +134,11 @@ initialize() { if [[ ! -f $ASPROOT/.asp ]]; then git init -q "$ASPROOT" || return 1 for remote in "${ARCH_GIT_REPOS[@]}"; do - git remote add "$remote" "https://git.archlinux.org/svntogit/$remote.git" || return 1 + if [[ "${remote}" = *64 ]]; then + git remote add "$remote" "https://git.archlinux.org/svntogit/${remote%64}.git" || return 1 + elif [[ "${remote}" = *32 ]]; then + git remote add "$remote" "https://git.archlinux32.org/archlinux32/${remote%32}.git" || return 1 + fi done touch "$ASPROOT/.asp" || return 1 @@ -300,7 +306,11 @@ action__set-git-protocol() { esac for remote in "${ARCH_GIT_REPOS[@]}"; do - git remote set-url "$remote" "$1://git.archlinux.org/svntogit/$remote.git" + if [[ "${remote}" = *64 ]]; then + git remote set-url "$remote" "$1://git.archlinux.org/svntogit/${remote%64}.git" + elif [[ "${remote}" = *32 ]]; then + git remote set-url "$remote" "$1://git.archlinux32.org/archlinux32/${remote%32}.git" + fi done } @@ -338,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 @@ -350,6 +360,9 @@ while getopts ':a:fhV' flag; do usage exit 0 ;; + u) + OPT_UPSTREAM=1 + ;; V) version exit 0 diff --git a/man/asp.1.txt b/man/asp32.1.txt index 7b984e3..998c560 100644 --- a/man/asp.1.txt +++ b/man/asp32.1.txt @@ -1,23 +1,27 @@ ///// vim:set ts=4 sw=4 syntax=asciidoc noet: ///// -asp(1) -====== +asp32(1) +======== Name ---- -asp - Manage Arch Linux build sources +asp32 - Manage Arch Linux 32 build sources Synopsis -------- -asp [options] command [targets...] +asp32 [options] command [targets...] Description ----------- +The original script can be found at https://github.com/falconindy/asp. +This is a fork for the specific needs of the Archlinux32 project +(https://www.archlinux32.org). + Manage the version-controlled sources for the build scripts used to create Arch -Linux packages. This program provides a thin wrapper over the svntogit -repositories hosted at https://git.archlinux.org. It aims to provide a -replacement for abs which favors a sparse checkout. +Linux 32 packages. This program provides a thin wrapper over the svntogit +repositories hosted at https://git.archlinux.org and https://git.archlinux32.org/archlinux32/packages. +It aims to provide a replacement for abs which favors a sparse checkout. Commands -------- @@ -27,7 +31,7 @@ The following commands are understood: Create a new git repository containing the full source and history for each of the given targets. The new repository will pull from the repository in '$ASPROOT' and must be updated separately after using - 'asp update'. If a checkout occurs on the same filesystem as '$ASPROOT', + 'asp32 update'. If a checkout occurs on the same filesystem as '$ASPROOT', most of the metadata can be hard linked, making this a relatively cheap copy. @@ -105,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. @@ -112,7 +119,7 @@ Environment ----------- *ASPROOT*:: Determines where the metadata is stored for locally tracked packages. Defaults - to '`${XDG_CACHE_HOME:-$HOME/.cache}/asp`'. + to '`${XDG_CACHE_HOME:-$HOME/.cache}/asp32`'. *ASPCACHE*:: Determines where cached data is stored. Defaults to '$ASPROOT/cache'. Data in @@ -121,3 +128,8 @@ Environment Authors ------- Dave Reisner <d@falconindy.com> + +Motifications for Archlinux32 +----------------------------- +Andreas Baumann <mail@andreasbaumann.cc> +Erich Eckner <arch32@eckner.net> diff --git a/package.inc.sh b/package.inc.sh index 360e41f..8f5032d 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() { @@ -99,11 +122,17 @@ package_show_file() { fi fi + if ! (( OPT_UPSTREAM )); then + local trepo + read -r trepo _ < <(package_get_repos_with_arch "$pkgname" packages32) + [[ $trepo ]] && git show "remotes/packages32/master:$trepo/$pkgname/$file" 2>/dev/null \ + && return + fi git show "remotes/$remote/packages/$pkgname:$subtree$file" } package_list_files() { - local remote subtree=trunk + local remote subtree=trunk trepo list_ups list_dwn pkgname=$1 if [[ $pkgname = */* ]]; then @@ -116,9 +145,36 @@ package_list_files() { subtree=repos/$repo-$OPT_ARCH fi + list_ups=$(git ls-tree -r --name-only "remotes/$remote/packages/$pkgname" "$subtree" \ + 2>/dev/null | awk -v "prefix=$subtree/" 'sub(prefix, "")') - git ls-tree -r --name-only "remotes/$remote/packages/$pkgname" "$subtree" | - awk -v "prefix=$subtree/" 'sub(prefix, "")' + if ! (( OPT_UPSTREAM )); then + read -r trepo _ < <(package_get_repos_with_arch "$pkgname" packages32) + if [[ $trepo ]]; then + list_dwn=$(git ls-tree -r --name-only "remotes/packages32/master" "$trepo/$pkgname" | + awk -v "prefix=$trepo/$pkgname/" 'sub(prefix, "")') + [[ $list_ups ]] && printf -v list_ups "%s\n%s" "$list_ups" "$list_dwn" \ + || printf -v list_ups "%s" "$list_dwn" + fi + fi + echo "$list_ups" | sort -u +} + +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 pentium4 ")}; {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() { @@ -135,24 +191,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/" + if ! (( OPT_UPSTREAM )); then + package_patch_arch32 . + fi } package_checkout() { @@ -161,27 +223,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 3c7fc06..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 @@ -40,11 +40,11 @@ _asp() { word=${COMP_WORDS[i]} if in_array "$word" ${verbs[ALL_PACKAGES]}; then verb=$word - comps=$(ASP_GIT_QUIET=1 \asp list-all | sed 's,.*/,,') + comps=$(ASP_GIT_QUIET=1 \asp32 list-all | sed 's,.*/,,') break elif in_array "$word" ${verbs[LOCAL_PACKAGES]}; then verb=$word - comps=$(ASP_GIT_QUIET=1 \asp list-local | sed 's,.*/,,') + comps=$(ASP_GIT_QUIET=1 \asp32 list-local | sed 's,.*/,,') break elif in_array "$word" ${verbs[PROTO]}; then verb=$word @@ -60,7 +60,7 @@ _asp() { case $verb in show) if (( i < ${#COMP_WORDS[@]} - 2 )); then - comps=$(ASP_GIT_QUIET=1 \asp ls-files "${COMP_WORDS[i+1]}" 2>/dev/null) + comps=$(ASP_GIT_QUIET=1 \asp32 ls-files "${COMP_WORDS[i+1]}" 2>/dev/null) fi ;; '') @@ -73,4 +73,4 @@ _asp() { fi } -complete -F _asp asp +complete -F _asp asp32 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' |