mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 02:37:15 +00:00
![Jessica Clarke](/assets/img/avatar_default.png)
Currently we just strip the .txz of the dist name (and add a status_
prefix) to get the shell variable name for its status, but this doesn't
give a valid result for dists like base-dbg, kernel-dbg and lib32-dbg,
or even kernel.KERNCONF (or, combining the two, kernel.KERNCONF-dbg). As
a result, four things go wrong for such dists:
1. If there is a dot and/or a dash in the name, writing to the variable
fails and spits an error out on stderr to the log
3. If there is a dot in the name before any dash, the syntax is always
invalid, reading the variable fails, spits an error out on stderr to
the log, the result is the empty string and that is interpreted as
being 0%
2. If there is a dash in the name before any dot, and there is a dist
whose name is the substring up to that first dash, and it has already
had its status written to, reading the variable instead reads that
dist's variable and so the status of that dist is displayed instead
3. If there is a dash in the name before any dot, and either there is
not a dist whose name is the substring up to that first dash or there
is such a dist but it has not already had its status written to,
reading the varaible instead results in the substring after the first
dash, including any additional string expansion syntax that follows
(i.e. ${status_kernel-dbg:--11}, the expression used to read the
variable, is interpreted as reading status_kernel with a default
value of "dbg:--11")
For example, in a default install with base, kernel, kernel-dbg and
lib32, the following sequence of displays happens:
1. base is In Progress, kernel is Pending, kernel-dbg is 0% (what shows
for the garbage input "dbg:--11") and lib32 is Pending
2. base is Passed, kernel is In Progress, kernel-dbg is In Progress
(since kernel has now had its status written to) and lib32 is
Pending
3. base is Passed, kernel is Passed, kernel-dbg is Passed (again, since
that is the status of kernel, despite that kernel-dbg is being
verified at this point) and lib32 is Pending
4. base is Passed, kernel is Passed, kernel-dbg is Passed and lib32 is
In Progress
Fix this with a crude encoding scheme. More special characters can
easily be added if needed in future.
Note that, prior to bsddialog being used (and thus for branches this is
MFC'ed to where dialog is still used), the same problem existed but
displayed slightly differently due to a combination of different default
values and different behaviour for unintended inputs.
Fixes: b70047d413
("Add generation of an installation manifest containing SHA256 checksums as ...")
MFC after: 1 week
88 lines
2.9 KiB
Bash
Executable file
88 lines
2.9 KiB
Bash
Executable file
#!/bin/sh
|
|
#-
|
|
# Copyright (c) 2011 Nathan Whitehorn
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions
|
|
# are met:
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
# SUCH DAMAGE.
|
|
#
|
|
|
|
test -f $BSDINSTALL_DISTDIR/MANIFEST || exit 0
|
|
|
|
BSDCFG_SHARE="/usr/share/bsdconfig"
|
|
. $BSDCFG_SHARE/common.subr || exit 1
|
|
|
|
dist_to_statusvar()
|
|
{
|
|
printf 'status_'
|
|
echo "$1" | sed 's/_/__/g;s/\./_dot_/g;s/-/_dash_/g'
|
|
}
|
|
|
|
percentage=0
|
|
for dist in $DISTRIBUTIONS; do
|
|
statusvar=$(dist_to_statusvar $dist)
|
|
eval "$statusvar=-8"
|
|
|
|
items=""
|
|
for i in $DISTRIBUTIONS; do
|
|
items="$items $i `eval echo \\\${$(dist_to_statusvar $i):--11}`"
|
|
done
|
|
bsddialog --backtitle "$OSNAME Installer" --title "Checksum Verification" \
|
|
--mixedgauge "\nVerifying checksums of selected distributions.\n" \
|
|
0 0 $percentage -- $items
|
|
|
|
CK=`sha256 -q $BSDINSTALL_DISTDIR/$dist`
|
|
awk -v checksum=$CK -v dist=$dist -v found=0 '{
|
|
if (dist == $1) {
|
|
found = 1
|
|
if (checksum == $2)
|
|
exit(0)
|
|
else
|
|
exit(2)
|
|
}
|
|
} END {if (!found) exit(1);}' $BSDINSTALL_DISTDIR/MANIFEST
|
|
|
|
CK_VALID=$?
|
|
if [ $CK_VALID -le 1 ]; then
|
|
if [ $CK_VALID -eq 0 ]; then
|
|
eval "$statusvar=-3"
|
|
else
|
|
eval "$statusvar=-7"
|
|
fi
|
|
percentage=$(echo $percentage + 100/`echo $DISTRIBUTIONS | wc -w` | bc)
|
|
else
|
|
eval "$statusvar=-2"
|
|
case $(/bin/freebsd-version -u) in
|
|
*-ALPHA*|*-CURRENT|*-STABLE|*-PRERELEASE)
|
|
bsddialog --backtitle "$OSNAME Installer" --title "Error" \
|
|
--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
|
|
;;
|
|
*)
|
|
bsddialog --backtitle "$OSNAME Installer" --title "Error" \
|
|
--msgbox "The checksum for $dist does not match. It may have become corrupted, and should be redownloaded." 0 0
|
|
;;
|
|
esac
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
exit 0
|