%install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/usr/sbin mkdir -p $RPM_BUILD_ROOT/etc/logcheck mkdir -p $RPM_BUILD_ROOT/etc/cron.hourly install ,/systems/linux/logcheck.hacking $RPM_BUILD_ROOT/etc/logcheck install ,/systems/linux/logcheck.violations $RPM_BUILD_ROOT/etc/logcheck install ,/systems/linux/logcheck.violations.ignore $RPM_BUILD_ROOT/etc/logcheck install ,/systems/linux/logcheck.ignore $RPM_BUILD_ROOT/etc/logcheck install ,/systems/linux/logcheck.sh $RPM_BUILD_ROOT/usr/sbin install ,/src/logtail $RPM_BUILD_ROOT/usr/sbin cat <<EOF > $RPM_BUILD_ROOT/etc/cron.hourly/logcheck
#!/bin/sh exec /usr/sbin/logcheck.sh EOF
The %install macro is the most involved section because you have to use it to prepare the RPM_BUILD_ROOT for RPM packaging. The following steps are required.
1. Make sure you start a fresh RPM build in case a previous build took place and was not complete successfully. This is done with the rm - rf $RPM_BUILD_ROOT directive.
2. Create the target directories for the installed files. In this example, the logcheck binaries are located in / usr/sbin and the configuration files are located in/etc/logcheck.
mjjSSÏW The RPM_BUILD_ROOT is an effective root. This means that it is a representation of where - ..-r ■ files would be located after the RPM has been installed in the root (/) directory.
3. The install program is effectively the same as cp. It copies a file from one location to another. It copies files to the location they would be in an installed system, under RPM_BUILD_ROOT.
4. The cat entry is a nice way of creating a file out of text using redirection. The redirection will enter the text following the cat program until an EOF (end of file) is found. This will create an entry in / etc/cron.hourly for logcheck to run once an hour.
Was this article helpful?