Table of Contents
apkg
is the new tool for package management and
configuration in LEAF's Bering-uClibc
branch.
It was first introduced with Bering-uClibc 3.0 and replaces the aged
lrpkg
scripts.
apkg
simplifies configuration saving, is
extensible and eases package updates.
The difference from the old lrpkg
package
management scripts is that, from now on the .lrp
packages become effectively read-only, while the changes to the various
configuration files are saved in a new package called
configdb.lrp
. As for the kernel modules (ie: the
files in /lib/modules
), they are now stored in
another new package called moddb.lrp
.
This approach improves not only the way packages are handled, by saving only the information that has changed, but also provides new options for preparing special base installations (such as a simple fileset for WRAP boards), while providing easy package upgrades.
apgk
has two modes of operation, just like
lrpkg
. The most used mode is interactive, it's the
one you see right after logging in. But it can also be used via the shell
prompt using switches.
The first time the router boots, there is no
configdb.lrp
(unless added by hand). You may see
some 'not found' errors, this is an expected behaviour and will
disapear once you save the config.
The "LEAF configuration menu
" is
the first screen you'll see after login. You can always start it from
the shell prompt with the lrcfg command.
This menu has some changes in the lower right corner, the available commands are now:
s) Save configuration
m) Backup modules
c) Show configuration changes since last save
d) Show configuration changes from defaults
s - will save all changed configuration files
and directories to configdb.lrp
.
m -backs up the modules directory
/lib/modules
to
moddb.lrp
.
The file /etc/modules
will be saved in
configdb.lrp
. If you only changed the entries in
this file, "Save config" is enough. But if you add a new module and
changed /etc/modules
you have to save both - the
configuration and the modules.
You can change the confirmation question before writing the lrp to your storage media in /etc/config.cfg. Setting CWRT to "off" allows you to save your completly configured box with only two keystrokes ("s" and "m" ).
There are two more commands available regarding configuration changes and saving:
c) Show configuration changes since last save
This command shows the changes in all your configuration files and directories since you saved your configuration.
d) Show configuration changes from defaults
This command shows all changes between your setup and the distribution defaults as shipped.
Both commands only work if you saved configurations at least once.
The new package and configuration management alleviate upgrading
packages. You can copy a new version of a package to your storage media
and with reboot the new version is loaded (from the <package>.lrp)
and your previous configuration, cause the configuration files in the
package are overwritten by those saved earlier in
configdb.lrp
.
You can also use the apkg -u upgrade command. When apkg -u is invoked, the user will be prompted for each changed configuration file - you can keep the old file, install the new file, view a diff or edit a merged version. If a configuration file has not changed between two releases (e.g. no new defaults, no new options etc), the file modified by the user will be kept without asking.
The new package has to be copied to the storage media before the upgrade to survive a reboot and for the same reason the config has to be saved after the upgrade.
Every package has a <package>.local
file
with files listed which shall be saved. At startup (linuxrc) the sha1sums
of everything listed in the <package>.local
file are calculated and saved in <package>.sha1
files. This part is done with a "find", so also directories can be listed
in <package>.local
files. Only use directories,
when this directory is unique for the package, otherwise the content is
processed multiple times which cost time and processing power. During
backup the sha1sums of the files in memory are compared with the saved
*.sha1 sums, new files are detected and duplicates are filtered
out.
For example: when one package has an etc/ppp directory in
<package>.local
and another one an
etc/ppp/dsl-providers
file listed, the
dsl-provider
file would be found twice and also
stored twice in the configdb
. Changed files are saved
in configdb.lrp
with a "full" backup, this is dynamic
so installing (or removing) a package will also be taken into
account.
The first device in the PKGPATH list is used as backup device. The
configdb
and moddb
will always
loaded last by linuxrc. This loading is automatic so there is no need to
specify configdb
and moddb
in
the packages list. Modules system, a very simple implementation: The
complete /lib/modules
directory is backuped to
moddb.lrp
and the /lib/modules/'kernel version' is
excluded. This also means that the modules.lrp
package now only contains the insmod logic and no modules.
apkg only saves configuration files, declared in <package>.local. It does never save the complete package. It is also not recommended to add binaries to the configdb file.
So, if you want to customize a package, like replacing a file in the LRP or adding new files to the LRP, it is suggested that you build a new package from scratch.
Building a LRP for a few small scripts, that are added on a running
system and are not part of any package can shurely be overkill. By adding
those files to the /var/lib/lrpkg/local.local file, they will be forced to
be saved in the config database. The format is simple, just list the full
path to the file without a leading slash:
etc/init.d/example.sh
Don't remove the first entry in this file.
"apkg" was rewritten by Eric Spakman as a replacement for lrpkg. His work was based on David Douthitt, Nathan Angelacos and Natanael Copa's efforts towards a more advanced package management tool. Cedric Schieli and Paul S. Traina added new features and helped to fix and cleanup Eric's work.