TUT:mib2c update - fenner/net-snmp-wiki-experiment GitHub Wiki
About mib2c-update
mib2c generates template code which you must customize. So what happens when the configuration file you chose is updated to fix a bug or add a new feature? Traditionally, you have had to manually merge the changes into your code, or merge your customizations into a freshly generated code set. (see pseudo-algorithm for the manual steps needed).
The shell script mib2c-update is a wrapper around mib2c and other utilities to help you take advantage of updates to the configuration file you chose for your mib module without having to manually merge code changes.
If all goes well, there might not be any conflicts. If you changed any configuration option, or there were lots of changes to the configuration files, you may have to do quite a bit of manual patching.
Basic Configuration
mib2c-update does not take any command-line parameters. All configuration information is kept in the file .mib2c-updaterc in the directory where the code is generated. This configuration file needs to contain two pieces of information: the table name, and the mib2c configuration file to use. The format is:
#
# example mib2c-update configuration file
#
# UPDATE_OID should contain the table for which code will be generated
#
UPDATE_OID=ipAddressTable
#
# UPDATE_CONF should contain the mib2c configuration file to be used
#
UPDATE_CONF=mib2c.mfd.conf
Those are the only required options. If you want to pass additional arguments to mib2c, you can set the options in UPDATE_MIB2C_OPTS:
UPDATE_MIB2C_OPTS="-q -f ipAddress"
You can also configure the directories that mib2c-update will use to generate temporary code. The available options, and their defaults, are:
UPDATE_CURR=. Determines where the current code is. The default is the current working directory.
UPDATE_ORIG=.orig Determines where the original template code is. In this case, originial means the template used for the code in current.
UPDATE_NEW=.new Determines where the new template code should be generated.
UPDATE_PATCH=.patch Determines where the template and custom code patches should be generated.
UPDATE_MERGED=.merged Determines where the merging of the new code with the patches should occur.
UPDATE_BACKUP=.backup Determines where the current and original code will be backed up.
Running mib2c-update
Note: if you are trying to use mib2c-update after the fact (i.e. you originally generated you code with mib2c directly) skip ahead to using mib2c-update retroactively.
The first run of mib2c-update is very easy. Simply create your configuration file, .mib2c-updaterc, as described above, and then run mib2c-update. The temporary directories will be created, and mib2c will be run to generate the initial code.
... XXX: EXAMPLE RUN HERE ...
Once you have generated the code, it is strongly recommended that it be checked in to a source code version control system, such as CVS, Subversion, RCS, ClearCase or (shudder) Microsoft SourceSafe. This will help you recover if a bug in mib2-update causes any problems. Both the current and original directories should be put under version control.
Manual updates
If you want to manage the process manually, it goes something like this:
- In a new directory (eg orig), generate the code for your table using the same mib2c configuration file and options that were originally used to generate the code.
- use diff to compare the unmodified template code to your existing code, and save the output to create a patch of your changes.
- in a new directory (eg new), generate the code for your table using the updated mib2c configuration files, but with the same options that were originally used to generate the code.
- use diff to compare the original template code to the updated template code, and save the output to create a patch of the configuration file changes.
- copy the new code to a new directory (eg merge), and apply the configuration file patch.
- apply your custome changes patch to the merge directory
- resolve any conflicts or failed patches.