[Bug 273148] [PATCH] scripted installs are unable to verify checksums for fetched dists

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 15 Aug 2023 15:53:20 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273148

            Bug ID: 273148
           Summary: [PATCH] scripted installs are unable to verify
                    checksums for fetched dists
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: lars@oddbit.com

Created attachment 244122
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=244122&action=edit
Patch to revert erroneous changes in 1f7746d81f53447ac15cc99395bb714d4dd0a4da.

In commit 1f7746d81f53447ac15cc99395bb714d4dd0a4da, a change was introduced
that breaks scripted installs.  Given an installerconfig file like this:

```
export PARTITIONS=DEFAULT
export DISTRIBUTIONS="kernel.txz base.txz"
export HOSTNAME=freebsd
export
BSDINSTALL_DISTSITE="https://download.freebsd.org/releases/amd64/13.2-RELEASE"

export nonInteractive="YES"

dhclient $INTERFACES

#!/bin/sh
sysrc ifconfig_DEFAULT=DHCP
sysrc sshd_enable=YES
```

The installation will always fail with a checksum error. This happens because
the remote dists are fetched like this:

```
(
        exec 3>&1
        export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&3)
        FETCH_RESULT=$?
        exec 3>&-
        return $FETCH_RESULT
) || error "Could not fetch remote distributions"
```

There is an attempt there to change the value of $BSDINSTALL_DISTDIR to the
location of the fetched files, but since this logic was placed in a subshell
that change is now a no-op.

Additionally, this code attempts to "return" from a subshell, but "return" is
only valid in functions.

The attached patch reverts this change so that both "auto" and "script" use the
same logic for fetching remote dists, and scripted installs operate as
intended.

-- 
You are receiving this mail because:
You are the assignee for the bug.