Skip to content

Commit

Permalink
Add INCLUDE command
Browse files Browse the repository at this point in the history
Squashed commit from #33.

* Add INCLUDE command to include other Pifiles easily in our script without using sh'isms.

* Fix typo

* Move INCLUDE to 00-commands.sh so it's available in all stages.
Add description of INCLUDE command to README.md

* Fix typo

* Incorporating suggestions by @oxzi

* stages/00-commands.sh: fix shellcheck warning

* INCLUDE examples

Co-authored-by: Alvar Penning <post@0x21.biz>
  • Loading branch information
aniongithub and oxzi authored Sep 23, 2021
1 parent a75017b commit f08f3c0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ default to *rpi.img* in the source file's directory.
`INPLACE` does not create a copy of the image, but performs all further
operations on the given image. This is an alternative to `FROM` and `TO`.

#### `INCLUDE [PATH_TO_PIFILE]`
`INCLUDE` includes the provided Pifile in the current one for modularity and
re-use. The included file _has_ to have a `.Pifile` extension which need not be
specified.


#### `PUMP [SIZE]`
`PUMP` increases the image's size about the given amount (suffixes K, M, G are allowed).

Expand Down
3 changes: 3 additions & 0 deletions examples/Module-Hello.Pifile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is a simple example for an `INCLUDE`able module.

RUN echo "Included echo!"
4 changes: 4 additions & 0 deletions examples/RPi-OpenWRT.Pifile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ RUN hello
# test if INSTALL works
INSTALL "README.md" "/tmp/"
RUN head -n1 "/tmp/README.md"

# test an INCLUDE - both with and without the .Pifile extension
INCLUDE examples/Module-Hello.Pifile
INCLUDE examples/Module-Hello
10 changes: 10 additions & 0 deletions stages/00-commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ post_stage() {
:
}

# INCLUDE sources the provided Pifile
#
# Usage: INCLUDE path/to/pifile[.Pifile]
INCLUDE() {
filename="${1%.*}"
# shellcheck disable=SC1090
source "${filename}.Pifile"
}

# Stage 1x
FROM() {
:
Expand All @@ -31,6 +40,7 @@ INPLACE() {
:
}


# Stage 2x
PUMP() {
:
Expand Down

0 comments on commit f08f3c0

Please sign in to comment.