Ant task to generate rpm has a couple limitations. Ideally, we want to prevent the use of Makefile in our RPM build to prevent unnecessary nested build procedures. However, this means we can't create symlink in %install for RPM build. In addition, Chukwa RPM is design to install in user defined directory. If version 1 of the RPM build is installed in /usr/local/chukwa-1 and version 2 is installed in /usr/local/chukwa-2. It is difficult to keep track weather the symlink should be removed during the upgrade. Hence, the only option is to manage the symlink removal via a fixed file which will always exist between different version of the rpm.
/etc/init.d/chukwa-collector is a fixed file which always exist across chukwa version. The script is changed to detect existence of this file to determine if the RPM is executed as an uninstall or upgrade. Symlink removal logic will base on the detection and remove at the right time.