- echo Now downloading BINUTILS...
- wget ${WGET_OPTS} ${BINUTILS}
-
- echo Now downloading GCC...
- wget ${WGET_OPTS} ${GCCCORE}
-
- echo Now downloading G++...
- wget ${WGET_OPTS} ${GPP}
-
- echo Now downloading NEWLIB...
- wget ${WGET_OPTS} ${NEWLIB}
-
- echo Now downloading INSIGHT...
- wget ${WGET_OPTS} ${INSIGHT}
-
- echo Now downloading GDB...
- wget ${WGET_OPTS} ${GDB}
-
- echo Now downloading GMP...
- wget ${WGET_OPTS} ${GMP}
-
- echo Now downloading MPFR...
- wget ${WGET_OPTS} ${MPFR}
-
- touch all.downloaded
+ wget ${WGET_OPTS} ${GNU_KEYRING}
+
+ # TODO: guess it's better to have a function that "downloads, checks file-presence and signature, and returns true/false" whether the file is ok
+ # Function will check if file exists (otherwise try to download the file - if failed and file still doesn't exist, complain and exit the script)
+ # Check if signature file exists (otherwise download the signature file as well - if download fail, warn the user and return function)
+ # Check the signature. If failed, backup-by-renaming current files, redownload both file & signature, run the function body one more time - if still no success, warn and return from function
+
+ function download_lib {
+ echo Now downloading $1
+ wget ${WGET_OPTS} $2
+ }
+
+ function download_signed_lib {
+ download_lib $1 $2
+ wget -N ${WGET_OPTS} $2.sig
+ gpg $GPG_OPTS --verify $3.sig 2> /dev/null
+ if [[ $? != 0 ]]; then
+ echo "Failed signature check for:" $3.sig
+ exit 1
+ fi
+ }
+
+ # NOTE: If new downloads are added here, please see the IMPORTANT note below
+ download_signed_lib BINUTILS ${BINUTILS} ${BINUTILS_TAR} || exit 1
+ download_signed_lib GCC ${GCCCORE} ${GCCCORE_TAR} || exit 1
+ download_signed_lib G++ ${GPP} ${GPP_TAR} || exit 1
+ download_lib NEWLIB ${NEWLIB}
+ # TODO: signature/hash check
+ download_lib INSIGHT ${INSIGHT}
+ # TODO: signature/hash check
+ download_signed_lib GDB ${GDB} ${GDB_TAR} || exit 1
+ download_signed_lib GMP ${GMP} ${GMP_TAR} || exit 1
+ download_signed_lib MPFR ${MPFR} ${MPFR_TAR} || exit 1
+
+ # IMPORTANT: Here is the number of .tar. archives downloaded above. Please update if new .tar. are added to download list.
+ if [[ `ls -1 *.tar.bz2 *.tar.gz | wc -l` != 8 ]]; then
+ echo "Seems like not all prerequisite files downloaded... Exiting."
+ exit 1
+ else
+ touch all.downloaded
+ fi