Вы находитесь на странице: 1из 4

2/21/13

apkg User Guide

Prev

apkg User Guide Part I. HOWTO

Next

apkg User Guide


K.-P. Kirchdoerfer
< k a p e k aa tu s e r s . s o u r c e f o r g e . n e t >

Eric Spakman
< e s p a k m a na tu s e r s . s o u r c e f o r g e . n e t >

Luis Correia
< l f c o r r e i aa tu s e r s . s o u r c e f o r g e . n e t >

Revision History Revision 1.0 Initial document Table of Contents About apkg November 2006

About apkg
What is apkg?
a p k gis 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 l r p k gscripts.

Why is apkg better then lrpkg?


a p k gsimplifies configuration saving,

is extensible and eases package updates.

The difference from the old l r p k gpackage management scripts is that, from now on the . l r ppackages become effectively read-only, while the changes to the various configuration files are saved in a new package called c o n f i g d b . l r p . As for the kernel modules (ie: the files in / l i b / m o d u l e s ), they are now stored in another new package called m o d d b . l r p . This approach improves not only the way packages are handled, by saving only the information that has changed,
leaf.sourceforge.net/doc/bk10pt01ar02.html 1/4

2/21/13

apkg User Guide

but also provides new options for preparing special base installations (such as a simple fileset for WRAP boards), while providing easy package upgrades.

Using apkg
a p g khas two

modes of operation, just like l r p k g . 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.

Note
The first time the router boots, there is no c o n f i g d b . l r p(unless added by hand). You may see some 'not found' errors, this is an expected behaviour and will disapear once you save the config.

Saving your configuration


Interactive mode The "L E A Fc o n f i g u r a t i o nm e n u " 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 c o n f i g d b . l r p . m -backs up the modules directory / l i b / m o d u l e sto m o d d b . l r p .

Note
The file / e t c / m o d u l e swill be saved in c o n f i g d b . l r p . If you only changed the entries in this file, "Save config" is enough. But if you add a new module and changed / e t c / m o d u l e syou 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
leaf.sourceforge.net/doc/bk10pt01ar02.html 2/4

2/21/13

apkg User Guide

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.

Note
Both commands only work if you saved configurations at least once. Command line switches apkg supports the following commands: -i [path]<package> install package -u [path]<package> upgrade package -c [path]<package> list contents of package -l [<package>] list installed packages; if <package> given, tell if it is installed -h this help

Upgrading packages
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 c o n f i g d b . l r p . 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.

Note
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.

More insights for developers and interested users


Every package has a < p a c k a g e > . l o c a lfile with files listed which shall be saved. At startup (linuxrc) the sha1sums of everything listed in the < p a c k a g e > . l o c a lfile are calculated and saved in < p a c k a g e > . s h a 1files. This part is done with a "find", so also directories can be listed in < p a c k a g e > . l o c a lfiles. Only use directories,
leaf.sourceforge.net/doc/bk10pt01ar02.html 3/4

2/21/13

apkg User Guide

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 < p a c k a g e > . l o c a land another one an e t c / p p p / d s l p r o v i d e r sfile listed, the d s l p r o v i d e rfile would be found twice and also stored twice in the c o n f i g d b . Changed files are saved in c o n f i g d b . l r pwith 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 c o n f i g d band m o d d bwill always loaded last by linuxrc. This loading is automatic so there is no need to specify c o n f i g d band m o d d bin the packages list. Modules system, a very simple implementation: The complete / l i b / m o d u l e sdirectory is backuped to m o d d b . l r pand the /lib/modules/'kernel version' is excluded. This also means that the m o d u l e s . l r ppackage now only contains the insmod logic and no modules.

Customizing packages
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:
e t c / i n i t . d / e x a m p l e . s h

Don't remove the first entry in this file.

Acknowledgments and Thanks


"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. Prev 6wall User Guide Up Home Next Customize logfile representation in webconf with filters

leaf.sourceforge.net/doc/bk10pt01ar02.html

4/4