Compare every single tag with a list of valid tags to prevent broken releases if the user makes a typo. Since the list is used in the ZSH completion as well, it is moved to "lib/". Also, add a command line parameter to allow releasing to an unknown repository when necessary.
This is how error output looks like:
$ ./archrelease foobar ==> ERROR: archrelease: Invalid tag: "foobar" (use -f to force release)
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de --- archrelease.in | 25 ++++++++++++++++++++++--- lib/repo-vars.sh | 17 +++++++++++++++++ zsh_completion.in | 14 +------------- 3 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 lib/repo-vars.sh
diff --git a/archrelease.in b/archrelease.in index b9f3378..235262a 100644 --- a/archrelease.in +++ b/archrelease.in @@ -1,13 +1,32 @@ #!/bin/bash
m4_include(lib/common.sh) +m4_include(lib/repo-vars.sh)
-if [[ -z $1 ]]; then - echo 'usage: archrelease <repo>...' +# parse command line options +FORCE= +while getopts ':f' flag; do + case $flag in + f) FORCE=1 ;; + :) die "Option requires an argument -- '$OPTARG'" ;; + ?) die "Invalid option -- '$OPTARG'" ;; + esac +done +shift $(( OPTIND - 1 )) + +if ! (( $# )); then + echo 'usage: archrelease [-f] <repo>...' exit 1 fi
-# TODO: validate repo is really repo-arch +# validate repo is really repo-arch +if [[ -z $FORCE ]]; then + for tag in "$@"; do + if ! in_array "$tag" "${_tags[@]}"; then + die 'archrelease: Invalid tag: "'$tag'" (use -f to force release)' + fi + done +fi
if [[ ! -f PKGBUILD ]]; then die 'archrelease: PKGBUILD not found' diff --git a/lib/repo-vars.sh b/lib/repo-vars.sh new file mode 100644 index 0000000..75b3e27 --- /dev/null +++ b/lib/repo-vars.sh @@ -0,0 +1,17 @@ +_arch=( + i686 + x86_64 + any +) + +_tags=( + core-i686 core-x86_64 core-any + extra-i686 extra-x86_64 extra-any + multilib-i686 multilib-x86_64 multilib-any + staging-i686 staging-x86_64 staging-any + testing-i686 testing-x86_64 testing-any + multilib-testing-i686 multilib-testing-x86_64 multilib-testing-any + community-i686 community-x86_64 community-any + community-staging-i686 community-staging-x86_64 community-staging-any + community-testing-i686 community-testing-x86_64 community-testing-any +) diff --git a/zsh_completion.in b/zsh_completion.in index d87850a..27217fa 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -1,18 +1,6 @@ #compdef archbuild archco archrelease archrm commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-i686-build=archbuild extra-x86_64-build=archbuild testing-i686-build=archbuild testing-x86_64-build=archbuild staging-i686-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild communityco=archco
-_arch=(i686 x86_64 any) - -_tags=( - core-i686 core-x86_64 core-any - extra-i686 extra-x86_64 extra-any - multilib-i686 multilib-x86_64 multilib-any - staging-i686 staging-x86_64 staging-any - testing-i686 testing-x86_64 testing-any - multilib-testing-i686 multilib-testing-x86_64 multilib-testing-any - community-i686 community-x86_64 community-any - community-staging-i686 community-staging-x86_64 community-staging-any - community-testing-i686 community-testing-x86_64 community-testing-any -) +m4_include(lib/repo-vars.sh)
_archbuild_args=( '-c[Recreate the chroot before building]'
Compare every single tag with a list of valid tags to prevent broken releases if the user makes a typo. Since the list is used in the ZSH completion as well, it is moved to "lib/". Also, add a command line parameter to allow releasing to an unknown repository when necessary.
This is how error output looks like:
$ ./archrelease foobar ==> ERROR: archrelease: Invalid tag: "foobar" (use -f to force release)
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de --- Rebased on master.
archrelease.in | 25 ++++++++++++++++++++++--- lib/repo-vars.sh | 19 +++++++++++++++++++ zsh_completion.in | 16 +--------------- 3 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 lib/repo-vars.sh
diff --git a/archrelease.in b/archrelease.in index b9f3378..235262a 100644 --- a/archrelease.in +++ b/archrelease.in @@ -1,13 +1,32 @@ #!/bin/bash
m4_include(lib/common.sh) +m4_include(lib/repo-vars.sh)
-if [[ -z $1 ]]; then - echo 'usage: archrelease <repo>...' +# parse command line options +FORCE= +while getopts ':f' flag; do + case $flag in + f) FORCE=1 ;; + :) die "Option requires an argument -- '$OPTARG'" ;; + ?) die "Invalid option -- '$OPTARG'" ;; + esac +done +shift $(( OPTIND - 1 )) + +if ! (( $# )); then + echo 'usage: archrelease [-f] <repo>...' exit 1 fi
-# TODO: validate repo is really repo-arch +# validate repo is really repo-arch +if [[ -z $FORCE ]]; then + for tag in "$@"; do + if ! in_array "$tag" "${_tags[@]}"; then + die 'archrelease: Invalid tag: "'$tag'" (use -f to force release)' + fi + done +fi
if [[ ! -f PKGBUILD ]]; then die 'archrelease: PKGBUILD not found' diff --git a/lib/repo-vars.sh b/lib/repo-vars.sh new file mode 100644 index 0000000..6f732cc --- /dev/null +++ b/lib/repo-vars.sh @@ -0,0 +1,19 @@ +_arch=( + i686 + x86_64 + any +) + +_tags=( + core-i686 core-x86_64 core-any + extra-i686 extra-x86_64 extra-any + multilib-i686 multilib-x86_64 multilib-any + staging-i686 staging-x86_64 staging-any + testing-i686 testing-x86_64 testing-any + multilib-testing-i686 multilib-testing-x86_64 multilib-testing-any + community-i686 community-x86_64 community-any + community-staging-i686 community-staging-x86_64 community-staging-any + community-testing-i686 community-testing-x86_64 community-testing-any + kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any + gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any +) diff --git a/zsh_completion.in b/zsh_completion.in index cbeed74..6d9a879 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -1,20 +1,6 @@ #compdef archbuild archco archrelease archrm commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-i686-build=archbuild extra-x86_64-build=archbuild testing-i686-build=archbuild testing-x86_64-build=archbuild staging-i686-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild kde-unstable-i686-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-i686-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco
-_arch=(i686 x86_64 any) - -_tags=( - core-i686 core-x86_64 core-any - extra-i686 extra-x86_64 extra-any - multilib-i686 multilib-x86_64 multilib-any - staging-i686 staging-x86_64 staging-any - testing-i686 testing-x86_64 testing-any - multilib-testing-i686 multilib-testing-x86_64 multilib-testing-any - community-i686 community-x86_64 community-any - community-staging-i686 community-staging-x86_64 community-staging-any - community-testing-i686 community-testing-x86_64 community-testing-any - kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any - gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any -) +m4_include(lib/repo-vars.sh)
_archbuild_args=( '-c[Recreate the chroot before building]'
Compare every single tag with a list of valid tags. This prevents broken releases which occurred whenever someone made a typo on the command line:
$ ./archrelease community i686 ==> ERROR: archrelease: Invalid tag: "community" (use -f to force release)
Since the list is used in the ZSH completion as well, break it out to a separate file and move it to "lib/". Also, add a command line parameter to allow for releasing to an unknown repository when necessary.
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de --- Same patch with minor tweaks, rebased on master.
Pierre: What's the status if this one? If you're not sure whether this is needed, here are a couple of extracts of our SVN log:
archrelease: copy trunk to multilib archrelease: copy trunk to i686 archrelease: copy trunk to x86_64 fixing mistake with archrelease archrelease: copy trunk to community archrelease: copy trunk to x86_64 archrelease: copy trunk to i686 Remove erroneous archrelease consequences. archrelease: copy trunk to i686 archrelease: copy trunk to community archrelease: copy trunk to multilib archrelease: remove multilib archrelease: copy trunk to community archrelease: copy trunk to community archrelease: copy trunk to community archrelease: copy trunk to community archrelease: copy trunk to any archrelease: copy trunk to community archrelease: new repo community wrong archrelease
This patch is in my "for-pierre" branch as well.
archrelease.in | 25 ++++++++++++++++++++++--- lib/valid-tags.sh | 19 +++++++++++++++++++++ zsh_completion.in | 17 +---------------- 3 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 lib/valid-tags.sh
diff --git a/archrelease.in b/archrelease.in index 40b6c09..5bc2c90 100644 --- a/archrelease.in +++ b/archrelease.in @@ -1,13 +1,32 @@ #!/bin/bash
m4_include(lib/common.sh) +m4_include(lib/valid-tags.sh)
-if [[ -z $1 ]]; then - echo 'Usage: archrelease <repo>...' +# parse command line options +FORCE= +while getopts ':f' flag; do + case $flag in + f) FORCE=1 ;; + :) die "Option requires an argument -- '$OPTARG'" ;; + ?) die "Invalid option -- '$OPTARG'" ;; + esac +done +shift $(( OPTIND - 1 )) + +if ! (( $# )); then + echo 'Usage: archrelease [-f] <repo>...' exit 1 fi
-# TODO: validate repo is really repo-arch +# validate repo is really repo-arch +if [[ -z $FORCE ]]; then + for tag in "$@"; do + if ! in_array "$tag" "${_tags[@]}"; then + die 'archrelease: Invalid tag: "'$tag'" (use -f to force release)' + fi + done +fi
if [[ ! -f PKGBUILD ]]; then die 'archrelease: PKGBUILD not found' diff --git a/lib/valid-tags.sh b/lib/valid-tags.sh new file mode 100644 index 0000000..5554403 --- /dev/null +++ b/lib/valid-tags.sh @@ -0,0 +1,19 @@ +_arch=( + i686 + x86_64 + any +) + +_tags=( + core-i686 core-x86_64 core-any + extra-i686 extra-x86_64 extra-any + multilib-i686 multilib-x86_64 multilib-any + staging-i686 staging-x86_64 staging-any + testing-i686 testing-x86_64 testing-any + multilib-testing-i686 multilib-testing-x86_64 multilib-testing-any + community-i686 community-x86_64 community-any + community-staging-i686 community-staging-x86_64 community-staging-any + community-testing-i686 community-testing-x86_64 community-testing-any + kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any + gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any +) diff --git a/zsh_completion.in b/zsh_completion.in index 90ad398..727112a 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -1,21 +1,6 @@ #compdef archbuild archco archrelease archrm commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-i686-build=archbuild extra-x86_64-build=archbuild testing-i686-build=archbuild testing-x86_64-build=archbuild staging-i686-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-i686-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-i686-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco
-_arch=(i686 x86_64 any) - -_tags=( - core-i686 core-x86_64 core-any - extra-i686 extra-x86_64 extra-any - multilib-i686 multilib-x86_64 multilib-any - staging-i686 staging-x86_64 staging-any - testing-i686 testing-x86_64 testing-any - multilib-testing-i686 multilib-testing-x86_64 multilib-testing-any - multilib-staging-i686 multilib-staging-x86_64 multilib-staging-any - community-i686 community-x86_64 community-any - community-staging-i686 community-staging-x86_64 community-staging-any - community-testing-i686 community-testing-x86_64 community-testing-any - kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any - gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any -) +m4_include(lib/valid-tags.sh)
_archbuild_args=( '-c[Recreate the chroot before building]'
These tags make no sense. Remove them from our valid tag array that is used for tab completion.
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de --- Next try... Fixed tag array this time :)
zsh_completion.in | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/zsh_completion.in b/zsh_completion.in index 90ad398..e976524 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -5,11 +5,11 @@ _arch=(i686 x86_64 any) _tags=( core-i686 core-x86_64 core-any extra-i686 extra-x86_64 extra-any - multilib-i686 multilib-x86_64 multilib-any + multilib-i686 staging-i686 staging-x86_64 staging-any testing-i686 testing-x86_64 testing-any - multilib-testing-i686 multilib-testing-x86_64 multilib-testing-any - multilib-staging-i686 multilib-staging-x86_64 multilib-staging-any + multilib-testing-i686 + multilib-staging-i686 community-i686 community-x86_64 community-any community-staging-i686 community-staging-x86_64 community-staging-any community-testing-i686 community-testing-x86_64 community-testing-any
Compare every single tag with a list of valid tags. This prevents broken releases which occurred whenever someone made a typo on the command line:
$ ./archrelease community i686 ==> ERROR: archrelease: Invalid tag: "community" (use -f to force release)
Since the list is used in the ZSH completion as well, break it out to a separate file and move it to "lib/". Also, add a command line parameter to allow for releasing to an unknown repository when necessary.
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de --- archrelease.in | 25 ++++++++++++++++++++++--- lib/valid-tags.sh | 20 ++++++++++++++++++++ zsh_completion.in | 17 ----------------- 3 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 lib/valid-tags.sh
diff --git a/archrelease.in b/archrelease.in index 40b6c09..5bc2c90 100644 --- a/archrelease.in +++ b/archrelease.in @@ -1,13 +1,32 @@ #!/bin/bash
m4_include(lib/common.sh) +m4_include(lib/valid-tags.sh)
-if [[ -z $1 ]]; then - echo 'Usage: archrelease <repo>...' +# parse command line options +FORCE= +while getopts ':f' flag; do + case $flag in + f) FORCE=1 ;; + :) die "Option requires an argument -- '$OPTARG'" ;; + ?) die "Invalid option -- '$OPTARG'" ;; + esac +done +shift $(( OPTIND - 1 )) + +if ! (( $# )); then + echo 'Usage: archrelease [-f] <repo>...' exit 1 fi
-# TODO: validate repo is really repo-arch +# validate repo is really repo-arch +if [[ -z $FORCE ]]; then + for tag in "$@"; do + if ! in_array "$tag" "${_tags[@]}"; then + die 'archrelease: Invalid tag: "'$tag'" (use -f to force release)' + fi + done +fi
if [[ ! -f PKGBUILD ]]; then die 'archrelease: PKGBUILD not found' diff --git a/lib/valid-tags.sh b/lib/valid-tags.sh new file mode 100644 index 0000000..26fd886 --- /dev/null +++ b/lib/valid-tags.sh @@ -0,0 +1,20 @@ +_arch=( + i686 + x86_64 + any +) + +_tags=( + core-i686 core-x86_64 core-any + extra-i686 extra-x86_64 extra-any + multilib-i686 + staging-i686 staging-x86_64 staging-any + testing-i686 testing-x86_64 testing-any + multilib-testing-i686 + multilib-staging-i686 + community-i686 community-x86_64 community-any + community-staging-i686 community-staging-x86_64 community-staging-any + community-testing-i686 community-testing-x86_64 community-testing-any + kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any + gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any +) diff --git a/zsh_completion.in b/zsh_completion.in index e976524..3b61a2e 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -1,22 +1,5 @@ #compdef archbuild archco archrelease archrm commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-i686-build=archbuild extra-x86_64-build=archbuild testing-i686-build=archbuild testing-x86_64-build=archbuild staging-i686-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-i686-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-i686-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco
-_arch=(i686 x86_64 any) - -_tags=( - core-i686 core-x86_64 core-any - extra-i686 extra-x86_64 extra-any - multilib-i686 - staging-i686 staging-x86_64 staging-any - testing-i686 testing-x86_64 testing-any - multilib-testing-i686 - multilib-staging-i686 - community-i686 community-x86_64 community-any - community-staging-i686 community-staging-x86_64 community-staging-any - community-testing-i686 community-testing-x86_64 community-testing-any - kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any - gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any -) - _archbuild_args=( '-c[Recreate the chroot before building]' '-r[Create chroots in this directory]:base_dir:_files -/'
Am 08.02.2012 10:59, schrieb Lukas Fleischer:
These tags make no sense. Remove them from our valid tag array that is used for tab completion.
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de
Next try... Fixed tag array this time :)
zsh_completion.in | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/zsh_completion.in b/zsh_completion.in index 90ad398..e976524 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -5,11 +5,11 @@ _arch=(i686 x86_64 any) _tags=( core-i686 core-x86_64 core-any extra-i686 extra-x86_64 extra-any
- multilib-i686 multilib-x86_64 multilib-any
- multilib-i686 staging-i686 staging-x86_64 staging-any testing-i686 testing-x86_64 testing-any
- multilib-testing-i686 multilib-testing-x86_64 multilib-testing-any
- multilib-staging-i686 multilib-staging-x86_64 multilib-staging-any
- multilib-testing-i686
- multilib-staging-i686 community-i686 community-x86_64 community-any community-staging-i686 community-staging-x86_64 community-staging-any community-testing-i686 community-testing-x86_64 community-testing-any
I guess you removed the wron tags ;-) What we might want to keep is multilib-x86_64.
These tags make no sense. Remove them from our valid tag array that is used for tab completion.
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de --- Damn it.
zsh_completion.in | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/zsh_completion.in b/zsh_completion.in index 90ad398..03c2d9a 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -5,11 +5,11 @@ _arch=(i686 x86_64 any) _tags=( core-i686 core-x86_64 core-any extra-i686 extra-x86_64 extra-any - multilib-i686 multilib-x86_64 multilib-any + multilib-x86_64 staging-i686 staging-x86_64 staging-any testing-i686 testing-x86_64 testing-any - multilib-testing-i686 multilib-testing-x86_64 multilib-testing-any - multilib-staging-i686 multilib-staging-x86_64 multilib-staging-any + multilib-testing-x86_64 + multilib-staging-x86_64 community-i686 community-x86_64 community-any community-staging-i686 community-staging-x86_64 community-staging-any community-testing-i686 community-testing-x86_64 community-testing-any
Compare every single tag with a list of valid tags. This prevents broken releases which occurred whenever someone made a typo on the command line:
$ ./archrelease community i686 ==> ERROR: archrelease: Invalid tag: "community" (use -f to force release)
Since the list is used in the ZSH completion as well, break it out to a separate file and move it to "lib/". Also, add a command line parameter to allow for releasing to an unknown repository when necessary.
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de --- archrelease.in | 25 ++++++++++++++++++++++--- lib/valid-tags.sh | 20 ++++++++++++++++++++ zsh_completion.in | 17 ----------------- 3 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 lib/valid-tags.sh
diff --git a/archrelease.in b/archrelease.in index 40b6c09..5bc2c90 100644 --- a/archrelease.in +++ b/archrelease.in @@ -1,13 +1,32 @@ #!/bin/bash
m4_include(lib/common.sh) +m4_include(lib/valid-tags.sh)
-if [[ -z $1 ]]; then - echo 'Usage: archrelease <repo>...' +# parse command line options +FORCE= +while getopts ':f' flag; do + case $flag in + f) FORCE=1 ;; + :) die "Option requires an argument -- '$OPTARG'" ;; + ?) die "Invalid option -- '$OPTARG'" ;; + esac +done +shift $(( OPTIND - 1 )) + +if ! (( $# )); then + echo 'Usage: archrelease [-f] <repo>...' exit 1 fi
-# TODO: validate repo is really repo-arch +# validate repo is really repo-arch +if [[ -z $FORCE ]]; then + for tag in "$@"; do + if ! in_array "$tag" "${_tags[@]}"; then + die 'archrelease: Invalid tag: "'$tag'" (use -f to force release)' + fi + done +fi
if [[ ! -f PKGBUILD ]]; then die 'archrelease: PKGBUILD not found' diff --git a/lib/valid-tags.sh b/lib/valid-tags.sh new file mode 100644 index 0000000..36918fe --- /dev/null +++ b/lib/valid-tags.sh @@ -0,0 +1,20 @@ +_arch=( + i686 + x86_64 + any +) + +_tags=( + core-i686 core-x86_64 core-any + extra-i686 extra-x86_64 extra-any + multilib-x86_64 + staging-i686 staging-x86_64 staging-any + testing-i686 testing-x86_64 testing-any + multilib-testing-x86_64 + multilib-staging-x86_64 + community-i686 community-x86_64 community-any + community-staging-i686 community-staging-x86_64 community-staging-any + community-testing-i686 community-testing-x86_64 community-testing-any + kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any + gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any +) diff --git a/zsh_completion.in b/zsh_completion.in index 03c2d9a..3b61a2e 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -1,22 +1,5 @@ #compdef archbuild archco archrelease archrm commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-i686-build=archbuild extra-x86_64-build=archbuild testing-i686-build=archbuild testing-x86_64-build=archbuild staging-i686-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-i686-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-i686-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco
-_arch=(i686 x86_64 any) - -_tags=( - core-i686 core-x86_64 core-any - extra-i686 extra-x86_64 extra-any - multilib-x86_64 - staging-i686 staging-x86_64 staging-any - testing-i686 testing-x86_64 testing-any - multilib-testing-x86_64 - multilib-staging-x86_64 - community-i686 community-x86_64 community-any - community-staging-i686 community-staging-x86_64 community-staging-any - community-testing-i686 community-testing-x86_64 community-testing-any - kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any - gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any -) - _archbuild_args=( '-c[Recreate the chroot before building]' '-r[Create chroots in this directory]:base_dir:_files -/'
Am 08.02.2012 12:48, schrieb Lukas Fleischer:
Compare every single tag with a list of valid tags. This prevents broken releases which occurred whenever someone made a typo on the command line:
$ ./archrelease community i686 ==> ERROR: archrelease: Invalid tag: "community" (use -f to force
release)
Since the list is used in the ZSH completion as well, break it out to a separate file and move it to "lib/". Also, add a command line parameter to allow for releasing to an unknown repository when necessary.
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de
archrelease.in | 25 ++++++++++++++++++++++--- lib/valid-tags.sh | 20 ++++++++++++++++++++ zsh_completion.in | 17 ----------------- 3 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 lib/valid-tags.sh
diff --git a/archrelease.in b/archrelease.in index 40b6c09..5bc2c90 100644 --- a/archrelease.in +++ b/archrelease.in @@ -1,13 +1,32 @@ #!/bin/bash
m4_include(lib/common.sh) +m4_include(lib/valid-tags.sh)
-if [[ -z $1 ]]; then
- echo 'Usage: archrelease <repo>...'
+# parse command line options +FORCE= +while getopts ':f' flag; do
- case $flag in
f) FORCE=1 ;;
:) die "Option requires an argument -- '$OPTARG'" ;;
\?) die "Invalid option -- '$OPTARG'" ;;
- esac
+done +shift $(( OPTIND - 1 ))
+if ! (( $# )); then
- echo 'Usage: archrelease [-f] <repo>...' exit 1
fi
-# TODO: validate repo is really repo-arch +# validate repo is really repo-arch +if [[ -z $FORCE ]]; then
- for tag in "$@"; do
if ! in_array "$tag" "${_tags[@]}"; then
die 'archrelease: Invalid tag: "'$tag'" (use -f to force release)'
fi
- done
+fi
if [[ ! -f PKGBUILD ]]; then die 'archrelease: PKGBUILD not found' diff --git a/lib/valid-tags.sh b/lib/valid-tags.sh new file mode 100644 index 0000000..36918fe --- /dev/null +++ b/lib/valid-tags.sh @@ -0,0 +1,20 @@ +_arch=(
- i686
- x86_64
- any
+)
+_tags=(
- core-i686 core-x86_64 core-any
- extra-i686 extra-x86_64 extra-any
- multilib-x86_64
- staging-i686 staging-x86_64 staging-any
- testing-i686 testing-x86_64 testing-any
- multilib-testing-x86_64
- multilib-staging-x86_64
- community-i686 community-x86_64 community-any
- community-staging-i686 community-staging-x86_64 community-staging-any
- community-testing-i686 community-testing-x86_64 community-testing-any
- kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any
- gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any
+) diff --git a/zsh_completion.in b/zsh_completion.in index 03c2d9a..3b61a2e 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -1,22 +1,5 @@ #compdef archbuild archco archrelease archrm commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-i686-build=archbuild extra-x86_64-build=archbuild testing-i686-build=archbuild testing-x86_64-build=archbuild staging-i686-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-i686-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-i686-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco
-_arch=(i686 x86_64 any)
-_tags=(
- core-i686 core-x86_64 core-any
- extra-i686 extra-x86_64 extra-any
- multilib-x86_64
- staging-i686 staging-x86_64 staging-any
- testing-i686 testing-x86_64 testing-any
- multilib-testing-x86_64
- multilib-staging-x86_64
- community-i686 community-x86_64 community-any
- community-staging-i686 community-staging-x86_64 community-staging-any
- community-testing-i686 community-testing-x86_64 community-testing-any
- kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any
- gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any
-)
_archbuild_args=( '-c[Recreate the chroot before building]' '-r[Create chroots in this directory]:base_dir:_files -/'
You forgot to add "m4_include(lib/valid-tags.sh)" here.
These tags make no sense. Remove them from our valid tag array that is used for tab completion.
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de --- zsh_completion.in | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/zsh_completion.in b/zsh_completion.in index 90ad398..03c2d9a 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -5,11 +5,11 @@ _arch=(i686 x86_64 any) _tags=( core-i686 core-x86_64 core-any extra-i686 extra-x86_64 extra-any - multilib-i686 multilib-x86_64 multilib-any + multilib-x86_64 staging-i686 staging-x86_64 staging-any testing-i686 testing-x86_64 testing-any - multilib-testing-i686 multilib-testing-x86_64 multilib-testing-any - multilib-staging-i686 multilib-staging-x86_64 multilib-staging-any + multilib-testing-x86_64 + multilib-staging-x86_64 community-i686 community-x86_64 community-any community-staging-i686 community-staging-x86_64 community-staging-any community-testing-i686 community-testing-x86_64 community-testing-any
Compare every single tag with a list of valid tags. This prevents broken releases which occurred whenever someone made a typo on the command line:
$ ./archrelease community i686 ==> ERROR: archrelease: Invalid tag: "community" (use -f to force release)
Since the list is used in the ZSH completion as well, break it out to a separate file and move it to "lib/". Also, add a command line parameter to allow for releasing to an unknown repository when necessary.
Signed-off-by: Lukas Fleischer archlinux@cryptocrack.de --- archrelease.in | 25 ++++++++++++++++++++++--- lib/valid-tags.sh | 20 ++++++++++++++++++++ zsh_completion.in | 17 +---------------- 3 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 lib/valid-tags.sh
diff --git a/archrelease.in b/archrelease.in index 40b6c09..5bc2c90 100644 --- a/archrelease.in +++ b/archrelease.in @@ -1,13 +1,32 @@ #!/bin/bash
m4_include(lib/common.sh) +m4_include(lib/valid-tags.sh)
-if [[ -z $1 ]]; then - echo 'Usage: archrelease <repo>...' +# parse command line options +FORCE= +while getopts ':f' flag; do + case $flag in + f) FORCE=1 ;; + :) die "Option requires an argument -- '$OPTARG'" ;; + ?) die "Invalid option -- '$OPTARG'" ;; + esac +done +shift $(( OPTIND - 1 )) + +if ! (( $# )); then + echo 'Usage: archrelease [-f] <repo>...' exit 1 fi
-# TODO: validate repo is really repo-arch +# validate repo is really repo-arch +if [[ -z $FORCE ]]; then + for tag in "$@"; do + if ! in_array "$tag" "${_tags[@]}"; then + die 'archrelease: Invalid tag: "'$tag'" (use -f to force release)' + fi + done +fi
if [[ ! -f PKGBUILD ]]; then die 'archrelease: PKGBUILD not found' diff --git a/lib/valid-tags.sh b/lib/valid-tags.sh new file mode 100644 index 0000000..36918fe --- /dev/null +++ b/lib/valid-tags.sh @@ -0,0 +1,20 @@ +_arch=( + i686 + x86_64 + any +) + +_tags=( + core-i686 core-x86_64 core-any + extra-i686 extra-x86_64 extra-any + multilib-x86_64 + staging-i686 staging-x86_64 staging-any + testing-i686 testing-x86_64 testing-any + multilib-testing-x86_64 + multilib-staging-x86_64 + community-i686 community-x86_64 community-any + community-staging-i686 community-staging-x86_64 community-staging-any + community-testing-i686 community-testing-x86_64 community-testing-any + kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any + gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any +) diff --git a/zsh_completion.in b/zsh_completion.in index 03c2d9a..727112a 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -1,21 +1,6 @@ #compdef archbuild archco archrelease archrm commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-i686-build=archbuild extra-x86_64-build=archbuild testing-i686-build=archbuild testing-x86_64-build=archbuild staging-i686-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-i686-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-i686-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco
-_arch=(i686 x86_64 any) - -_tags=( - core-i686 core-x86_64 core-any - extra-i686 extra-x86_64 extra-any - multilib-x86_64 - staging-i686 staging-x86_64 staging-any - testing-i686 testing-x86_64 testing-any - multilib-testing-x86_64 - multilib-staging-x86_64 - community-i686 community-x86_64 community-any - community-staging-i686 community-staging-x86_64 community-staging-any - community-testing-i686 community-testing-x86_64 community-testing-any - kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any - gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any -) +m4_include(lib/valid-tags.sh)
_archbuild_args=( '-c[Recreate the chroot before building]'
arch-projects@lists.archlinux.org