[arch-projects] [devtools][PATCH 1/6] commitpkg: declare rsyncopts as an array
From: Dave Reisner <d@falconindy.com> Signed-off-by: Dave Reisner <d@falconindy.com> --- commitpkg | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commitpkg b/commitpkg index bdc1fd6..d37babf 100755 --- a/commitpkg +++ b/commitpkg @@ -97,9 +97,9 @@ for i in 'changelog' 'install'; do done # see if any limit options were passed, we'll send them to rsync -rsyncopts='-e ssh -p --chmod=ug=rw,o=r -c -h -L --progress --partial -y' +rsyncopts=(-e ssh -p --chmod=ug=rw,o=r -c -h -L --progress --partial -y) if [ "$1" = '-l' ]; then - rsyncopts="$rsyncopts --bwlimit=$2" + rsyncopts+=("--bwlimit=$2") shift 2 fi @@ -175,7 +175,7 @@ done if [[ ${#uploads[*]} -gt 0 ]]; then echo 'uploading all package and signature files' - rsync $rsyncopts "${uploads[@]}" "$server:staging/$repo/" || abort + rsync "${rsyncopts[@]}" "${uploads[@]}" "$server:staging/$repo/" || abort fi if [ "${arch[*]}" == 'any' ]; then -- 1.7.6
From: Dave Reisner <d@falconindy.com> Signed-off-by: Dave Reisner <d@falconindy.com> --- We shouldn't be insisting on an option order... commitpkg | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/commitpkg b/commitpkg index d37babf..1275615 100755 --- a/commitpkg +++ b/commitpkg @@ -98,15 +98,17 @@ done # see if any limit options were passed, we'll send them to rsync rsyncopts=(-e ssh -p --chmod=ug=rw,o=r -c -h -L --progress --partial -y) -if [ "$1" = '-l' ]; then - rsyncopts+=("--bwlimit=$2") - shift 2 -fi - -if [ "$1" = "-a" ]; then - commit_arch=$2 - shift 2 -fi +while getopts ':l:a:' flag; do + case $flag in + l) rsyncopts+=("--bwlimit=$2") ;; + a) commit_arch=$2 ;; + :) echo "option requires an argument -- '$OPTARG'" >&2 + exit 1 ;; + \?) echo "invalid option -- '$OPTARG'" >&2 + exit 1 ;; + esac +done +shift $(( OPTIND - 1 )) if [ -n "$(svn status -q)" ]; then echo -n 'committing changes to trunk...' -- 1.7.6
From: Dave Reisner <d@falconindy.com> Signed-off-by: Dave Reisner <d@falconindy.com> --- Small pet peeve of mine. I always expect -m to be required for a commit msg. I have a startling number of commits where the message is only -m. We should at least use _all_ the arguments so that the next time a noodle noggin such as myself insists on using the unneeded -m, we get a useful commit msg along with the "mark of shame". commitpkg | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/commitpkg b/commitpkg index 1275615..01c09d5 100755 --- a/commitpkg +++ b/commitpkg @@ -114,7 +114,7 @@ if [ -n "$(svn status -q)" ]; then echo -n 'committing changes to trunk...' msgtemplate="upgpkg: $pkgbase $(get_full_version ${epoch:-0} $pkgver $pkgrel)"$'\n\n' if [ -n "$1" ]; then - svn commit -q -m "${msgtemplate}${1}" || abort + svn commit -q -m "${msgtemplate}$*" || abort else msgfile="$(mktemp)" echo "$msgtemplate" > "$msgfile" -- 1.7.6
On Tue, Aug 16, 2011 at 09:35:58PM -0400, Dave Reisner wrote:
From: Dave Reisner <d@falconindy.com>
Signed-off-by: Dave Reisner <d@falconindy.com> --- Small pet peeve of mine. I always expect -m to be required for a commit msg. I have a startling number of commits where the message is only -m. We should at least use _all_ the arguments so that the next time a noodle noggin such as myself insists on using the unneeded -m, we get a useful commit msg along with the "mark of shame".
commitpkg | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/commitpkg b/commitpkg index 1275615..01c09d5 100755 --- a/commitpkg +++ b/commitpkg @@ -114,7 +114,7 @@ if [ -n "$(svn status -q)" ]; then echo -n 'committing changes to trunk...' msgtemplate="upgpkg: $pkgbase $(get_full_version ${epoch:-0} $pkgver $pkgrel)"$'\n\n' if [ -n "$1" ]; then - svn commit -q -m "${msgtemplate}${1}" || abort + svn commit -q -m "${msgtemplate}$*" || abort
-1. The second patch already fixes this: ---- $ communitypkg -m 'Anything that happens, happens.' invalid option -- 'm' ---- Also, I'd rather say we should check if there's more than one additional argument in the commitpkg invocation and bail out if there is.
else msgfile="$(mktemp)" echo "$msgtemplate" > "$msgfile" -- 1.7.6
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- I'll cut the person who wants to commit an odd filename to svn (e.g. something with whitespaces), but archrelease shouldn't care about this. archrelease | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/archrelease b/archrelease index 8da8b95..20ccd50 100755 --- a/archrelease +++ b/archrelease @@ -30,9 +30,11 @@ fi echo -n "releasing package to ${1}..." pushd .. >/dev/null if [ -d "repos/${1}" ]; then - for file in $(svn ls "repos/${1}"); do - svn rm -q "repos/${1}/$file" - done + declare -a trash + while read -r file; do + trash+=("repos/$1/$file") + done < <(svn ls "repos/$1") + svn rm -q "${trash[@]}" fi if [ ! -d repos ]; then mkdir repos -- 1.7.6
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- Less forking, more bashing. archrelease | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/archrelease b/archrelease index 20ccd50..24e950c 100755 --- a/archrelease +++ b/archrelease @@ -5,48 +5,50 @@ abort() { exit 1 } -if [ "$1" = '' ]; then +if [[ -z $1 ]]; then abort 'Usage: archrelease <repo>' fi # TODO: validate repo is really repo-arch -if [ ! -f PKGBUILD ]; then +if [[ ! -f PKGBUILD ]]; then abort 'archrelease: PKGBUILD not found' fi -trunk=$(basename $(pwd)) +trunk=${PWD##*/} # Normally this should be trunk, but it may be something # such as 'gnome-unstable' -if [ "$(basename $(dirname $(pwd)))" == "repos" ]; then +IFS='/' read -r -d '' -a parts <<< "$PWD" +if [[ "${parts[@]:(-2):1}" == "repos" ]]; then abort 'archrelease: Should not be in repos dir (try from trunk/)' fi +unset parts -if [ ! -z "$(svn status -q)" ]; then +if [[ $(svn status -q) ]]; then abort 'archrelease: You have not committed your changes yet!' fi echo -n "releasing package to ${1}..." pushd .. >/dev/null -if [ -d "repos/${1}" ]; then +if [[ -d repos/$1 ]]; then declare -a trash while read -r file; do trash+=("repos/$1/$file") done < <(svn ls "repos/$1") svn rm -q "${trash[@]}" fi -if [ ! -d repos ]; then +if [[ ! -d repos ]]; then mkdir repos svn add -q repos fi -if [ ! -d "repos/${1}" ]; then +if [[ ! -d "repos/$1" ]]; then mkdir "repos/${1}" svn add -q "repos/${1}" fi known_files=$(svn ls "trunk") for file in $known_files; do - if [ "$file" != "${file%/}" ]; then + if [[ ${file:(-1)} = '/' ]]; then abort "archrelease: subdirectories are not supported in package directories!" fi done -- 1.7.6
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- archrelease | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/archrelease b/archrelease index 24e950c..af75b8f 100755 --- a/archrelease +++ b/archrelease @@ -46,13 +46,13 @@ if [[ ! -d "repos/$1" ]]; then mkdir "repos/${1}" svn add -q "repos/${1}" fi -known_files=$(svn ls "trunk") -for file in $known_files; do +IFS=$'\n' read -r -d '' -a known_files < <(svn ls "trunk") +for file in "${known_files[@]}"; do if [[ ${file:(-1)} = '/' ]]; then abort "archrelease: subdirectories are not supported in package directories!" fi done -for file in $known_files; do +for file in "${known_files[@]}"; do svn copy -q -r HEAD "trunk/$file" "repos/${1}/" done svn commit -q -m "archrelease: copy trunk to ${1}" || abort -- 1.7.6
participants (2)
-
Dave Reisner
-
Lukas Fleischer