From 16f2b17e2bb52856c43d1bb4f5e6affb558ceb67 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Tue, 2 Jan 2018 09:52:08 +0100 Subject: renamed to arch32 --- Makefile | 10 +- asp.in | 367 -------------------------------------------------------- asp32.in | 367 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ man/asp.1.txt | 123 ------------------- man/asp32.1.txt | 131 ++++++++++++++++++++ 5 files changed, 503 insertions(+), 495 deletions(-) delete mode 100644 asp.in create mode 100644 asp32.in delete mode 100644 man/asp.1.txt create mode 100644 man/asp32.1.txt diff --git a/Makefile b/Makefile index c545a05..2cb29cc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PACKAGE_NAME = asp +PACKAGE_NAME = asp32 VERSION = v3 VDEVEL = $(shell test -d .git && git describe --dirty 2>/dev/null) @@ -10,10 +10,10 @@ endif PREFIX = /usr/local BINPROGS = \ - asp + asp32 MANPAGES = \ - man/asp.1 + man/asp32.1 BASH_COMPLETION = \ shell/bash-completion @@ -55,8 +55,8 @@ 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=$(PACKAGE_NAME)-$(VERSION)/ $(VERSION) | gzip -9 > $(PACKAGE_NAME)-$(VERSION).tar.gz diff --git a/asp.in b/asp.in deleted file mode 100644 index 99f69fe..0000000 --- a/asp.in +++ /dev/null @@ -1,367 +0,0 @@ -#!/bin/bash - -ASP_VERSION=@ASP_VERSION@ -ARCH_GIT_REPOS=(packages community) - -OPT_ARCH=$(uname -m) -OPT_FORCE=0 -: ${ASPROOT:=${XDG_CACHE_HOME:-$HOME/.cache}/asp} -: ${ASPCACHE:=$ASPROOT/cache} - -m4_include(util.inc.sh) -m4_include(remote.inc.sh) -m4_include(package.inc.sh) -m4_include(archweb.inc.sh) - -usage() { - cat< max )); then - log_fatal '%s expects at most %d args, got %d' "${FUNCNAME[1]#action__}" "$max" "$argc" - elif (( argc < min )); then - log_fatal '%s expects at least %d args, got %d' "${FUNCNAME[1]#action__}" "$min" "$argc" - fi -} - -version() { - printf 'asp %s\n' "$ASP_VERSION" -} - -update_all() { - local r - - for r in "${ARCH_GIT_REPOS[@]}"; do - log_info "updating remote '%s'" "$r" - remote_update "$r" - done -} - -update_local_branches() { - local r=0 - - while read -r branchname; do - git branch -qf "$branchname" "refs/remotes/$branchname" || r=1 - done < <(git branch --no-color) - - return "$r" -} - -update_remote_branches() { - local refspecs=() remote pkgname - declare -A refspec_map - - if (( $# == 0 )); then - update_all - return - fi - - # map packages to remotes - for pkgname; do - package_init -n "$pkgname" remote || return 1 - refspec_map["$remote"]+=" packages/$pkgname" - done - - # update each remote all at once - for remote in "${!refspec_map[@]}"; do - read -ra refspecs <<<"${refspec_map["$remote"]}" - remote_update_refs "$remote" "${refspecs[@]}" - done -} - -update_packages() { - update_remote_branches "$@" && update_local_branches -} - -initialize() { - local remote - - umask 0022 - - export GIT_DIR=$ASPROOT/.git - - 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 - done - - touch "$ASPROOT/.asp" || return 1 - fi - - if [[ ! -d $ASPCACHE ]]; then - mkdir -p "$ASPCACHE" || return 1 - fi - - return 0 -} - -dump_packages() { - local remote refspecs dumpfn - - case $1 in - all) - dumpfn=remote_get_all_refs - ;; - local) - dumpfn=remote_get_tracked_refs - ;; - *) - die 'internal error: invalid dump type: "%s"' "$1" - ;; - esac - - for remote in "${ARCH_GIT_REPOS[@]}"; do - "$dumpfn" "$remote" refspecs - if [[ $refspecs ]]; then - printf '%s\n' "${refspecs[@]##*/}" - fi - done | sort -} - -list_local() { - dump_packages 'local' -} - -list_all() { - dump_packages 'all' -} - -shortlog() { - package_log "$@" "${FUNCNAME[0]}" -} - -log() { - package_log "$@" "${FUNCNAME[0]}" -} - -difflog() { - package_log "$@" "${FUNCNAME[0]}" -} - -gc() { - git gc --prune=all -} - -untrack() { - local pkgname=$1 remote - - package_init -n "$pkgname" remote || return 1 - - remote_untrack "$remote" "$pkgname" - package_untrack "$pkgname" "$remote" -} - -disk_usage() { - local usage - read usage _ < <(du -sh "$ASPROOT") - - log_info 'Using %s on disk.' "$usage" -} - -action__checkout() { - __require_argc 1- $# - map package_checkout "$@" -} - -action__difflog() { - __require_argc 1 $# - difflog "$1" -} - -action__disk-usage() { - __require_argc 0 $# - disk_usage -} - -action__export() { - __require_argc 1- $# - map package_export "$@" -} - -action__gc() { - __require_argc 0 $# - gc -} - -action__help() { - __require_argc 0 $# - usage -} - -action__list-all() { - __require_argc 0 $# - list_all -} - -action__list-arches() { - __require_argc 1- $# - map package_get_arches "$@" -} - -action__list-local() { - __require_argc 0 $# - list_local -} - -action__list-repos() { - __require_argc 1- $# - map package_get_repos "$@" -} - -action__log() { - __require_argc 1 $# - log "$1" -} - -action__shortlog() { - __require_argc 1 $# - shortlog "$1" -} - -action__show() { - __require_argc 1-2 $# - package_show_file "$@" -} - -action__untrack() { - __require_argc 1- $# - map untrack "$@" -} - -action__update() { - update_packages "$@" -} - -action__ls-files() { - __require_argc 1 $# - - package_list_files "$1" -} - -action__set-git-protocol() { - __require_argc 1 $# - - case $1 in - git|http|https) - ;; - *) - log_fatal 'invalid protocol: %s' "$1" - ;; - esac - - for remote in "${ARCH_GIT_REPOS[@]}"; do - git remote set-url "$remote" "$1://git.archlinux.org/svntogit/$remote.git" - done -} - -dispatch_action() { - local candidates - - [[ $1 ]] || log_fatal 'no action specified (use -h for help)' - - # exact match - if declare -F "action__$1" &>/dev/null; then - "action__$@" - return - fi - - # prefix match - mapfile -t candidates < <(compgen -A function "action__$1") - case ${#candidates[*]} in - 0) - log_fatal 'unknown action: %s' "$1" - ;; - 1) - "${candidates[0]}" "${@:2}" - return - ;; - *) - { - printf "error: verb '%s' is ambiguous; possibilities:" "$1" - printf " '%s'" "${candidates[@]#action__}" - echo - } >&2 - return 1 - ;; - esac -} - -initialize || log_fatal 'failed to initialize asp repository in %s' "$ASPROOT" - -while getopts ':a:fhV' flag; do - case $flag in - a) - OPT_ARCH=$OPTARG - ;; - f) - OPT_FORCE=1 - ;; - h) - usage - exit 0 - ;; - V) - version - exit 0 - ;; - \?) - log_fatal "invalid option -- '%s'" "$OPTARG" - ;; - :) - log_fatal "option '-%s' requires an argument" "$OPTARG" - ;; - esac -done -shift $(( OPTIND - 1 )) - -dispatch_action "$@" diff --git a/asp32.in b/asp32.in new file mode 100644 index 0000000..ef60587 --- /dev/null +++ b/asp32.in @@ -0,0 +1,367 @@ +#!/bin/bash + +ASP_VERSION=@ASP_VERSION@ +ARCH_GIT_REPOS=(packages community) + +OPT_ARCH=$(uname -m) +OPT_FORCE=0 +: ${ASPROOT:=${XDG_CACHE_HOME:-$HOME/.cache}/asp32} +: ${ASPCACHE:=$ASPROOT/cache} + +m4_include(util.inc.sh) +m4_include(remote.inc.sh) +m4_include(package.inc.sh) +m4_include(archweb.inc.sh) + +usage() { + cat< max )); then + log_fatal '%s expects at most %d args, got %d' "${FUNCNAME[1]#action__}" "$max" "$argc" + elif (( argc < min )); then + log_fatal '%s expects at least %d args, got %d' "${FUNCNAME[1]#action__}" "$min" "$argc" + fi +} + +version() { + printf 'asp %s\n' "$ASP_VERSION" +} + +update_all() { + local r + + for r in "${ARCH_GIT_REPOS[@]}"; do + log_info "updating remote '%s'" "$r" + remote_update "$r" + done +} + +update_local_branches() { + local r=0 + + while read -r branchname; do + git branch -qf "$branchname" "refs/remotes/$branchname" || r=1 + done < <(git branch --no-color) + + return "$r" +} + +update_remote_branches() { + local refspecs=() remote pkgname + declare -A refspec_map + + if (( $# == 0 )); then + update_all + return + fi + + # map packages to remotes + for pkgname; do + package_init -n "$pkgname" remote || return 1 + refspec_map["$remote"]+=" packages/$pkgname" + done + + # update each remote all at once + for remote in "${!refspec_map[@]}"; do + read -ra refspecs <<<"${refspec_map["$remote"]}" + remote_update_refs "$remote" "${refspecs[@]}" + done +} + +update_packages() { + update_remote_branches "$@" && update_local_branches +} + +initialize() { + local remote + + umask 0022 + + export GIT_DIR=$ASPROOT/.git + + 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 + done + + touch "$ASPROOT/.asp" || return 1 + fi + + if [[ ! -d $ASPCACHE ]]; then + mkdir -p "$ASPCACHE" || return 1 + fi + + return 0 +} + +dump_packages() { + local remote refspecs dumpfn + + case $1 in + all) + dumpfn=remote_get_all_refs + ;; + local) + dumpfn=remote_get_tracked_refs + ;; + *) + die 'internal error: invalid dump type: "%s"' "$1" + ;; + esac + + for remote in "${ARCH_GIT_REPOS[@]}"; do + "$dumpfn" "$remote" refspecs + if [[ $refspecs ]]; then + printf '%s\n' "${refspecs[@]##*/}" + fi + done | sort +} + +list_local() { + dump_packages 'local' +} + +list_all() { + dump_packages 'all' +} + +shortlog() { + package_log "$@" "${FUNCNAME[0]}" +} + +log() { + package_log "$@" "${FUNCNAME[0]}" +} + +difflog() { + package_log "$@" "${FUNCNAME[0]}" +} + +gc() { + git gc --prune=all +} + +untrack() { + local pkgname=$1 remote + + package_init -n "$pkgname" remote || return 1 + + remote_untrack "$remote" "$pkgname" + package_untrack "$pkgname" "$remote" +} + +disk_usage() { + local usage + read usage _ < <(du -sh "$ASPROOT") + + log_info 'Using %s on disk.' "$usage" +} + +action__checkout() { + __require_argc 1- $# + map package_checkout "$@" +} + +action__difflog() { + __require_argc 1 $# + difflog "$1" +} + +action__disk-usage() { + __require_argc 0 $# + disk_usage +} + +action__export() { + __require_argc 1- $# + map package_export "$@" +} + +action__gc() { + __require_argc 0 $# + gc +} + +action__help() { + __require_argc 0 $# + usage +} + +action__list-all() { + __require_argc 0 $# + list_all +} + +action__list-arches() { + __require_argc 1- $# + map package_get_arches "$@" +} + +action__list-local() { + __require_argc 0 $# + list_local +} + +action__list-repos() { + __require_argc 1- $# + map package_get_repos "$@" +} + +action__log() { + __require_argc 1 $# + log "$1" +} + +action__shortlog() { + __require_argc 1 $# + shortlog "$1" +} + +action__show() { + __require_argc 1-2 $# + package_show_file "$@" +} + +action__untrack() { + __require_argc 1- $# + map untrack "$@" +} + +action__update() { + update_packages "$@" +} + +action__ls-files() { + __require_argc 1 $# + + package_list_files "$1" +} + +action__set-git-protocol() { + __require_argc 1 $# + + case $1 in + git|http|https) + ;; + *) + log_fatal 'invalid protocol: %s' "$1" + ;; + esac + + for remote in "${ARCH_GIT_REPOS[@]}"; do + git remote set-url "$remote" "$1://git.archlinux.org/svntogit/$remote.git" + done +} + +dispatch_action() { + local candidates + + [[ $1 ]] || log_fatal 'no action specified (use -h for help)' + + # exact match + if declare -F "action__$1" &>/dev/null; then + "action__$@" + return + fi + + # prefix match + mapfile -t candidates < <(compgen -A function "action__$1") + case ${#candidates[*]} in + 0) + log_fatal 'unknown action: %s' "$1" + ;; + 1) + "${candidates[0]}" "${@:2}" + return + ;; + *) + { + printf "error: verb '%s' is ambiguous; possibilities:" "$1" + printf " '%s'" "${candidates[@]#action__}" + echo + } >&2 + return 1 + ;; + esac +} + +initialize || log_fatal 'failed to initialize asp repository in %s' "$ASPROOT" + +while getopts ':a:fhV' flag; do + case $flag in + a) + OPT_ARCH=$OPTARG + ;; + f) + OPT_FORCE=1 + ;; + h) + usage + exit 0 + ;; + V) + version + exit 0 + ;; + \?) + log_fatal "invalid option -- '%s'" "$OPTARG" + ;; + :) + log_fatal "option '-%s' requires an argument" "$OPTARG" + ;; + esac +done +shift $(( OPTIND - 1 )) + +dispatch_action "$@" diff --git a/man/asp.1.txt b/man/asp.1.txt deleted file mode 100644 index 7b984e3..0000000 --- a/man/asp.1.txt +++ /dev/null @@ -1,123 +0,0 @@ -///// -vim:set ts=4 sw=4 syntax=asciidoc noet: -///// -asp(1) -====== - -Name ----- -asp - Manage Arch Linux build sources - -Synopsis --------- -asp [options] command [targets...] - -Description ------------ -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. - -Commands --------- -The following commands are understood: - -*checkout* 'TARGET'...:: - 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', - most of the metadata can be hard linked, making this a relatively cheap - copy. - -*difflog* 'TARGET':: - Show the full revision history of the target, with file diffs. - -*disk-usage*:: - Report the approximate disk usage for locally tracked packages. - -*export* 'TARGET'...:: - Dump the build source files for each target into a directory of the - target's name in '$PWD'. Targets can be specified simply as 'package' to - check out the source files at HEAD, or in 'repository/package' format - to checkout the source files which were used to push the 'package' which - exists in 'repository'. - -*gc*:: - Perform housekeeping procedures on the local repo, optimizing and - compacting the repo to free disk space. - -*help*:: - Display the command line usage and exit. - -*list-all*:: - List all known packages in the repositories. - -*list-arches* 'TARGET'...:: - List the architectures the given targets are available for. - -*list-local*:: - List all packages which are tracked locally. - -*list-repos* 'TARGET'...:: - List the repositories the given targets exist in. - -*log* 'TARGET':: - Show the revision history of the target. - -*ls-files* 'TARGET':: - List source files for the given target. - -*set-git-protocol* 'PROTOCOL':: - Set the protocol used to communicate with the remote git repositories. Must - be one of 'git', 'http', or 'https'. - -*shortlog* 'TARGET':: - Show a condensed revision history of the target. - -*show* 'TARGET' ['FILE']:: - Show the file content of the target, which may be in the format 'package' - or 'repository/package'. If an additional 'file' argument is provided, attempt - to display that file rather than the PKGBUILD. If the repository is not - specified, the file will be shown at the most recent revision (which may be - newer than what is in the repositories). - -*untrack* 'TARGET'...:: - Remove a remote tracking branch from the local repository. Disk usage for - the removed package(s) may not be freed until garbage collection has taken - place. - -*update* ['TARGET'...]:: - For each target, if the package is not known to the local repository, - attempt to track it. If the package is tracked, update the package - to the newest version. If no targets are provided, all locally known - packages will be updated. - -Options -------- -*-a* 'architecture':: - When relevant, specify an architecture other than that of the current host. - -*-f*:: - Allow files to be overwritten. - -*-h*:: - Print a short help text and exit. - -*-V*:: - Print a short version string and exit. - -Environment ------------ -*ASPROOT*:: - Determines where the metadata is stored for locally tracked packages. Defaults - to '`${XDG_CACHE_HOME:-$HOME/.cache}/asp`'. - -*ASPCACHE*:: - Determines where cached data is stored. Defaults to '$ASPROOT/cache'. Data in - this directory can always be safely deleted. - -Authors -------- -Dave Reisner diff --git a/man/asp32.1.txt b/man/asp32.1.txt new file mode 100644 index 0000000..be089d4 --- /dev/null +++ b/man/asp32.1.txt @@ -0,0 +1,131 @@ +///// +vim:set ts=4 sw=4 syntax=asciidoc noet: +///// +asp32(1) +======== + +Name +---- +asp32 - Manage Arch Linux 32 build sources + +Synopsis +-------- +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 32 packages. This program provides a thin wrapper over the svntogit +repositories hosted at https://git.archlinux.org and https://github.com/archlinux32/packages. +It aims to provide a replacement for abs which favors a sparse checkout. + +Commands +-------- +The following commands are understood: + +*checkout* 'TARGET'...:: + 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 + '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. + +*difflog* 'TARGET':: + Show the full revision history of the target, with file diffs. + +*disk-usage*:: + Report the approximate disk usage for locally tracked packages. + +*export* 'TARGET'...:: + Dump the build source files for each target into a directory of the + target's name in '$PWD'. Targets can be specified simply as 'package' to + check out the source files at HEAD, or in 'repository/package' format + to checkout the source files which were used to push the 'package' which + exists in 'repository'. + +*gc*:: + Perform housekeeping procedures on the local repo, optimizing and + compacting the repo to free disk space. + +*help*:: + Display the command line usage and exit. + +*list-all*:: + List all known packages in the repositories. + +*list-arches* 'TARGET'...:: + List the architectures the given targets are available for. + +*list-local*:: + List all packages which are tracked locally. + +*list-repos* 'TARGET'...:: + List the repositories the given targets exist in. + +*log* 'TARGET':: + Show the revision history of the target. + +*ls-files* 'TARGET':: + List source files for the given target. + +*set-git-protocol* 'PROTOCOL':: + Set the protocol used to communicate with the remote git repositories. Must + be one of 'git', 'http', or 'https'. + +*shortlog* 'TARGET':: + Show a condensed revision history of the target. + +*show* 'TARGET' ['FILE']:: + Show the file content of the target, which may be in the format 'package' + or 'repository/package'. If an additional 'file' argument is provided, attempt + to display that file rather than the PKGBUILD. If the repository is not + specified, the file will be shown at the most recent revision (which may be + newer than what is in the repositories). + +*untrack* 'TARGET'...:: + Remove a remote tracking branch from the local repository. Disk usage for + the removed package(s) may not be freed until garbage collection has taken + place. + +*update* ['TARGET'...]:: + For each target, if the package is not known to the local repository, + attempt to track it. If the package is tracked, update the package + to the newest version. If no targets are provided, all locally known + packages will be updated. + +Options +------- +*-a* 'architecture':: + When relevant, specify an architecture other than that of the current host. + +*-f*:: + Allow files to be overwritten. + +*-h*:: + Print a short help text and exit. + +*-V*:: + Print a short version string and exit. + +Environment +----------- +*ASPROOT*:: + Determines where the metadata is stored for locally tracked packages. Defaults + to '`${XDG_CACHE_HOME:-$HOME/.cache}/asp32`'. + +*ASPCACHE*:: + Determines where cached data is stored. Defaults to '$ASPROOT/cache'. Data in + this directory can always be safely deleted. + +Authors +------- +Dave Reisner + +Motifications for Archlinux32 +----------------------------- +Andreas Baumann -- cgit v1.2.3-70-g09d2