Page MenuHomeFreeBSD

Make NanoBSD source-able from other scripts.
ClosedPublic

Authored by will on Dec 16 2014, 3:21 AM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 12:16 AM
Unknown Object (File)
Nov 11 2023, 6:45 AM
Unknown Object (File)
Nov 8 2023, 2:57 PM
Unknown Object (File)
Oct 10 2023, 5:47 AM
Unknown Object (File)
Oct 7 2023, 1:47 PM
Unknown Object (File)
Aug 16 2023, 11:02 AM
Unknown Object (File)
Jul 13 2023, 8:43 AM
Unknown Object (File)
Apr 25 2023, 9:25 AM
Subscribers
None

Details

Summary

This change converts NanoBSD into a two-script bundle.

  • defaults.sh contains all non-CLI code. Most NanoBSD code is moved into this file.
  • nanobsd.sh now consists just of a command line interface that calls into functions in defaults.sh.
Test Plan

Run NanoBSD using a previously-working configuration.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

will retitled this revision from to Make NanoBSD source-able from other scripts..
will updated this object.
will edited the test plan for this revision. (Show Details)
will added a reviewer: imp.

So what's the motivation for this?

tools/tools/nanobsd/nanobsd.sh
32 ↗(On Diff #2755)

Does this work if you've run the shell script via a path listed in $PATH?

The motivation is primarily to enable using NanoBSD within another script. This can be useful for sharing configuration data, for example.

imp edited edge metadata.

Sure, but there's one big caveat. The API between nanobsd.sh and defaults.sh is currently undocumented and subject to change. cust_pkg is definitely going to be deleted soon, for example. All the geometry stuff to create a disk is likely to be redone (though the current APIs might remain).

Unless there's documentation and/or documented users, external folks are going to have a bumpy ride.

This revision is now accepted and ready to land.Dec 16 2014, 5:32 PM

That's true, but the point of the change is merely to enable reuse, not necessarily to make any sort of API guarantee.

tools/tools/nanobsd/nanobsd.sh
32 ↗(On Diff #2755)

Yes; as far as I can tell, this mechanism works regardless of how you invoke the script. In that particular case, $0 is already the fully expanded path:

will@sol% cat ~/bin/foo; foo
#!/bin/sh
x=realpath $0
echo "\$0='$0' x='${x}'"
$0='/home/will/bin/foo' x='/home/will/bin/foo'
will@sol% cd ~/bin; ./foo
$0='./foo' x='/home/will/bin/foo'

will updated this revision to Diff 2766.

Closed by commit rS275832 (authored by @will).