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)
Sun, Dec 8, 9:09 PM
Unknown Object (File)
Wed, Nov 27, 12:54 AM
Unknown Object (File)
Oct 29 2024, 12:53 PM
Unknown Object (File)
Oct 24 2024, 6:05 AM
Unknown Object (File)
Oct 23 2024, 7:37 AM
Unknown Object (File)
Oct 23 2024, 7:20 AM
Unknown Object (File)
Oct 19 2024, 12:43 AM
Unknown Object (File)
Oct 10 2024, 6:57 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).