Page MenuHomeFreeBSD

bsdinstall: allow whitelabeling the installer
ClosedPublic

Authored by brd on Apr 11 2022, 1:25 AM.
Tags
None
Referenced Files
F82232685: D34878.diff
Fri, Apr 26, 7:13 PM
F82162172: D34878.id105945.diff
Fri, Apr 26, 2:10 AM
Unknown Object (File)
Thu, Apr 25, 8:07 PM
Unknown Object (File)
Thu, Apr 25, 8:07 PM
Unknown Object (File)
Tue, Apr 23, 7:48 PM
Unknown Object (File)
Mon, Apr 8, 5:42 AM
Unknown Object (File)
Mar 20 2024, 10:36 PM
Unknown Object (File)
Jan 30 2024, 8:18 AM

Details

Summary

Override OSNAME to change the name of the OS in the installer.

This is a first step, the shell script changes will be a separate review.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

brd requested review of this revision.Apr 11 2022, 1:25 AM

hi @brd, I tested the 'partedit' and it seems all right.

usr.sbin/bsdinstall/Makefile
16

A question (for me) to understand, is the creation of a new file the way to "pass" a value to a MACRO? Can our make(1) or the compiler do something like CFLAGS+= -DOSNAME=${VALUE}?

usr.sbin/bsdinstall/distextract/distextract.c
46–47

Maybe a new line between include<> and include "" (also in other files).

This revision is now accepted and ready to land.Apr 11 2022, 7:50 AM

Address blank line between local include and system include

This revision now requires review to proceed.Apr 11 2022, 2:41 PM
brd marked 2 inline comments as done.Apr 11 2022, 2:42 PM
brd added inline comments.
usr.sbin/bsdinstall/Makefile
16

Yes. I tested using the flag to make(1).

This revision is now accepted and ready to land.Apr 11 2022, 6:04 PM

The review is accepted already,

I did just some test because the topic is interesting and I had the same problem in the past (solved by hardcode :-) ).
The trick seems the backaslash + double quote:
Let' s consider partedit/Makefile (of course deleting: the code to create a new file in the up-Makefile and #include "opt_osname.h in partedit.c)

BINDIR= ${LIBEXECDIR}/bsdinstall
PROG=	distextract
.if defined (OSNAME)
LABEL="${OSNAME}"
.else
LABEL="FreeBSD"
.endif
CFLAGS+=	-I${SRCTOP}/contrib/bsddialog/lib -D OSNAME=\"${LABEL}\"
LIBADD=	archive bsddialog m

MAN=

.include <bsd.prog.mk>

Without a defined OSNAME:
% cd partedit
% make clean ; make cleandir ; make ; ./partedit

┌──────────────────────┤Partition Editor├───────────────────────┐
│ Create partitions for FreeBSD, F1 for help.                   │  
│ No changes will be made until you select Finish.              │  
│                                                               │

...FreeBSD... OK!

with a defined OSNAME

% make clean ; make cleandir ; env OSNAME="MY BSD OS" make ; ./partedit

┌──────────────────────┤Partition Editor├───────────────────────┐
│ Create partitions for MY BSD OS, F1 for help.                 │  
│ No changes will be made until you select Finish.              │  
│                                                               │

...MY BSD OS... OK!

If we define a variable with the makefile % make -D OSNAME LABEL will be 1 (one), so we could solve setting the value in Makefile:

.if defined (OSNAME)
LABEL="MY BSD OS"
.else
LABEL="FreeBSD"
.endif
CFLAGS+=	-I${SRCTOP}/contrib/bsddialog/lib -D OSNAME=\"${LABEL}\"

Then we can switch the label like early.

...just 2 cent to remember to myself :-), of course I' ll continue to investigate or ask to some expert.

brd marked an inline comment as done.Apr 14 2022, 5:50 PM

@asiciliano The reason I did it using a file is so that make(1) would detect a change a rebuild if you change the value and do another build.

In D34878#791429, @brd wrote:

@asiciliano The reason I did it using a file is so that make(1) would detect a change a rebuild if you change the value and do another build.

@brd The review is ok, I posted some test to remember to myself and to ask to somebody, I had a similar situation in the past. I'm sorry if it was unclear and boring.

In D34878#791429, @brd wrote:

@asiciliano The reason I did it using a file is so that make(1) would detect a change a rebuild if you change the value and do another build.

@brd The review is ok, I posted some test to remember to myself and to ask to somebody, I had a similar situation in the past. I'm sorry if it was unclear and boring.

OK, cool, I just wanted to make sure the reasoning for doing what I did was understood. Thanks for the review :)

This revision was automatically updated to reflect the committed changes.