File SuSEconfig.prelink of Package prelink

#! /bin/sh
# Copyright (c) 2006 SUSE Linux Products GmbH, Nuernberg, Germany.
# All rights reserved.
#
# Author: Adrian Schroeter <adrian@suse.de>
#
# This module runs prelink.

# 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

r=$ROOT

for i in $r/etc/sysconfig/suseconfig $r/etc/sysconfig/prelink ; do
  if test ! -f $i ; then
    echo "No $i found."
    exit 1
  fi

  . $i
done

for i in /usr/bin/chroot $r/usr/sbin/prelink ; do
  if test ! -x $i ; then
    echo "No $i found."
    exit 1
  fi
done

if test -x /usr/bin/on_ac_power && ! /usr/bin/on_ac_power -q; then
	echo "skip prelink while running on battery"
        exit 0
fi

RPM_DATABASE=$r/var/lib/rpm/Packages
if test ! -e $RPM_DATABASE; then
  RPM_DATABASE=$r/var/lib/rpm/packages.rpm
fi

if test "$ENABLE_SUSECONFIG" = "yes" -a "$USE_PRELINK" = "yes" ; then
   if test "$r/var/lib/prelink/prelink_run" -ot $RPM_DATABASE; then
      echo -n running prelink, can take a long time ...
      if test -n "$r" -a "$r" != "/" ; then
         /usr/bin/chroot "$r" /usr/sbin/prelink -a $PRELINK_OPTS
      else
         /usr/sbin/prelink -a $PRELINK_OPTS
      fi
      touch "$r/var/lib/prelink/prelink_run"
      echo
   else
      echo skip prelink, rpm database has not changed since last run
   fi
fi

if test "$ENABLE_SUSECONFIG" = "yes" -a "$USE_PRELINK" = "no" ; then
   if test -e "$r/var/lib/prelink/prelink_run" ; then
      echo -n undoing prelinking ...
      if test -n "$r" -a "$r" != "/" ; then
         /usr/bin/chroot "$r" /usr/sbin/prelink -ua
      else
         /usr/sbin/prelink -ua
      fi
      rm "$r/var/lib/prelink/prelink_run"
      echo
   fi
fi

openSUSE Build Service is sponsored by