Bug 252270 - pkg bootstrap: support for -4 -6 flags
Summary: pkg bootstrap: support for -4 -6 flags
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Baptiste Daroussin
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2020-12-29 17:30 UTC by Evilham
Modified: 2021-05-05 08:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Evilham 2020-12-29 17:30:12 UTC
pkg bootstrap does not support the -4 and -6 flags, which means that in certain edge cases, where e.g. IPv6 connectivity might be patchy or still not fully available, bootstrapping pkg can be difficult.

Reported by dvl and confirmed by bapt on bsd.network:
https://bsd.network/@dvl/105459633226703486
Comment 1 Evilham 2020-12-29 17:31:37 UTC
I'm taking a go at it (matter of parsing arguments and passing the flags to fetchXGet), will be linking a patch here.
Comment 2 Evilham 2020-12-31 01:52:33 UTC
Patch for review: https://reviews.freebsd.org/D27860

While looking into this, I noticed that the argument handling changed between 12.1 and 12.2, and behaviour had changed slightly.
One instance of this [1] means that pkg bootstrap -y doesn't work, which it did in 12.1, but was not documented.

I attempted to use getopt_long so options work in a more natural fashion and at the same time keep pkg(7) fully compatible with pkg(8).

[1]: https://code.ungleich.ch/ungleich-public/cdist/-/issues/846
Comment 3 commit-hook freebsd_committer 2021-01-06 10:48:20 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=ae994fdc5bd2ccc0ac0b8745fd1f1be67ad6e071

commit ae994fdc5bd2ccc0ac0b8745fd1f1be67ad6e071
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2021-01-06 10:35:22 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2021-01-06 10:47:34 +0000

    pkg(7): rework the arguments handling

    Rework the arguments handling around using getopt_long:
    * add long option support
    * add -4 and -6 support to enforce ipv4 or ipv6

    While here fix a regression which occured between FreeBSD 12.1 and
    FreeBSD 12.2 where pkg bootstrap -y stopped working

    PR:             252270
    MFC after:      2 weeks
    Submitted by:   evilham <contact@evilham.com>
    Differential Revision:  https://reviews.freebsd.org/D27860

 usr.sbin/pkg/pkg.7 |  25 ++++++++++--
 usr.sbin/pkg/pkg.c | 117 ++++++++++++++++++++++++++++++++++++-----------------
 2 files changed, 102 insertions(+), 40 deletions(-)
Comment 4 commit-hook freebsd_committer 2021-05-05 08:26:10 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0543e10e950dd5c8b17cdb7cf60b9f95aece094a

commit 0543e10e950dd5c8b17cdb7cf60b9f95aece094a
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2021-01-06 10:35:22 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2021-05-05 08:16:47 +0000

    pkg(7): rework the arguments handling

    Rework the arguments handling around using getopt_long:
    * add long option support
    * add -4 and -6 support to enforce ipv4 or ipv6

    While here fix a regression which occured between FreeBSD 12.1 and
    FreeBSD 12.2 where pkg bootstrap -y stopped working

    PR:             252270
    Submitted by:   evilham <contact@evilham.com>
    Differential Revision:  https://reviews.freebsd.org/D27860

    (cherry picked from commit ae994fdc5bd2ccc0ac0b8745fd1f1be67ad6e071)

 usr.sbin/pkg/pkg.7 |  25 ++++++++++--
 usr.sbin/pkg/pkg.c | 117 ++++++++++++++++++++++++++++++++++++-----------------
 2 files changed, 102 insertions(+), 40 deletions(-)