tinyramfs/docs/tinyramfs.hooks.7
2020-09-08 22:34:45 +03:00

177 lines
3.9 KiB
Groff

.\" Generated by scdoc 1.11.0
.\" Complete documentation for this program is not available as a GNU info page
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.nh
.ad l
.\" Begin generated content:
.TH "tinyramfs.hooks" "7" "2020-09-08"
.P
.SH NAME
.P
Tinyramfs - hooks and related stuff
.P
.SH DESCRIPTION
.P
Hooks can be located in \fB/usr/share/tinyramfs/hooks\fR (system path) and
\fB/etc/tinyramfs/hooks\fR (user path).\& Tinyramfs also allows you to specify custom
location via \fB-H\fR option.\& See \fBtinyramfs\fR(8) for more information.\&
.P
Hooks provides a way to extend build and init process.\& Hooks must be written in
POSIX shell.\& Bashisms and other non-portable extensions are forbidden.\& In order
to write hooks you must know about hook structure.\&
.P
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
<hook> - directory of hook scripts
.RS 4
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
<hook> - invoked in build process.\&
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
<hook>.\&init - invoked in init process.\&
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
<hook>.\&init.\&late - invoked after root filesystem was mounted.\&
.RE
.P
.RE
.SS MAN PAGE SYNTAX
.P
.nf
.RS 4
- B: extension can be used in build process
- I: extension can be used in init process
- BI: extension can be used in both processes
.fi
.RE
.P
.SH EXTENSIONS
.P
Tinyramfs also provides some extensions and environment variables to easily
interact with build and init system.\&
.P
.SS BI: print <message>
.P
.RS 4
Print message to stdout.\&
.P
.RE
.SS BI: panic [message]
.P
.RS 4
If message was not specified, then tinyramfs will print default error
message.\& otherwise message will be printed.\&
.P
.RE
.SS B: copy_module <full path>
.P
.RS 4
Copy kernel module by path to tinyramfs working directory.\&
.P
.RE
.SS B: copy_binary <name or full path>
.P
.RS 4
If full path was specified and it's has executable bit, then it's will
be copied to /bin location of tinyramfs working directory.\&
.P
If name was specified, then tinyramfs will try to find command by name
in PATH.\& If it's success, command will be copied to /bin location of
tinyramfs working directory.\& Otherwise error message will appear.\&
.P
.RE
.SS B: copy_file <file> <destination> <mode> <strip>
.P
.RS 4
<file> must be full path to file.\&
.P
<destination> must be full path where <file> should be stored.\& Tinyramfs
will automatically create all leading directories if they aren't exist
already.\& Also no need to prepend path of tinyramfs working directory.\&
.P
<mode> permissions in octal format.\&
.P
<strip> if was set to 1, then tinyramfs will attempt to run strip
on file.\& Tinyramfs will silently ignore errors if strip doesn't
exists or failed to strip binary.\&
.P
.RE
.SS I: resolve_device <UUID|LABEL|/dev/\*|PARTUUID>
.P
.RS 4
Sets \fBdevice\fR variable to full path of resolved UUID|LABEL|/dev/*|PARTUUID
.P
.RE
.SH VARIABLES
.P
.nf
.RS 4
- BI: debug - 1 if debug mode enabled
- I: break - breakpoint for debugging
- B: tmpdir - full path of tinyramfs working directory (initramfs rootfs in future)
- B: kernel - kernel version
- B: moddir - modules directory
- B: config - config location
- B: srcdir - directory of tinyramfs system files
- B: output - output path
- BI: see tinyramfs\&.config(5)
.fi
.RE
.P
.SH EXAMPLES
.P
This example will show how to handle soft dependencies of ext4 module.\&
Create \fB/etc/tinyramfs/hooks/ext4\fR directory and copy below scripts with
appropriate names to that directory.\& After that, prepend \fBext4\fR to \fBhooks\fR
option in tinyrams config.\&
.P
.SS ext4
.P
.nf
.RS 4
print "Copying ext4 dependencies"
for _mod in crc32c libcrc32c; do
copy_module "$_mod"
done
.fi
.RE
.P
.SS ext4.init
.P
.nf
.RS 4
modprobe -a crc32c libcrc32c
.fi
.RE
.P
.SH SEE ALSO
.P
\fBtinyramfs\fR(8) \fBtinyramfs.\&config\fR(5) \fBtinyramfs.\&cmdline\fR(7) \fBtinyramfs.\&hooks\fR(7)