public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix a few problems with download_prerequisites.
@ 2021-08-24  6:03 apinski
  2021-08-24  8:03 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: apinski @ 2021-08-24  6:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

From: Andrew Pinski <apinski@marvell.com>

There are a few problems with download_prerequisites are
described in PR 82704.  The first is on busy-box version of
shasum and md5sum the extended option --check don't exist
so just use -c.  The second issue is the code for which
shasum program to use is included twice and is different.
So move which program to use for the checksum after argument
parsing.  The last issue is --md5 option has been broken for
sometime now as the program is named md5sum and not just md5.
Nobody updated switch table to be correct.

contrib/ChangeLog:

	PR other/82704
	* download_prerequisites: Fix issues with --md5 and
	--sha512 options.
---
 contrib/download_prerequisites | 59 +++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 29 deletions(-)

diff --git a/contrib/download_prerequisites b/contrib/download_prerequisites
index 51e715f..8f69b61 100755
--- a/contrib/download_prerequisites
+++ b/contrib/download_prerequisites
@@ -46,18 +46,6 @@ verify=1
 force=0
 OS=$(uname)
 
-case $OS in
-  "Darwin"|"FreeBSD"|"DragonFly"|"AIX")
-    chksum='shasum -a 512 --check'
-  ;;
-  "OpenBSD")
-    chksum='sha512 -c'
-  ;;
-  *)
-    chksum='sha512sum -c'
-  ;;
-esac
-
 if type wget > /dev/null ; then
   fetch='wget'
 else
@@ -113,7 +101,7 @@ do
 done
 unset arg
 
-# Emulate Linux's 'md5 --check' on macOS
+# Emulate Linux's 'md5sum --check' on macOS
 md5_check() {
   # Store the standard input: a line from contrib/prerequisites.md5:
   md5_checksum_line=$(cat -)
@@ -162,26 +150,10 @@ do
                 verify=0
                 ;;
             --sha512)
-                case $OS in
-                  "Darwin")
-                    chksum='shasum -a 512 --check'
-                  ;;
-                  *)
-                    chksum='sha512sum --check'
-                  ;;
-                esac
                 chksum_extension='sha512'
                 verify=1
                 ;;
             --md5)
-                case $OS in
-                  "Darwin")
-                    chksum='md5_check'
-                  ;;
-                  *)
-                    chksum='md5 --check'
-                  ;;
-                esac
                 chksum_extension='md5'
                 verify=1
                 ;;
@@ -212,6 +184,35 @@ done
 [ "x${argnext}" = x ] || die "Missing argument for option --${argnext}"
 unset arg argnext
 
+case $chksum_extension in
+  sha512)
+    case $OS in
+      "Darwin"|"FreeBSD"|"DragonFly"|"AIX")
+        chksum='shasum -a 512 --check'
+      ;;
+      "OpenBSD")
+        chksum='sha512 -c'
+      ;;
+      *)
+        chksum='sha512sum -c'
+      ;;
+    esac
+  ;;
+  md5)
+    case $OS in
+      "Darwin")
+        chksum='md5_check'
+      ;;
+      *)
+        chksum='md5sum -c'
+      ;;
+    esac
+    ;;
+  *)
+    die "Unkown checksum $chksum_extension"
+  ;;
+esac
+
 [ -e ./gcc/BASE-VER ]                                                         \
     || die "You must run this script in the top-level GCC source directory"
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix a few problems with download_prerequisites.
  2021-08-24  6:03 [PATCH] Fix a few problems with download_prerequisites apinski
@ 2021-08-24  8:03 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2021-08-24  8:03 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches

On Tue, Aug 24, 2021 at 8:04 AM apinski--- via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> From: Andrew Pinski <apinski@marvell.com>
>
> There are a few problems with download_prerequisites are
> described in PR 82704.  The first is on busy-box version of
> shasum and md5sum the extended option --check don't exist
> so just use -c.  The second issue is the code for which
> shasum program to use is included twice and is different.
> So move which program to use for the checksum after argument
> parsing.  The last issue is --md5 option has been broken for
> sometime now as the program is named md5sum and not just md5.
> Nobody updated switch table to be correct.

OK

> contrib/ChangeLog:
>
>         PR other/82704
>         * download_prerequisites: Fix issues with --md5 and
>         --sha512 options.
> ---
>  contrib/download_prerequisites | 59 +++++++++++++++++++++---------------------
>  1 file changed, 30 insertions(+), 29 deletions(-)
>
> diff --git a/contrib/download_prerequisites b/contrib/download_prerequisites
> index 51e715f..8f69b61 100755
> --- a/contrib/download_prerequisites
> +++ b/contrib/download_prerequisites
> @@ -46,18 +46,6 @@ verify=1
>  force=0
>  OS=$(uname)
>
> -case $OS in
> -  "Darwin"|"FreeBSD"|"DragonFly"|"AIX")
> -    chksum='shasum -a 512 --check'
> -  ;;
> -  "OpenBSD")
> -    chksum='sha512 -c'
> -  ;;
> -  *)
> -    chksum='sha512sum -c'
> -  ;;
> -esac
> -
>  if type wget > /dev/null ; then
>    fetch='wget'
>  else
> @@ -113,7 +101,7 @@ do
>  done
>  unset arg
>
> -# Emulate Linux's 'md5 --check' on macOS
> +# Emulate Linux's 'md5sum --check' on macOS
>  md5_check() {
>    # Store the standard input: a line from contrib/prerequisites.md5:
>    md5_checksum_line=$(cat -)
> @@ -162,26 +150,10 @@ do
>                  verify=0
>                  ;;
>              --sha512)
> -                case $OS in
> -                  "Darwin")
> -                    chksum='shasum -a 512 --check'
> -                  ;;
> -                  *)
> -                    chksum='sha512sum --check'
> -                  ;;
> -                esac
>                  chksum_extension='sha512'
>                  verify=1
>                  ;;
>              --md5)
> -                case $OS in
> -                  "Darwin")
> -                    chksum='md5_check'
> -                  ;;
> -                  *)
> -                    chksum='md5 --check'
> -                  ;;
> -                esac
>                  chksum_extension='md5'
>                  verify=1
>                  ;;
> @@ -212,6 +184,35 @@ done
>  [ "x${argnext}" = x ] || die "Missing argument for option --${argnext}"
>  unset arg argnext
>
> +case $chksum_extension in
> +  sha512)
> +    case $OS in
> +      "Darwin"|"FreeBSD"|"DragonFly"|"AIX")
> +        chksum='shasum -a 512 --check'
> +      ;;
> +      "OpenBSD")
> +        chksum='sha512 -c'
> +      ;;
> +      *)
> +        chksum='sha512sum -c'
> +      ;;
> +    esac
> +  ;;
> +  md5)
> +    case $OS in
> +      "Darwin")
> +        chksum='md5_check'
> +      ;;
> +      *)
> +        chksum='md5sum -c'
> +      ;;
> +    esac
> +    ;;
> +  *)
> +    die "Unkown checksum $chksum_extension"
> +  ;;
> +esac
> +
>  [ -e ./gcc/BASE-VER ]                                                         \
>      || die "You must run this script in the top-level GCC source directory"
>
> --
> 1.8.3.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-24  8:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24  6:03 [PATCH] Fix a few problems with download_prerequisites apinski
2021-08-24  8:03 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).