On Thu, May 17, 2018 at 06:37:56PM -0600, Aaron Bieber wrote:
> On Fri, Mar 02, 2018 at 07:32:04AM -0700, Aaron Bieber wrote:
> > Hi,
> >
> > Currently disks can only be entered in the [sw]d[0-9][0-9] format at the
> > "Which disk is the root disk?" prompt. This is great for humans, but
> > things get tricky when doing an autoinstall upgrade on systems where
> > connected disks change frequently.
> >
> > This diff lets you put the DUID in the response file.
> >
> > If anyone has a better way to determine the disk from the duid, I am all
> > ears :D
> >
> > Cheers,
> > Aaron
> >
>
> Thanks to tb@, kn@, Philipp Buehler and phy1729 on #metabug! I tested a
> bsd.rd with an auto-upgrade response file. Once with a duid and once
> with a disk name. Both worked.
>
> I have an OK from tb@ unless anyone objects.
>
> The diff has been distilled down to this:
>
Paste fail, here is the latest diff:
Index: distrib/miniroot/install.sub
===================================================================
RCS file: /var/cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1067
diff -u -p -r1.1067 install.sub
--- distrib/miniroot/install.sub 7 May 2018 10:44:01 -0000 1.1067
+++ distrib/miniroot/install.sub 18 May 2018 00:16:34 -0000
@@ -336,6 +336,12 @@ get_ifs() {
done
}
+# checks whether $1 is a valid duid
+is_duid() {
+ ((${#1} == 16)) && [[ $1 == +([0-9a-f]) ]] && return 0
+ return 1
+}
+
# Return the device name of the disk device $1, which may be a disklabel UID.
get_dkdev_name() {
local _dev=${1#/dev/} _d
@@ -2231,7 +2237,8 @@ get_rootinfo() {
case $resp in
"?") diskinfo $(get_dkdevs);;
'') ;;
- *) if isin "$resp" $(get_dkdevs); then
+ *) $AUTO && is_duid "$resp" && resp=$(get_dkdev_name $resp)
+ if isin "$resp" $(get_dkdevs); then
[[ $MODE == install ]] && break
is_rootdisk "$resp" && break
echo "$resp is not a valid root disk."
--
PGP: 0x1F81112D62A9ADCE / 3586 3350 BFEA C101 DB1A 4AF0 1F81 112D 62A9 ADCE