Date: Sun, 2 Jan 2022 16:08:16 +0100 From: "alf.siciliano@gmail.com" <alf.siciliano@gmail.com> To: Baptiste Daroussin <bapt@FreeBSD.org> Cc: Jessica Clarke <jrtc27@freebsd.org>, "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org>, alfsiciliano@gmail.com Subject: Re: git: 18f20d5d967a - main - bsddialog: convert bsdinstall/distextract Message-ID: <20220102160816.b1d9227fcece8eec1086d5cc@gmail.com> In-Reply-To: <20220101214002.k5jy6o7h2njst7l5@aniel.nours.eu> References: <202201012052.201KqrhV082129@gitrepo.freebsd.org> <41538126-67AC-4C19-9414-BD4E8B85D23B@freebsd.org> <20220101214002.k5jy6o7h2njst7l5@aniel.nours.eu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 1 Jan 2022 22:40:02 +0100 Baptiste Daroussin <bapt@FreeBSD.org> wrote: > On Sat, Jan 01, 2022 at 09:35:50PM +0000, Jessica Clarke wrote: > > On 1 Jan 2022, at 20:52, Baptiste Daroussin <bapt@FreeBSD.org> wrote: > > >=20 > > > The branch main has been updated by bapt: > > >=20 > > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D18f20d5d967ae790f12196= 3e1fcee68d729a529e > > >=20 > > > commit 18f20d5d967ae790f121963e1fcee68d729a529e > > > Author: Alfonso Siciliano <alfsiciliano@gmail.com> > > > AuthorDate: 2022-01-01 20:50:44 +0000 > > > Commit: Baptiste Daroussin <bapt@FreeBSD.org> > > > CommitDate: 2022-01-01 20:51:23 +0000 > > >=20 > > > bsddialog: convert bsdinstall/distextract > > >=20 > > > Differential Revision: https://reviews.freebsd.org/D33581 > > > --- > > > usr.sbin/bsdinstall/distextract/Makefile | 3 +- > > > usr.sbin/bsdinstall/distextract/distextract.c | 180 +++++++++++++----= --------- > > > 2 files changed, 92 insertions(+), 91 deletions(-) > > >=20 > > > diff --git a/usr.sbin/bsdinstall/distextract/Makefile b/usr.sbin/bsdi= nstall/distextract/Makefile > > > index 2b7180e28ea0..5e9f2b9e1473 100644 > > > --- a/usr.sbin/bsdinstall/distextract/Makefile > > > +++ b/usr.sbin/bsdinstall/distextract/Makefile > > > @@ -2,7 +2,8 @@ > > >=20 > > > BINDIR=3D ${LIBEXECDIR}/bsdinstall > > > PROG=3D distextract > > > -LIBADD=3D archive dpv dialog m > > > +CFLAGS+=3D -I${SRCTOP}/contrib/bsddialog/lib > > > +LIBADD=3D archive bsddialog m > > >=20 > > > MAN=3D > > >=20 > > > diff --git a/usr.sbin/bsdinstall/distextract/distextract.c b/usr.sbin= /bsdinstall/distextract/distextract.c > > > index 8ad6c7b2c64b..df10c299ab7f 100644 > > > --- a/usr.sbin/bsdinstall/distextract/distextract.c > > > +++ b/usr.sbin/bsdinstall/distextract/distextract.c > > > @@ -33,11 +33,12 @@ __FBSDID("$FreeBSD$"); > > > #include <sys/param.h> > > > #include <archive.h> > > > #include <ctype.h> > > > -#include <dialog.h> > > > -#include <dpv.h> > > > +#include <bsddialog.h> > > > +#include <bsddialog_progressview.h> > > > #include <err.h> > > > #include <errno.h> > > > #include <limits.h> > > > +#include <signal.h> > > > #include <stdio.h> > > > #include <stdlib.h> > > > #include <string.h> > > > @@ -46,30 +47,27 @@ __FBSDID("$FreeBSD$"); > > > /* Data to process */ > > > static char *distdir =3D NULL; > > > static struct archive *archive =3D NULL; > > > -static struct dpv_file_node *dists =3D NULL; > > >=20 > > > /* Function prototypes */ > > > static void sig_int(int sig); > > > static int count_files(const char *file); > > > -static int extract_files(struct dpv_file_node *file, int out); > > > +static int extract_files(struct bsddialog_fileminibar *file); > > >=20 > > > -#define _errx(...) (end_dialog(), errx(__VA_ARGS__)) > > > +#define _errx(...) (bsddialog_end(), errx(__VA_ARGS__)) > > >=20 > > > int > > > main(void) > > > { > > > char *chrootdir; > > > char *distributions; > > > + unsigned int i; > > > int retval; > > > - size_t config_size =3D sizeof(struct dpv_config); > > > - size_t file_node_size =3D sizeof(struct dpv_file_node); > > > + size_t minibar_size =3D sizeof(struct bsddialog_fileminibar); > > > size_t span; > > > - struct dpv_config *config; > > > - struct dpv_file_node *dist =3D dists; > > > - static char backtitle[] =3D "FreeBSD Installer"; > > > - static char title[] =3D "Archive Extraction"; > > > - static char aprompt[] =3D "\n Overall Progress:"; > > > - static char pprompt[] =3D "Extracting distribution files...\n"; > > > + unsigned int nminibars; > > > + struct bsddialog_fileminibar *dists; > > > + struct bsddialog_progviewconf pvconf; > > > + struct bsddialog_conf conf; > > > struct sigaction act; > > > char error[PATH_MAX + 512]; > > >=20 > > > @@ -78,17 +76,17 @@ main(void) > > > if ((distdir =3D getenv("BSDINSTALL_DISTDIR")) =3D=3D NULL) > > > distdir =3D __DECONST(char *, ""); > > >=20 > > > - /* Initialize dialog(3) */ > > > - init_dialog(stdin, stdout); > > > - dialog_vars.backtitle =3D backtitle; > > > - dlg_put_backtitle(); > > > - > > > - dialog_msgbox("", > > > - "Checking distribution archives.\nPlease wait...", 4, 35, FALSE= ); > > > - > > > - /* > > > - * Parse $DISTRIBUTIONS into dpv(3) linked-list > > > - */ > > > + if (bsddialog_init() =3D=3D BSDDIALOG_ERROR) > > > + errx(EXIT_FAILURE, "Cannot init libbsdialog"); > > > + bsddialog_initconf(&conf); > > > + bsddialog_backtitle(&conf, __DECONST(char *, "FreeBSD Installer")); > >=20 > > Can all these interfaces really not just use a const char * rather than > > having to scatter __DECONST everywhere if you want to pass a string > > literal to functions like this? There are quite a few __DECONST?s of > > string literals in this patch alone... > >=20 > > Jess >=20 > Adding Alfonso to CC. >=20 > Yes I agree, the __DECONST are from me, not from Alfonso, I added them to= avoid > having to play with WARNS and make progress in the conversion anyway. The= n start > the discussion with Alfonso to see how we can improve this. >=20 > Best regrads, > Bapt Hi Jessica, Thank you for your report, Briefly: I know the problem and it is in the TODO list, I hope to improve soon, it was very tedious "__DECONST" each string in bsdinstall. Rationale:=20 libbsddialog is a new library without real world use cases, indeed it is private in BASE; so far we are adding it "for steps" in PORTS and BASE. I implemented the features to replace LGPL libdialog, now we are working mainly to test/fix/improve the dialogs (infobox, checklist, form, etc) to complete the "library-migration" process. Fortunately this phase is ending (only 2 reviews in progress), then I' ll improve the lib/API: char*/const char*, mixedgauge, wrapping text autosize algorithm, re-update bsdinstall. Finally, the last step: bsddialog utility in bsdinstall/scripts. Please let me know any problem or if you need some new or GPL-dialog feature in bsddialog. Best regards, Alfonso ---=20 Alfonso S. Siciliano=20 http://alfonsosiciliano.gitlab.io
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20220102160816.b1d9227fcece8eec1086d5cc>