1b70047d4SNathan Whitehorn#!/bin/sh 2b70047d4SNathan Whitehorn#- 3b70047d4SNathan Whitehorn# Copyright (c) 2011 Nathan Whitehorn 4b70047d4SNathan Whitehorn# All rights reserved. 5b70047d4SNathan Whitehorn# 6b70047d4SNathan Whitehorn# Redistribution and use in source and binary forms, with or without 7b70047d4SNathan Whitehorn# modification, are permitted provided that the following conditions 8b70047d4SNathan Whitehorn# are met: 9b70047d4SNathan Whitehorn# 1. Redistributions of source code must retain the above copyright 10b70047d4SNathan Whitehorn# notice, this list of conditions and the following disclaimer. 11b70047d4SNathan Whitehorn# 2. Redistributions in binary form must reproduce the above copyright 12b70047d4SNathan Whitehorn# notice, this list of conditions and the following disclaimer in the 13b70047d4SNathan Whitehorn# documentation and/or other materials provided with the distribution. 14b70047d4SNathan Whitehorn# 15b70047d4SNathan Whitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16b70047d4SNathan Whitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17b70047d4SNathan Whitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18b70047d4SNathan Whitehorn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19b70047d4SNathan Whitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20b70047d4SNathan Whitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21b70047d4SNathan Whitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22b70047d4SNathan Whitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23b70047d4SNathan Whitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24b70047d4SNathan Whitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25b70047d4SNathan Whitehorn# SUCH DAMAGE. 26b70047d4SNathan Whitehorn# 27b70047d4SNathan Whitehorn 28b70047d4SNathan Whitehorntest -f $BSDINSTALL_DISTDIR/MANIFEST || exit 0 29b70047d4SNathan Whitehorn 30cc42ef53SBrad DavisBSDCFG_SHARE="/usr/share/bsdconfig" 31cc42ef53SBrad Davis. $BSDCFG_SHARE/common.subr || exit 1 32cc42ef53SBrad Davis 33*47d669f1SJessica Clarkedist_to_statusvar() 34*47d669f1SJessica Clarke{ 35*47d669f1SJessica Clarke printf 'status_' 36*47d669f1SJessica Clarke echo "$1" | sed 's/_/__/g;s/\./_dot_/g;s/-/_dash_/g' 37*47d669f1SJessica Clarke} 38*47d669f1SJessica Clarke 39b70047d4SNathan Whitehornpercentage=0 40b70047d4SNathan Whitehornfor dist in $DISTRIBUTIONS; do 41*47d669f1SJessica Clarke statusvar=$(dist_to_statusvar $dist) 42*47d669f1SJessica Clarke eval "$statusvar=-8" 43b70047d4SNathan Whitehorn 44b70047d4SNathan Whitehorn items="" 45b70047d4SNathan Whitehorn for i in $DISTRIBUTIONS; do 46*47d669f1SJessica Clarke items="$items $i `eval echo \\\${$(dist_to_statusvar $i):--11}`" 47b70047d4SNathan Whitehorn done 48cc42ef53SBrad Davis bsddialog --backtitle "$OSNAME Installer" --title "Checksum Verification" \ 490868f621SAlfonso S. Siciliano --mixedgauge "\nVerifying checksums of selected distributions.\n" \ 500868f621SAlfonso S. Siciliano 0 0 $percentage -- $items 51b70047d4SNathan Whitehorn 52b70047d4SNathan Whitehorn CK=`sha256 -q $BSDINSTALL_DISTDIR/$dist` 53c31153adSNathan Whitehorn awk -v checksum=$CK -v dist=$dist -v found=0 '{ 54b70047d4SNathan Whitehorn if (dist == $1) { 55c31153adSNathan Whitehorn found = 1 56b70047d4SNathan Whitehorn if (checksum == $2) 57b70047d4SNathan Whitehorn exit(0) 58b70047d4SNathan Whitehorn else 59c31153adSNathan Whitehorn exit(2) 60b70047d4SNathan Whitehorn } 61c31153adSNathan Whitehorn } END {if (!found) exit(1);}' $BSDINSTALL_DISTDIR/MANIFEST 62b70047d4SNathan Whitehorn 63c31153adSNathan Whitehorn CK_VALID=$? 64c31153adSNathan Whitehorn if [ $CK_VALID -le 1 ]; then 65c31153adSNathan Whitehorn if [ $CK_VALID -eq 0 ]; then 66*47d669f1SJessica Clarke eval "$statusvar=-3" 67c31153adSNathan Whitehorn else 68*47d669f1SJessica Clarke eval "$statusvar=-7" 69c31153adSNathan Whitehorn fi 70b70047d4SNathan Whitehorn percentage=$(echo $percentage + 100/`echo $DISTRIBUTIONS | wc -w` | bc) 71b70047d4SNathan Whitehorn else 72*47d669f1SJessica Clarke eval "$statusvar=-2" 732775c1d7SEd Maste case $(/bin/freebsd-version -u) in 742775c1d7SEd Maste *-ALPHA*|*-CURRENT|*-STABLE|*-PRERELEASE) 75cc42ef53SBrad Davis bsddialog --backtitle "$OSNAME Installer" --title "Error" \ 762913e785SBrad Davis --msgbox "The checksum for $dist does not match. It may have become corrupted, or it may be from a newer version of $OSNAME. Please check for a newer snapshot." 0 0 772775c1d7SEd Maste ;; 782775c1d7SEd Maste *) 79cc42ef53SBrad Davis bsddialog --backtitle "$OSNAME Installer" --title "Error" \ 80b70047d4SNathan Whitehorn --msgbox "The checksum for $dist does not match. It may have become corrupted, and should be redownloaded." 0 0 812775c1d7SEd Maste ;; 822775c1d7SEd Maste esac 83b70047d4SNathan Whitehorn exit 1 84b70047d4SNathan Whitehorn fi 85b70047d4SNathan Whitehorndone 86b70047d4SNathan Whitehorn 87b70047d4SNathan Whitehornexit 0 88