[pacman-dev] [PATCH 1/2] makepkg: unify list of known hash algorithms
Unifying this list makes adding new algorithms easier. There's also some menial cleanup in this patch to avoid use of eval and properly treat lists of data as array instead of simple strings. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- scripts/makepkg.sh.in | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 025f756..73f4eb7 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -54,6 +54,8 @@ splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'url' 'license' \ 'replaces' 'backup' 'options' 'install' 'changelog') readonly -a packaging_options other_options splitpkg_overrides +known_hash_algos=(md5 sha1 sha256 sha384 sha512) + # Options ASDEPS=0 NEEDED=0 @@ -1107,10 +1109,10 @@ get_integlist() { local integ local integlist=() - for integ in md5 sha1 sha256 sha384 sha512; do - local integrity_sums=($(eval echo "\${${integ}sums[@]}")) - if [[ -n "$integrity_sums" ]]; then - integlist=(${integlist[@]} $integ) + for integ in "${known_hash_algos[@]}"; do + local sumname="${integ}sums[@]" + if [[ -n ${!sumname} ]]; then + integlist+=("$integ") fi done @@ -1131,19 +1133,17 @@ generate_checksums() { local integlist if (( $# == 0 )); then - integlist=$(get_integlist) + IFS=$'\n' read -ra integlist < <(get_integlist) else - integlist=$@ + integlist=("$@") fi local integ - for integ in ${integlist[@]}; do - case "$integ" in - md5|sha1|sha256|sha384|sha512) : ;; - *) - error "$(gettext "Invalid integrity algorithm '%s' specified.")" "$integ" - exit 1;; # $E_CONFIG_ERROR - esac + for integ in "${integlist[@]}"; do + if ! in_array "$integ" "${known_hash_algos[@]}"; then + error "$(gettext "Invalid integrity algorithm '%s' specified.")" "$integ" + exit 1 # $E_CONFIG_ERROR + fi local ct=0 local numsrc=${#source[@]} @@ -1192,8 +1192,9 @@ check_checksums() { local correlation=0 local integ required - for integ in md5 sha1 sha256 sha384 sha512; do - local integrity_sums=($(eval echo "\${${integ}sums[@]}")) + for integ in "${known_hash_algos[@]}"; do + local sumname="${integ}sums[@]" + local integrity_sums=("${!sumname}") if (( ${#integrity_sums[@]} == ${#source[@]} )); then msg "$(gettext "Validating source files with %s...")" "${integ}sums" correlation=1 -- 1.8.4
Implements FS#36776. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- scripts/makepkg.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 73f4eb7..8ef92fc 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -54,7 +54,7 @@ splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'url' 'license' \ 'replaces' 'backup' 'options' 'install' 'changelog') readonly -a packaging_options other_options splitpkg_overrides -known_hash_algos=(md5 sha1 sha256 sha384 sha512) +known_hash_algos=(md5 sha1 sha224 sha256 sha384 sha512) # Options ASDEPS=0 -- 1.8.4
On 03/09/13 06:08, Dave Reisner wrote:
Unifying this list makes adding new algorithms easier. There's also some menial cleanup in this patch to avoid use of eval and properly treat lists of data as array instead of simple strings.
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- scripts/makepkg.sh.in | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 025f756..73f4eb7 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -54,6 +54,8 @@ splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'url' 'license' \ 'replaces' 'backup' 'options' 'install' 'changelog') readonly -a packaging_options other_options splitpkg_overrides
+known_hash_algos=(md5 sha1 sha256 sha384 sha512)
Do we want those values in quotes. I know it is not strictly necessary, but it is done in the three lists on the line above that so consistency would be good.
On Tue, Sep 03, 2013 at 03:58:33PM +1000, Allan McRae wrote:
On 03/09/13 06:08, Dave Reisner wrote:
Unifying this list makes adding new algorithms easier. There's also some menial cleanup in this patch to avoid use of eval and properly treat lists of data as array instead of simple strings.
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- scripts/makepkg.sh.in | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 025f756..73f4eb7 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -54,6 +54,8 @@ splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'url' 'license' \ 'replaces' 'backup' 'options' 'install' 'changelog') readonly -a packaging_options other_options splitpkg_overrides
+known_hash_algos=(md5 sha1 sha256 sha384 sha512)
Do we want those values in quotes. I know it is not strictly necessary, but it is done in the three lists on the line above that so consistency would be good.
+1 for consistency. Adjusted on my 'integrity' branch.
participants (3)
-
Allan McRae
-
Dave Reisner
-
Dave Reisner