Creating a Package

A KPM package can be created using the kpm-helper.py script:

# Step 1. Create a folder to store your package contents
mkdir example_package
# Step 2. Initialise the package folder
python kpm-helper.py package init ./example_package

The example_package folder will now look like this:

example_package
└── manifest.json

1 directory, 1 file

The manifest file will now be initialised to target the kindleany platform (see: targeting specific platforms)

Packing

To convert your package folder to a kpkg file that can be added to a repository and that KPM can install, use kpm-helper.py:

python kpm-helper.py package pack FOLDER_PATH OUTPUT_PATH

Where FOLDER_PATH is the path to your package and OUTPUT_PATH is the folder to put the kpkg file.

Targeting Specific Platforms

There are many reasons you may want a package to only target a specific platform, kpm-helper.py can modify the manifest at pack time with the --supported-platform flag. You may also manually set the optional supported_platforms array in the manifest.json file.

Valid Platforms

  • kindle - Kindles older than the K5
  • kindle5 - K5 and newer
  • kindlepw2 - PW2 and newer
  • kindlehf - armhf platforms

Hooks

You can now put any other files in the package folder, however they won’t do anything by themselves, this is why we have hooks:

example_package
├── install.sh
├── launch.sh
├── manifest.json
└── uninstall.sh

1 directory, 5 files
File NamePurpose
install.shRan during package installation after it is unpacked
uninstall.shRan during package uninstallation after it is unmounted
launch.shRan when package is launched from a launcher

Hooks MUST NOT write to rootfs or remount it as rw, see below for more details

Hooks are always ran from the package’s folder whilst the package is in an unpacked state, this means you can reference local files with relative paths.

It is encouraged to use the install.sh hook to place a scriptlet in the /mnt/us/documents folder when appropriate.
It is recommended that the scriptlet runs /var/local/kmc/bin/kpm launch PACKAGENAME to run the package’s launch.sh

Guidelines

  • The uninstall.sh hook will be passed the parameter upgrade if this uninstallation is part of an upgrade, you can use this to determine whether configuration files should be deleted or not.
  • The uninstall.sh hook should NOT delete package files, this is handled by KPM

Writing To Rootfs

Using the install.sh hook to modify the contents of rootfs is unsupported. It is recommended that you do not do this for now.
A solution is planned to be implemented in the near future.