Bug 91084 - download_prerequisites fails on OpenBSD
Summary: download_prerequisites fails on OpenBSD
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-04 09:21 UTC by Thomas Koenig
Modified: 2021-08-24 09:52 UTC (History)
0 users

See Also:
Host: openbsd
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-01-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2019-07-04 09:21:00 UTC
It fails with

sha512sum: not found

(This can be tested on gcc220.fsffrance.org at the moment).
Comment 1 Richard Biener 2019-07-04 10:21:24 UTC
case $OS in
  "Darwin"|"FreeBSD"|"DragonFly")
    chksum='shasum -a 512 --check'
  ;;
  *)
    chksum='sha512sum -c'
  ;;
esac

probably OpenBSD needs similar treatment?
Comment 2 Jonathan Wakely 2019-07-04 10:26:49 UTC
I already suggested that on the cfarm list. Thomas, it would be helpful if you could try that.
Comment 3 Thomas Koenig 2019-07-04 19:01:42 UTC
~/trunk $ svn diff contrib/                                                                                                        
Index: contrib/download_prerequisites
===================================================================
--- contrib/download_prerequisites      (revision 273019)
+++ contrib/download_prerequisites      (working copy)
@@ -50,6 +50,9 @@
   "Darwin"|"FreeBSD"|"DragonFly")
     chksum='shasum -a 512 --check'
   ;;
+  "OpenBSD")
+    chksum="sha512 -c"
+  ;;
   *)
     chksum='sha512sum -c'
   ;;
~/trunk $ contrib/download_prerequisites  
(SHA512) gmp-6.1.0.tar.bz2: OK
(SHA512) mpfr-3.1.4.tar.bz2: OK
(SHA512) mpc-1.0.3.tar.gz: OK
(SHA512) isl-0.18.tar.bz2: OK
tar: input compressed with bzip2; use the -j option to decompress it
error: Cannot extract package from gmp-6.1.0.tar.bz2

*sigh*
Comment 4 Thomas Koenig 2019-07-04 19:08:47 UTC
~/trunk $ svn diff contrib/                                                                                                        
Index: contrib/download_prerequisites
===================================================================
--- contrib/download_prerequisites      (revision 273019)
+++ contrib/download_prerequisites      (working copy)
@@ -45,11 +45,16 @@
 verify=1
 force=0
 OS=$(uname)
+tar=tar
 
 case $OS in
   "Darwin"|"FreeBSD"|"DragonFly")
     chksum='shasum -a 512 --check'
   ;;
+  "OpenBSD")
+    chksum="sha512 -c"
+    tar="tar -j"  
+  ;;
   *)
     chksum='sha512sum -c'
   ;;
@@ -243,7 +248,7 @@
     package="${ar%.tar*}"
     if [ ${force} -gt 0 ]; then rm -rf "${directory}/${package}"; fi
     [ -e "${directory}/${package}" ]                                          \
-        || ( cd "${directory}" && tar -xf "${ar}" )                           \
+        || ( cd "${directory}" && ${tar} -xf "${ar}" )                           \
         || die "Cannot extract package from ${ar}"
     unset package
 done
~/trunk $ contrib/download_prerequisites  
(SHA512) gmp-6.1.0.tar.bz2: OK
(SHA512) mpfr-3.1.4.tar.bz2: OK
(SHA512) mpc-1.0.3.tar.gz: OK
(SHA512) isl-0.18.tar.bz2: OK
bzip2: (stdin) is not a bzip2 file.
tar: End of archive volume 1 reached
tar: Sorry, unable to determine archive format.
error: Cannot extract package from mpc-1.0.3.tar.gz

Maybe somebody who actually knows a little about BSD utilities
could take it from here.
Comment 5 Jonathan Wakely 2019-07-04 19:22:30 UTC
This is not a BSD problem, it's just a case of writing a portable shell script.

This should work:

--- a/contrib/download_prerequisites
+++ b/contrib/download_prerequisites
@@ -241,9 +241,15 @@ unset ar
 for ar in $(echo_archives)
 do
     package="${ar%.tar*}"
+    decompress_flag=
+    case $ar:$OS in
+      *.tar.gz:OpenBSD) decompress_flag=-z ;;
+      *.tar.bz2:OpenBSD) decompress_flag=-j ;;
+      *:OpenBSD) die "Unknown format: ${ar#*.tar}" ;;
+    esac
     if [ ${force} -gt 0 ]; then rm -rf "${directory}/${package}"; fi
     [ -e "${directory}/${package}" ]                                          \
-        || ( cd "${directory}" && tar -xf "${ar}" )                           \
+        || ( cd "${directory}" && tar $decompress_flag -xf "${ar}" )                           \
         || die "Cannot extract package from ${ar}"
     unset package
 done
Comment 6 Jonathan Wakely 2019-07-04 19:24:50 UTC
Or without the overlong line:

--- a/contrib/download_prerequisites
+++ b/contrib/download_prerequisites
@@ -241,9 +241,15 @@ unset ar
 for ar in $(echo_archives)
 do
     package="${ar%.tar*}"
+    decompress_flag=
+    case $ar:$OS in
+      *.tar.gz:OpenBSD) decompress_flag=-z ;;
+      *.tar.bz2:OpenBSD) decompress_flag=-j ;;
+      *:OpenBSD) die "Unknown format: ${ar#*.tar}" ;;
+    esac
     if [ ${force} -gt 0 ]; then rm -rf "${directory}/${package}"; fi
     [ -e "${directory}/${package}" ]                                          \
-        || ( cd "${directory}" && tar -xf "${ar}" )                           \
+        || ( cd "${directory}" && tar $decompress_flag -xf "${ar}" )          \
         || die "Cannot extract package from ${ar}"
     unset package
 done
Comment 7 Jonathan Wakely 2019-07-04 19:26:10 UTC
Or you could always just download the packages and untar them by hand. The script isn't mandatory, it's just a convenience.
Comment 8 Martin Liška 2020-01-21 15:03:14 UTC
@Jonathan: Is the issue fixed?
Comment 9 Thomas Koenig 2020-10-06 16:33:49 UTC
WORKSFORME on OpenBSD 6.7.
Comment 10 Andrew Pinski 2021-08-24 09:52:52 UTC
(In reply to Thomas Koenig from comment #9)
> WORKSFORME on OpenBSD 6.7.

So closing.