Пакет rpm может иметь в своей структуре скрипты, которые выполняются перед установкой, после установки, перед удалением, после удаления. Причем могут встречатся случаи, когда присутствует какой-либо один вид сценариев, несколько видов или все.
Опция --scripts позволяет вывести скрипты, ассоциированные с заданным пакетом. Базовый синтаксис:
| 
 rpm -q --scripts package_name     
 | 
Например:
| 
 # rpm -q --scripts tcsh 
  
postinstall scriptlet (through /bin/sh): 
  
if [ ! -f /etc/shells ]; then 
  
echo "/bin/tcsh" >> /etc/shells 
  
echo "/bin/csh" >> /etc/shells 
  
else 
  
grep '^/bin/tcsh$' /etc/shells > /dev/null || echo "/bin/tcsh" >> /etc/shells 
  
grep '^/bin/csh$' /etc/shells > /dev/null || echo "/bin/csh" >> /etc/shells 
  
fi 
  
postuninstall scriptlet (through /bin/sh): 
  
if [ ! -x /bin/tcsh ]; then 
  
grep -v '^/bin/tcsh$' /etc/shells | grep -v '^/bin/csh$'> /etc/shells.rpm 
  
mv /etc/shells.rpm /etc/shells 
  
fi 
  
PRODUCTION: NOTE THE fi on a line by itself at the end of this listing. Thanks, -Eric     
 | 
Некоторые пакеты могут иметь весьма сложные скрипты, как показано ниже:
| 
 # rpm -q --scripts sendmail 
  
preinstall scriptlet (through /bin/sh): 
  
/usr/sbin/useradd -u 47 -d /var/spool/mqueue -r -s /dev/null mailnull >/dev/null 
2>&1 || : 
  
postinstall scriptlet (through /bin/sh): 
  
# 
  
# Convert old format to new 
  
# 
  
if [ -f /etc/mail/deny ] ; then 
  
cat /etc/mail/deny | \ 
  
awk 'BEGIN{ print "# Entries from obsoleted /etc/mail/deny"} \ 
{print $1" REJECT"}' >> /etc/mail/access 
  
cp /etc/mail/deny /etc/mail/deny.rpmorig 
  
fi 
  
for oldfile in relay_allow ip_allow name_allow ; do 
  
if [ -f /etc/mail/$oldfile ] ; then 
  
cat /etc/mail/$oldfile | \ 
  
awk "BEGIN { print \"# Entries from obsoleted /etc/mail/$oldfile 
\" ;} \ 
  
{ print \$1\" RELAY\" }" >> /etc/mail/access 
  
cp /etc/mail/$oldfile /etc/mail/$oldfile.rpmorig 
  
fi 
  
done 
  
# 
  
# Oops, these files moved 
  
# 
  
if [ -f /etc/sendmail.cw ] ; then 
  
cat /etc/sendmail.cw | \ 
  
awk 'BEGIN { print "# Entries from obsoleted /etc/sendmail.cw" ;} \ 
{ print $1 }' >> /etc/mail/local-host-names 
  
cp /etc/sendmail.cw /etc/sendmail.cw.rpmorig 
  
fi 
  
# 
  
# Rebuild maps (next reboot will rebuild also) 
  
# 
  
{ /usr/bin/newaliases 
  
for map in virtusertable access domaintable mailertable 
  
do 
  
if [ -f /etc/mail/${map} ] ; then 
  
/usr/bin/makemap hash /etc/mail/${map} < /etc/mail/${map} 
  
sleep 1 
  
fi 
  
done 
  
} > /dev/null 2>&1 
  
/sbin/chkconfig --add sendmail 
  
preuninstall scriptlet (through /bin/sh): 
  
if [ $1 = 0 ]; then 
  
/etc/rc.d/init.d/sendmail stop >/dev/null 2>&1 
  
/sbin/chkconfig --del sendmail 
  
fi 
  
postuninstall scriptlet (through /bin/sh): 
  
if [ "$1" -ge "1" ]; then 
  
/etc/rc.d/init.d/sendmail condrestart >/dev/null 2>&1 
  
fi 
  
exit 0     
 | 
В этом примере основной скрипт - постинсталляционный. Он конвертирует старый формат данных в новый, если это возможно, что помогает пользователю легко перейти на новый релиз ПО.
 Далее - Список изменений 
 Назад - Список статуса файлов пакета 
 Содержание