Packaging/SUSE Package Conventions/SUSEConfig
From openSUSE
| 6. SuSEconfig (deprecated) | ||
|---|---|---|
Contents |
6. SuSEconfig (deprecated)
This section describes a SUSE-specific tool, SuSEconfig. It explains what the tool is for, how to create a new SuSEconfig module, and what environment variables and predefined functions are available in the modules.
Warning
SuSEconfig is deprecated. Solutions should be created without the need to run SuSEconfig after installation of a RPM package with the rpm tool.
6.1. Tool
SuSEconfig is a tool for updating the system configuration.
Synopsis:
SuSEconfig [-force] [-nomodule] [-nonewpackage] [-norestarts] [-quick] [-verbose] [-module module]
The configuration tool SuSEconfig is used to maintain configuration depending on many packages. In the past, it was also used to update native configuration files according to the variables set in [[SUSE_Package_Conventions/Sysconfig /etc/sysconfig], but this is no longer allowed. See below for a more detailed description.
The tool is based on shell scripts. It consists of a wrapper /sbin/SuSEconfig and modules installed in /sbin/conf.d. Furthermore, there is a file /lib/YaST/SuSEconfig.functions providing some functions used by multiple modules.
The only SuSEconfig task is actually to maintain configuration that must be updated if any of many related packages is changed (installed, updated, removed). For example, the X11 fonts configuration must be updated after any package providing fonts is changed. Such problems can be solved by RPM scripts, like triggers, %post, and %preun. The solution using SuSEconfig has the advantage that it is more independent from such packages. The disadvantage is that SuSEconfig is often started even if it is not needed (see below).
Other alternatives can manage the X11 font configuration. One solution would be to have a complex code in the %post and %postun scripts of each package providing X11 fonts. A better solution would be to put this code in an extra script that would be always installed and call this script from the %post and %postun scripts. The solution used at SUSE is similar to the second one, but the script is also called from SuSEconfig, module fonts. The advantage is that the user can install external (non-SUSE) packages providing X11 fonts or even install stand-alone fonts. Then it is enough to run SuSEconfig and the X11 font configuration is updated.
Another task of SuSEconfig was to spread information from /etc/sysconfig over the system into native config files of applications. A single SuSEconfig module was usually responsible for an application and its native config files. For example, the module apache updated the native Apache native configuration. This approach brought more negatives than positives, so [[SUSE_Package_Conventions/Sysconfig /etc/sysconfig] and SuSEconfig must not be used this way now.
The basic idea is to run the related SuSEconfig modules after a change. YaST uses this approach in some cases. Also an advanced user can start only selected modules with the option –module. Because it is usually difficult to decide which module should be processed, it is suggested to run SuSEconfig (all modules) after any change in /etc/sysconfig or after any package is changed. YaST does this automatically when need. The user must do this when doing such an action manually.
SuSEconfig must be run by the user root.
Options:
-force — unused.
-nomodule — runs only the wrapper without any module.
-nonewpackage — skips actions that are necessary only when a package is newly installed.
-norestarts — unused.
-quick — runs only the most important modules.
-verbose — is more verbose.
-module module — runs only a selected module. All modules are run by default.
6.2. Modules
A SuSEconfig module is a shell script installed as /sbin/conf.d/SuSEconfig.module_name. The file begins with the usual header:
#!/bin/sh
or
#!/bin/bash
Then the required config files are usually sourced from /etc/sysconfig. This example is taken from the module postfix:
test -s $r/etc/sysconfig/postfix || {
echo "No $r/etc/sysconfig/postfix found."
exit 1
}
. $r/etc/sysconfig/postfix
Furthermore, predefined functions are sourced if they are used. See [[SUSE_Package_Conventions/SUSEConfig#spc_suc_functions Section�6.4, “Functions”] for more details.
Finally, there is a code that updates the system configuration. There are no limitations but only suggestions on the code:
-
SuSEconfigshould not replace changes made by the user. The function check_md5_and_mode can be used for this purpose. See [[SUSE_Package_Conventions/SUSEConfig#spc_suc_fn_check_md5_and_move Section�6.4.1, “check_md5_and_move”] for more details. - The module should check if a time consuming action is really needed. For example, md5 sums or time stamps could be checked. The module can be started even if it is not really needed.
This example is taken from the module icu:
export ICU_DATA=/usr/share/icu/2.6.2 if test ! -f $ICU_DATA/cnvalias.dat -o \ /etc/icu/convrtrs.txt -nt $ICU_DATA/cnvalias.dat then echo "Compiling converters and aliases list from /etc/icu/convrtrs.txt" /usr/bin/gencnval /etc/icu/convrtrs.txt fi
- If an action is needed only after a new package is installed, it should be done only if
CHECK_NEWPACKAGE = “true”. This helps to speed upSuSEconfigtoo.
This example is taken from the module perl:
test "$CHECK_NEWPACKAGE" = false && exit 0
Obsolete features:
Some older SuSEconfig modules contain the following obsolete tests. They are included in the wrapper /sbin/SuSEconfig and need not be in modules anymore:
# check if we are started as root
# only one of UID and USER must be set correctly
#
if test "$UID" != 0 -a "$USER" != root; then
echo "You must be root to start $0."
exit 1
fi
# check if SuSEconfig is enabled
test -f $ROOT/etc/sysconfig/suseconfig || {
echo "No /etc/sysconfig/suseconfig found."
exit 1
}
. $ROOT/etc/sysconfig/suseconfig
if test -n "$ENABLE_SUSECONFIG" -a
"$ENABLE_SUSECONFIG" = "no" ; then
echo "SuSEconfig is disabled in $ROOT/etc/sysconfig/suseconfig. Exit..."
exit 0
fi
6.3. Variables
These variables are set by SuSEconfig command-line options and are exported in SuSEconfig modules.
-
DO_RESTARTS— unused. It is set to“false”by the option–norestarts. -
CHECK_NEWPACKAGE— used to skip actions needed only if a new package is installed. It is set to“false”by the option-nonewpackage. -
FASTRUN— used to skip actions that do not necessarily need to be done immediately. It is set to“true”by the options-quickand-module. -
FORCE_REPLACE— unused. It is set to“true”by the option-force. -
VERBOSE— used to print more messages on request. It is set to“true”by the option-verbose.
6.4. Functions
The following functions are used by several SuSEconfig modules. They are implemented in the file /lib/YaST/SuSEconfig.functions and can be sourced to the module the following way:
test -f /lib/YaST/SuSEconfig.functions || {
echo "ERROR - can not find /lib/YaST/SuSEconfig.functions!!"
echo "This should not happen. Exit..."
exit 1
}
. /lib/YaST/SuSEconfig.functions
6.4.1. check_md5_and_move
This function checks a file and replaces it with a new version if the original one has not been changed by the user.
Synopsis:
check_md5_and_move config_file
The function check_md5_and_move helps to keep changes made by the user. It does the following actions:
- It checks for
config_file.SuSEconfigwhich includes the suggested changes bySuSEconfig. The filename consists of the givenconfig_fileand the suffix.SuSEconfig. - It checks the md5 sum of the
config_file. The md5 sum is stored in/var/adm/SuSEconfig/md5/config_file. - It replaces the original
config_filewith the suggestedconfig_file.SuSEconfigif the md5 sum is the same or is missing. Then it updates the md5 ckecksum. Otherwise, it keeps the file as-is and prints the message:
ATTENTION: You have modified config_file. Leaving it untouched... You can find my version in config_file.SuSEconfig...
This example is taken from the module guile:
test -f /lib/YaST/SuSEconfig.functions || {
echo "ERROR - can not find /lib/YaST/SuSEconfig.functions!!"
echo "This should not happen. Exit..."
exit 1
}
. /lib/YaST/SuSEconfig.functions
[...]
mv /usr/share/guile/1.6/slibcat \
/usr/share/guile/1.6/slibcat.old_version
guile -c "(use-modules (ice-9 slib)) (require 'new-catalog)"
mv /usr/share/guile/1.6/slibcat \
/usr/share/guile/1.6/slibcat.SuSEconfig
mv /usr/share/guile/1.6/slibcat.old_version \
/usr/share/guile/1.6/slibcat
check_md5_and_move /usr/share/guile/1.6/slibcat
This code sources the predefined functions. Then it prepares a new version of /usr/share/guile/1.6/slibcat as /usr/share/guile/1.6/slibcat.SuSEconfig. Finally, it calls the function check_md5_and_move, which replaces the original /usr/share/guile/1.6/slibcat only if it has not been changed by the user.
6.4.2. my_test_write
This function provides a simple test of whether a directory is writable.
Synopsis:
my_test_write dir
The function my_test_write checks if the directory dir is writable. It returns “0” on success.
6.4.3. my_test_for_space
This function provides a simple test of whether there is enough free space in a directory.
Synopsis:
my_test_for_space dir
The function my_test_for_space tries to create a 50kB test file in the directory dir. It returns “0” on success.
| 5. Sysconfig | 7. Init Scripts |

