From 0557868f58d1391c867d57aa1c0da6fad4562e4b Mon Sep 17 00:00:00 2001 From: Dennis Groenen Date: Tue, 16 Oct 2012 19:05:29 +0200 Subject: [PATCH] move (un)installation script content to postinst/prerm --- debian/busybox-power.postinst | 144 ++++++++++++++++++++++++- debian/busybox-power.prerm | 210 +++++++++++++++++++++++++++++++++--- debian/rules | 2 - debian/scripts/install-binary.sh | 143 ------------------------ debian/scripts/uninstall-binary.sh | 191 -------------------------------- 5 files changed, 339 insertions(+), 351 deletions(-) delete mode 100755 debian/scripts/install-binary.sh delete mode 100755 debian/scripts/uninstall-binary.sh diff --git a/debian/busybox-power.postinst b/debian/busybox-power.postinst index b90ab79..74a2edb 100644 --- a/debian/busybox-power.postinst +++ b/debian/busybox-power.postinst @@ -1,5 +1,143 @@ -#!/bin/sh -set -e +#!/opt/busybox-power/busybox.power sh +# A script to replace /bin/busybox and create missing symlinks to its applets. +# +# The target directories for BusyBox' applets are defined in the "applets" file. +# This script will only create symbolic links when 1) they do not already exist +# in the filesystem, and 2) the BusyBox binary supports the applet. A list of +# all made symbolic links is written out to the file "busybox-power.symlinks", +# which will be used during uninstallation of busybox-power. +# +# NB The BusyBox binary needs to support the install applet. +# +# By Dennis Groenen +# GPLv3 licensed +# -/opt/busybox-power/busybox.power sh /opt/busybox-power/install-binary.sh +INSTALLDIR="/opt/busybox-power" +EXECPWR="$INSTALLDIR/busybox.power" +DISTBIN="/bin/busybox.distrib" + +VERBOSE="0" + +INSTBINARY_SHA1=`$EXECPWR sha1sum $EXECPWR | $EXECPWR awk '{ print $1 }'` +ORIGBINARY_SHA1=`$EXECPWR sha1sum /bin/busybox | $EXECPWR awk '{ print $1 }'` + +# Load shared functions +source $INSTALLDIR/functions + +# Check whether the applets file exists +CHECK_APPLETSFILE() { + if test ! -e $INSTALLDIR/applets; then + echo "error: cannot find list of defined applets" + exit 1 + fi +} + +# Check whether symlinks have been made before +CHECK_SYMLINKSFILE() { + if test -e $INSTALLDIR/busybox-power.symlinks; then + echo "error: symlinks already seem to be made?" + echo " this script is not supposed to be ran twice" + exit 1 + fi +} + +# Backup the original BusyBox binary +BACKUP() { + if test ! -e /bin/busybox; then + # Scratchbox does not ship with BusyBox by default + return + fi + + if test "$INSTBINARY_SHA1" != "$ORIGBINARY_SHA1"; then + $EXECPWR cp -a /bin/busybox $DISTBIN + $EXECPWR sha1sum $DISTBIN | $EXECPWR awk '{ print $1 }' \ + > $INSTALLDIR/busybox.distrib.sha1 + GETBBVERSION > $INSTALLDIR/busybox.distrib.version + fi +} + +# Overwrite the installed binary with the enhanced binary +INSTALL() { + /usr/sbin/dpkg-divert --local --divert $DISTBIN /bin/busybox + $EXECPWR cp -f $EXECPWR /bin/busybox +} + +# Create missing symlinks to the enhanced binary +SYMLINK() { + # Load defined BusyBox applets + source $INSTALLDIR/applets + + # Get a list of supported applets by busybox-power + if test -d /tmp/busybox-power; then + $EXECPWR rm -Rf /tmp/busybox-power; fi + $EXECPWR mkdir -p /tmp/busybox-power + $EXECPWR --install -s /tmp/busybox-power + $EXECPWR ls /tmp/busybox-power/ > $INSTALLDIR/applets_supported + $EXECPWR rm -Rf /tmp/busybox-power + + # Prepare file that will keep track of installed symlinks by busybox-power + echo "# Automatically generated by busybox-power. DO NOT EDIT" > $INSTALLDIR/busybox-power.symlinks + echo -e "\nDESTINATIONS=\"$DESTINATIONS\"" >> $INSTALLDIR/busybox-power.symlinks + echo -e "\n# Installed symlinks" >> $INSTALLDIR/busybox-power.symlinks + + # Walk through all possible destinations + for DESTDIR in $DESTINATIONS; do + # Enable us to see all entries in $DESTINATION as variables + eval "APPLICATIONS=\$$DESTDIR" + + # Set destination directory accordingly + case $DESTDIR in + DEST_BIN) + DIR="/bin" + ;; + DEST_SBIN) + DIR="/sbin" + ;; + DEST_USRBIN) + DIR="/usr/bin" + ;; + DEST_USRSBIN) + DIR="/usr/sbin" + ;; + esac + + # Keep track of installed symlinks per destination + SYMLINKS="$DESTDIR=\"" + + ECHO_VERBOSE "\nSymlinking applets in $DIR" + # Walk through all applications from the current destination + for APP in $APPLICATIONS; do + # The following code is executed for all applets in the current destination + if test ! -e $DIR/$APP; then + # Check whether the applet is supported by the busybox binary + if `$EXECPWR grep -Fq "$APP" $INSTALLDIR/applets_supported`; then + ECHO_VERBOSE "Symlinking: /bin/busybox -> $DIR/$APP" + $EXECPWR ln -s /bin/busybox $DIR/$APP + SYMLINKS="$SYMLINKS $APP" + fi + fi + done + + # Write out installed symlinks + echo "$SYMLINKS\"" >> $INSTALLDIR/busybox-power.symlinks + done + + $EXECPWR rm $INSTALLDIR/applets_supported +} + +### Codepath ### +ECHO_VERBOSE "busybox-power: verbose mode" +ECHO_VERBOSE " binary: $EXECPWR" +ECHO_VERBOSE " version string: `$EXECPWR | $EXECPWR head -n 1`" +CHECK_ENV && ECHO_VERBOSE " environment: $ENVIRONMENT" + +CHECK_STANDALONE +CHECK_APPLETSFILE +CHECK_SYMLINKSFILE +if test "$ENVIRONMENT" != "SDK"; then + CHECK_ROOT; fi +BACKUP +INSTALL +SYMLINK diff --git a/debian/busybox-power.prerm b/debian/busybox-power.prerm index 9d2978d..dafdf88 100644 --- a/debian/busybox-power.prerm +++ b/debian/busybox-power.prerm @@ -1,15 +1,201 @@ #!/bin/sh -set -e - -sh /opt/busybox-power/uninstall-binary.sh - -# Clean up trap (from busybox-power <= 1.20.2power1) -# Should be removed by the old prerm, but may be left behind when that one fails -# and dpkg uses this one instead. Therefore, keep this cleanup included for a -# few busybox-power releases. -line="trap exit SIGHUP #by busybox-power" -if grep -F -q "$line" /etc/profile; then - sed "/$line/d" /etc/profile > /tmp/profile.sed - mv /tmp/profile.sed /etc/profile +# A script to restore /bin/busybox and delete the symlinks made during +# installation. +# +# Symbolic links to applets are only removed if they are +# 1) created by the installer script ("install-binary.sh") +# 2) not replaced by a binary (i.e. they are still a symbolic link) +# 3) pointing to a busybox binary +# +# By Dennis Groenen +# GPLv3 licensed +# + +INSTALLDIR="/opt/busybox-power" +EXECPWR="$INSTALLDIR/busybox.power" +DISTBIN="/bin/busybox.distrib" + +VERBOSE="0" +MODIFIEDBIN="0" + +INSTBINARY_SHA1=`sha1sum $EXECPWR | awk '{ print $1 }'` +if test -e $DISTBIN; then + ORIGBINARY_SHA1=`sha1sum $DISTBIN | awk '{ print $1 }'`; fi + +# Load shared functions +source $INSTALLDIR/functions + +# Check whether we can load the list of created symlinks during installation +CHECK_SYMLINKSFILE() { + if test ! -e $INSTALLDIR/busybox-power.symlinks; then + echo -e "Warning: cannot find the list of symlinks to be removed. No" \ + "symlinks will be removed at all!\n" >> /tmp/busybox-power-error + fi +} + +# Check the (integrity) of our BusyBox backup +CHECK_BACKUP() { + # Firstly, check whether the backup still exists + if test ! -e $DISTBIN; then + if test "$ENVIRONMENT" == "SDK"; then return; fi # SDK comes without BB + echo -e "Warning: the backup of the original BusyBox binary is missing!" \ + "/bin/busybox will not be touched.\n" >> /tmp/busybox-power-error + return + fi + + # Secondly, check the integrity of the backup + if test -e $INSTALLDIR/busybox.distrib.sha1; then + if test "`cat $INSTALLDIR/busybox.distrib.sha1`" != "$ORIGBINARY_SHA1"; then + if test "`cat $INSTALLDIR/busybox.distrib.version`" == "`GETBBVERSION`"; then + # The backup has been changed whilst busybox hasn't been upgraded + echo -e "Warning: the backup of the original BusyBox binary has" \ + "been modified since installing busybox-power (invalid SHA1" \ + "checksum). Do not continue unless you're sure that $DISTBIN" \ + "is not corrupted.\n" >> /tmp/busybox-power-error + fi + fi + else + echo -e "Warning: could not load the saved SHA1 checksum of the backup" \ + "of the original BusyBox binary; the integrity of the backup of the" \ + "original binary can not be guaranteed.\n" >> /tmp/busybox-power-error + fi +} + +# Check whether /bin/busybox has been modified after bb-power's installation +CHECK_INSTALLEDBIN() { + if test "$INSTBINARY_SHA1" != "`sha1sum /bin/busybox | awk '{ print $1 }'`"; then + echo -e "Warning: /bin/busybox has been modified since installing" \ + "busybox-power (invalid SHA1 checksum). Your current /bin/busybox" \ + "won't be touched and the diversion of /bin/busybox to $DISTBIN will" \ + "not be removed. \n" >> /tmp/busybox-power-error + MODIFIEDBIN="1" + fi +} + +# Display encountered errors +DISPLAY_ERRORS() { + case $ENVIRONMENT in + SDK) + echo -e "\n\n-----------Attention!-----------" + cat /tmp/busybox-power-error + rm /tmp/busybox-power-error + echo "-> Please press [enter] to ignore the above errors/warnings." + echo " Hit [ctrl-c] to break" + read + ;; + FREMANTLE) + echo "Click \"I Agree\" to ignore the above errors/warnings. Ask for" \ + "help if you don't know what to do." >> /tmp/busybox-power-error + echo "Please confirm the text on the screen of your device" + maemo-confirm-text "Attention!" /tmp/busybox-power-error + res=$? + rm /tmp/busybox-power-error + if test ! $res == 0; then exit 1; fi + ;; + esac +} + +# Uninstallation of the enhanced binary +UNINSTALL() { + if test $MODIFIEDBIN == 1; then + # /bin/busybox has been modified since installing busybox-power + # Leave both the file and the diversion in place + return + elif test -e $DISTBIN; then + cp -af $DISTBIN /bin/busybox + if test -e /bin/busybox; then + rm $DISTBIN; fi + elif test "$ENVIRONMENT" == "SDK"; then + # There was no /bin/busybox to begin with.. + rm /bin/busybox + fi + + /usr/sbin/dpkg-divert --remove /bin/busybox +} + +# Remove all symlinks that the installation script has made +UNSYMLINK() { + # Load list of installed symlinks + touch $INSTALLDIR/busybox-power.symlinks + source $INSTALLDIR/busybox-power.symlinks + + # Walk through all possible destinations + for DESTDIR in $DESTINATIONS; do + # Enable us to see all entries in $DESTINATIONS as variables + eval "APPLICATIONS=\$$DESTDIR" + # Set destination directory accordingly + case $DESTDIR in + DEST_BIN) + DIR="/bin" + ;; + DEST_SBIN) + DIR="/sbin" + ;; + DEST_USRBIN) + DIR="/usr/bin" + ;; + DEST_USRSBIN) + DIR="/usr/sbin" + ;; + esac + + ECHO_VERBOSE "\nRemoving symlinks in $DIR" + # Walk through all applications from the current destination + for APP in $APPLICATIONS; do + # The following code is executed for every application in the current + # destination + if test -h $DIR/$APP; then + # Good, this app is still a symbolic link .. + if test -n "`ls -l $DIR/$APP | grep busybox`"; then + ECHO_VERBOSE "Removing link: $DIR/$APP" + rm $DIR/$APP + fi + fi + done + done +} + +# Action to be performed after restoring original busybox +CLEANUP() { + OLDFILES="busybox-power.symlinks + busybox.distrib.version + busybox.distrib.sha1" + + for file in $OLDFILES; do + if test -e $INSTALLDIR/$file; then + rm $INSTALLDIR/$file + fi + done + + # Clean up trap (from busybox-power <= 1.20.2power1) + # Should be removed by the old prerm, but may be left behind when that one + # fails and dpkg uses this one instead. Therefore, keep this cleanup + # included for a few busybox-power releases. + line="trap exit SIGHUP #by busybox-power" + if grep -F -q "$line" /etc/profile; then + sed "/$line/d" /etc/profile > /tmp/profile.sed + mv /tmp/profile.sed /etc/profile + fi +} + +### Codepath ### +ECHO_VERBOSE "busybox-power: verbose mode" +ECHO_VERBOSE " binary: $EXECPWR" +ECHO_VERBOSE " version string: `$EXECPWR | $EXECPWR head -n 1`" +CHECK_ENV && ECHO_VERBOSE " environment: $ENVIRONMENT" + +CHECK_STANDALONE +CHECK_SYMLINKSFILE +if test "$ENVIRONMENT" != "SDK"; then + CHECK_ROOT + CHECK_BACKUP + CHECK_INSTALLEDBIN +fi +if test -e /tmp/busybox-power-error; then + # An error has occured during the checks + DISPLAY_ERRORS fi +UNSYMLINK +UNINSTALL +CLEANUP diff --git a/debian/rules b/debian/rules index 0fffe9e..be3eeb2 100755 --- a/debian/rules +++ b/debian/rules @@ -83,8 +83,6 @@ binary-arch_busybox: $(STAMPS_DIR)/build_busybox dh_testroot dh_clean -k -d install -D -m644 debian/scripts/applets debian/busybox-power/opt/busybox-power/applets - install -D -m755 debian/scripts/install-binary.sh debian/busybox-power/opt/busybox-power/install-binary.sh - install -D -m755 debian/scripts/uninstall-binary.sh debian/busybox-power/opt/busybox-power/uninstall-binary.sh install -D -m644 debian/scripts/functions debian/busybox-power/opt/busybox-power/functions install -D -m755 $(DIR)/busybox_unstripped debian/busybox-power/opt/busybox-power/busybox.power diff --git a/debian/scripts/install-binary.sh b/debian/scripts/install-binary.sh deleted file mode 100755 index 5271163..0000000 --- a/debian/scripts/install-binary.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/sh -# A script to replace /bin/busybox and create missing symlinks to its applets. -# -# The target directories for BusyBox' applets are defined in the "applets" file. -# This script will only create symbolic links when 1) they do not already exist -# in the filesystem, and 2) the BusyBox binary supports the applet. A list of -# all made symbolic links is written out to the file "busybox-power.symlinks", -# which will be used during uninstallation of busybox-power. -# -# NB The BusyBox binary needs to support the install applet. -# -# By Dennis Groenen -# GPLv3 licensed -# - -INSTALLDIR="/opt/busybox-power" -EXECPWR="$INSTALLDIR/busybox.power" -DISTBIN="/bin/busybox.distrib" - -VERBOSE="0" - -INSTBINARY_SHA1=`$EXECPWR sha1sum $EXECPWR | $EXECPWR awk '{ print $1 }'` -ORIGBINARY_SHA1=`$EXECPWR sha1sum /bin/busybox | $EXECPWR awk '{ print $1 }'` - -# Load shared functions -source $INSTALLDIR/functions - -# Check whether the applets file exists -CHECK_APPLETSFILE() { - if test ! -e $INSTALLDIR/applets; then - echo "error: cannot find list of defined applets" - exit 1 - fi -} - -# Check whether symlinks have been made before -CHECK_SYMLINKSFILE() { - if test -e $INSTALLDIR/busybox-power.symlinks; then - echo "error: symlinks already seem to be made?" - echo " this script is not supposed to be ran twice" - exit 1 - fi -} - -# Backup the original BusyBox binary -BACKUP() { - if test ! -e /bin/busybox; then - # Scratchbox does not ship with BusyBox by default - return - fi - - if test "$INSTBINARY_SHA1" != "$ORIGBINARY_SHA1"; then - $EXECPWR cp -a /bin/busybox $DISTBIN - $EXECPWR sha1sum $DISTBIN | $EXECPWR awk '{ print $1 }' \ - > $INSTALLDIR/busybox.distrib.sha1 - GETBBVERSION > $INSTALLDIR/busybox.distrib.version - fi -} - -# Overwrite the installed binary with the enhanced binary -INSTALL() { - /usr/sbin/dpkg-divert --local --divert $DISTBIN /bin/busybox - $EXECPWR cp -f $EXECPWR /bin/busybox -} - -# Create missing symlinks to the enhanced binary -SYMLINK() { - # Load defined BusyBox applets - source $INSTALLDIR/applets - - # Get a list of supported applets by busybox-power - if test -d /tmp/busybox-power; then - $EXECPWR rm -Rf /tmp/busybox-power; fi - $EXECPWR mkdir -p /tmp/busybox-power - $EXECPWR --install -s /tmp/busybox-power - $EXECPWR ls /tmp/busybox-power/ > $INSTALLDIR/applets_supported - $EXECPWR rm -Rf /tmp/busybox-power - - # Prepare file that will keep track of installed symlinks by busybox-power - echo "# Automatically generated by busybox-power. DO NOT EDIT" > $INSTALLDIR/busybox-power.symlinks - echo -e "\nDESTINATIONS=\"$DESTINATIONS\"" >> $INSTALLDIR/busybox-power.symlinks - echo -e "\n# Installed symlinks" >> $INSTALLDIR/busybox-power.symlinks - - # Walk through all possible destinations - for DESTDIR in $DESTINATIONS; do - # Enable us to see all entries in $DESTINATION as variables - eval "APPLICATIONS=\$$DESTDIR" - - # Set destination directory accordingly - case $DESTDIR in - DEST_BIN) - DIR="/bin" - ;; - DEST_SBIN) - DIR="/sbin" - ;; - DEST_USRBIN) - DIR="/usr/bin" - ;; - DEST_USRSBIN) - DIR="/usr/sbin" - ;; - esac - - # Keep track of installed symlinks per destination - SYMLINKS="$DESTDIR=\"" - - ECHO_VERBOSE "\nSymlinking applets in $DIR" - # Walk through all applications from the current destination - for APP in $APPLICATIONS; do - # The following code is executed for all applets in the current destination - if test ! -e $DIR/$APP; then - # Check whether the applet is supported by the busybox binary - if `$EXECPWR grep -Fq "$APP" $INSTALLDIR/applets_supported`; then - ECHO_VERBOSE "Symlinking: /bin/busybox -> $DIR/$APP" - $EXECPWR ln -s /bin/busybox $DIR/$APP - SYMLINKS="$SYMLINKS $APP" - fi - fi - done - - # Write out installed symlinks - echo "$SYMLINKS\"" >> $INSTALLDIR/busybox-power.symlinks - done - - $EXECPWR rm $INSTALLDIR/applets_supported -} - -### Codepath ### -ECHO_VERBOSE "busybox-power: verbose mode" -ECHO_VERBOSE " binary: $EXECPWR" -ECHO_VERBOSE " version string: `$EXECPWR | $EXECPWR head -n 1`" -CHECK_ENV && ECHO_VERBOSE " environment: $ENVIRONMENT" - -CHECK_STANDALONE -CHECK_APPLETSFILE -CHECK_SYMLINKSFILE -if test "$ENVIRONMENT" != "SDK"; then - CHECK_ROOT; fi -BACKUP -INSTALL -SYMLINK - diff --git a/debian/scripts/uninstall-binary.sh b/debian/scripts/uninstall-binary.sh deleted file mode 100755 index 9a08957..0000000 --- a/debian/scripts/uninstall-binary.sh +++ /dev/null @@ -1,191 +0,0 @@ -#!/bin/sh -# A script to restore /bin/busybox and delete the symlinks made during -# installation. -# -# Symbolic links to applets are only removed if they are -# 1) created by the installer script ("install-binary.sh") -# 2) not replaced by a binary (i.e. they are still a symbolic link) -# 3) pointing to a busybox binary -# -# By Dennis Groenen -# GPLv3 licensed -# - -INSTALLDIR="/opt/busybox-power" -EXECPWR="$INSTALLDIR/busybox.power" -DISTBIN="/bin/busybox.distrib" - -VERBOSE="0" -MODIFIEDBIN="0" - -INSTBINARY_SHA1=`sha1sum $EXECPWR | awk '{ print $1 }'` -if test -e $DISTBIN; then - ORIGBINARY_SHA1=`sha1sum $DISTBIN | awk '{ print $1 }'`; fi - -# Load shared functions -source $INSTALLDIR/functions - -# Check whether we can load the list of created symlinks during installation -CHECK_SYMLINKSFILE() { - if test ! -e $INSTALLDIR/busybox-power.symlinks; then - echo -e "Warning: cannot find the list of symlinks to be removed. No" \ - "symlinks will be removed at all!\n" >> /tmp/busybox-power-error - fi -} - -# Check the (integrity) of our BusyBox backup -CHECK_BACKUP() { - # Firstly, check whether the backup still exists - if test ! -e $DISTBIN; then - if test "$ENVIRONMENT" == "SDK"; then return; fi # SDK comes without BB - echo -e "Warning: the backup of the original BusyBox binary is missing!" \ - "/bin/busybox will not be touched.\n" >> /tmp/busybox-power-error - return - fi - - # Secondly, check the integrity of the backup - if test -e $INSTALLDIR/busybox.distrib.sha1; then - if test "`cat $INSTALLDIR/busybox.distrib.sha1`" != "$ORIGBINARY_SHA1"; then - if test "`cat $INSTALLDIR/busybox.distrib.version`" == "`GETBBVERSION`"; then - # The backup has been changed whilst busybox hasn't been upgraded - echo -e "Warning: the backup of the original BusyBox binary has" \ - "been modified since installing busybox-power (invalid SHA1" \ - "checksum). Do not continue unless you're sure that $DISTBIN" \ - "is not corrupted.\n" >> /tmp/busybox-power-error - fi - fi - else - echo -e "Warning: could not load the saved SHA1 checksum of the backup" \ - "of the original BusyBox binary; the integrity of the backup of the" \ - "original binary can not be guaranteed.\n" >> /tmp/busybox-power-error - fi -} - -# Check whether /bin/busybox has been modified after bb-power's installation -CHECK_INSTALLEDBIN() { - if test "$INSTBINARY_SHA1" != "`sha1sum /bin/busybox | awk '{ print $1 }'`"; then - echo -e "Warning: /bin/busybox has been modified since installing" \ - "busybox-power (invalid SHA1 checksum). Your current /bin/busybox" \ - "won't be touched and the diversion of /bin/busybox to $DISTBIN will" \ - "not be removed. \n" >> /tmp/busybox-power-error - MODIFIEDBIN="1" - fi -} - -# Display encountered errors -DISPLAY_ERRORS() { - case $ENVIRONMENT in - SDK) - echo -e "\n\n-----------Attention!-----------" - cat /tmp/busybox-power-error - rm /tmp/busybox-power-error - echo "-> Please press [enter] to ignore the above errors/warnings." - echo " Hit [ctrl-c] to break" - read - ;; - FREMANTLE) - echo "Click \"I Agree\" to ignore the above errors/warnings. Ask for" \ - "help if you don't know what to do." >> /tmp/busybox-power-error - echo "Please confirm the text on the screen of your device" - maemo-confirm-text "Attention!" /tmp/busybox-power-error - res=$? - rm /tmp/busybox-power-error - if test ! $res == 0; then exit 1; fi - ;; - esac -} - -# Uninstallation of the enhanced binary -UNINSTALL() { - if test $MODIFIEDBIN == 1; then - # /bin/busybox has been modified since installing busybox-power - # Leave both the file and the diversion in place - return - elif test -e $DISTBIN; then - cp -af $DISTBIN /bin/busybox - if test -e /bin/busybox; then - rm $DISTBIN; fi - elif test "$ENVIRONMENT" == "SDK"; then - # There was no /bin/busybox to begin with.. - rm /bin/busybox - fi - - /usr/sbin/dpkg-divert --remove /bin/busybox -} - -# Remove all symlinks that the installation script has made -UNSYMLINK() { - # Load list of installed symlinks - touch $INSTALLDIR/busybox-power.symlinks - source $INSTALLDIR/busybox-power.symlinks - - # Walk through all possible destinations - for DESTDIR in $DESTINATIONS; do - # Enable us to see all entries in $DESTINATIONS as variables - eval "APPLICATIONS=\$$DESTDIR" - # Set destination directory accordingly - case $DESTDIR in - DEST_BIN) - DIR="/bin" - ;; - DEST_SBIN) - DIR="/sbin" - ;; - DEST_USRBIN) - DIR="/usr/bin" - ;; - DEST_USRSBIN) - DIR="/usr/sbin" - ;; - esac - - ECHO_VERBOSE "\nRemoving symlinks in $DIR" - # Walk through all applications from the current destination - for APP in $APPLICATIONS; do - # The following code is executed for every application in the current - # destination - if test -h $DIR/$APP; then - # Good, this app is still a symbolic link .. - if test -n "`ls -l $DIR/$APP | grep busybox`"; then - ECHO_VERBOSE "Removing link: $DIR/$APP" - rm $DIR/$APP - fi - fi - done - done -} - -# Action to be performed after restoring original busybox -CLEANUP() { - OLDFILES="busybox-power.symlinks - busybox.distrib.version - busybox.distrib.sha1" - - for file in $OLDFILES; do - if test -e $INSTALLDIR/$file; then - rm $INSTALLDIR/$file - fi - done -} - -### Codepath ### -ECHO_VERBOSE "busybox-power: verbose mode" -ECHO_VERBOSE " binary: $EXECPWR" -ECHO_VERBOSE " version string: `$EXECPWR | $EXECPWR head -n 1`" -CHECK_ENV && ECHO_VERBOSE " environment: $ENVIRONMENT" - -CHECK_STANDALONE -CHECK_SYMLINKSFILE -if test "$ENVIRONMENT" != "SDK"; then - CHECK_ROOT - CHECK_BACKUP - CHECK_INSTALLEDBIN -fi -if test -e /tmp/busybox-power-error; then - # An error has occured during the checks - DISPLAY_ERRORS -fi -UNSYMLINK -UNINSTALL -CLEANUP - -- 1.7.9.5