Scripts
pkger has 3 defined build phases - configure, build and install of which only build is required to create a package.
Each phase has field called steps
that takes an array of steps to execute during a given phase. A step can be a simple
string that will be executed in the default shell like "echo 123"
or an entry that specifies on what targets it should
be executed like:
- cmd: >-
echo only on deb targets
deb: true
To set a working directory during the script phase set the working_dir
parameter like so:
working_dir: /tmp
Environment variables are available for this field so this is possible:
working_dir: ${PKGER_BLD_DIR}/${RECIPE}-${RECIPE_VERSION}-${SOME_USER_DEFINED_VAR}
To use a different shell to execute each command set the shell
parameter:
shell: "/bin/bash" # optionally change default `/bin/sh`
configure (Optional)
Optional configuration steps. If provided the steps will be executed before the build phase.
The working directory will be set to $PKGER_BLD_DIR
configure:
shell: "/bin/bash"
steps:
- cmd: >-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
build (Required)
This is the phase where the package should be assembled/compiled/linked and so on. All steps executed during the build
will have the working directory seto to $PKGER_BLD_DIR
. This directory will contain either
extracted sources if source
is specified in metadata or a git repository if git
was specified.
build:
steps:
- cmd: $HOME/.cargo/bin/cargo build --release .
- images: [ debian ]
cmd: echo 'hello from Debian' # will only be executed on image `debian`
- cmd: echo 'will only run on images with target == `rpm`'
rpm: true
# same applies to other targets
pkg: false
apk: false
deb: false
gzip: falze
- cmd: echo 'only on version 0.2.0'
versions: [ 0.2.0 ]
# fields can also be combined
- cmd: echo 'only on debian version 0.2.0'
versions: [ 0.2.0 ]
images: [ debian ]
]
install (Optional)
Optional steps that (if provided) will be executed after the build phase. Working directory of each step will be set to
$PKGER_OUT_DIR
so you can use relative paths with commands like install. Each file that
ends up in $PKGER_OUT_DIR
will be available in the final package unless explicitly
excluded by exclude
field in metadata. So in the example below, the file that is
installed will be available as /usr/bin/pkger
with permissions preserved.
install:
steps:
- cmd: >-
install -m755 $PKGER_BLD_DIR/target/release/pkger usr/bin/pkger