EXECPWR="$INSTALLDIR/busybox.power"
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
fi
}
-# Create SHA1 hashes of relevant binaries
-HASH_BINARIES() {
- $EXECPWR sha1sum $INSTALLDIR/busybox.power | $EXECPWR awk '{ print $1 }' \
- > $INSTALLDIR/busybox.power.sha1
- $EXECPWR sha1sum /bin/busybox | $EXECPWR awk '{ print $1 }' \
- > $INSTALLDIR/busybox.original.sha1
-}
-
# Backup the original BusyBox binary
BACKUP() {
- case $ENVIRONMENT in
- SDK)
- # Scratchbox does not ship with BusyBox by default
- if test -e /bin/busybox; then
- $EXECPWR cp /bin/busybox $INSTALLDIR/busybox.original; fi
- ;;
- FREMANTLE)
- # Check whether busybox-power isn't somehow installed already
- INSTBINARY_SHA1=`$EXECPWR cat $INSTALLDIR/busybox.power.sha1`
- ORIGBINARY_SHA1=`$EXECPWR cat $INSTALLDIR/busybox.original.sha1`
- if test "$INSTBINARY_SHA1" == "$ORIGBINARY_SHA1"; then
- echo "warning: installed busybox binary matches the binary"
- echo " that is to be installed"
- if ! test -e $INSTALLDIR/busybox.original; then
- $EXECPWR cp /bin/busybox $INSTALLDIR/busybox.original; fi
- else
- $EXECPWR cp /bin/busybox $INSTALLDIR/busybox.original
- fi
- ;;
- esac
+ 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 /bin/busybox $INSTALLDIR/busybox.original
+ $EXECPWR sha1sum $INSTALLDIR/busybox.original | $EXECPWR awk '{ print $1 }' \
+ > $INSTALLDIR/busybox.original.sha1
+ fi
}
# Overwrite the installed binary with the enhanced binary
INSTALL() {
/usr/sbin/dpkg-divert --local --divert /bin/busybox.distrib /bin/busybox
- $EXECPWR cp -f $INSTALLDIR/busybox.power /bin/busybox
+ $EXECPWR cp -f $EXECPWR /bin/busybox
}
# Create missing symlinks to the enhanced binary
CHECK_APPLETSFILE
CHECK_SYMLINKSFILE
if test "$ENVIRONMENT" != "SDK"; then
- CHECK_ROOT
- HASH_BINARIES
-fi
+ CHECK_ROOT; fi
BACKUP
INSTALL
SYMLINK
MODIFIEDBIN="0"
DIVERTED="0"
+INSTBINARY_SHA1=`sha1sum $EXECPWR | awk '{ print $1 }'`
+if test -e $INSTALLDIR/busybox.original; then
+ ORIGBINARY_SHA1=`sha1sum $INSTALLDIR/busybox.original | awk '{ print $1 }'`; fi
+
# Load shared functions
source $INSTALLDIR/functions
# Check the (integrity) of our BusyBox backup
CHECK_BACKUP() {
+ # SDK doesn't ship with BusyBox by default, there might be no backup at all
+ if test ! -e $INSTALLDIR/busybox.original -a "$ENVIRONMENT" == "SDK" ; then
+ return; fi
+
# Firstly, check whether the backup still exists
if test ! -e $INSTALLDIR/busybox.original; then
echo -e "Error: original binary is missing! Continuing will only remove the symlinks made during installation, /bin/busybox stays untouched.\n" >> /tmp/busybox-power-error
# Secondly, check the integrity of the backup
if test -e $INSTALLDIR/busybox.original.sha1; then
- INSTBINARY_SHA1=`cat $INSTALLDIR/busybox.original.sha1`
- ORIGBINARY_SHA1=`sha1sum $INSTALLDIR/busybox.original | awk '{ print $1 }'`
- if test ! "$INSTBINARY_SHA1" == "$ORIGBINARY_SHA1"; then
+ if test ! "`cat $INSTALLDIR/busybox.original.sha1`" == "$ORIGBINARY_SHA1"; then
echo -e "Warning: the backed-up original binary has been modified since installing busybox-power (invalid SHA1 checksum). Do not continue unless you're sure $INSTALLDIR/busybox.original isn't corrupted.\n" >> /tmp/busybox-power-error
fi
else
# Check whether /bin/busybox has been modified after bb-power's installation
CHECK_INSTALLEDBIN() {
- if test -e $INSTALLDIR/busybox.power.sha1; then
- INSTBINARY_SHA1=`sha1sum /bin/busybox | awk '{ print $1 }'`
- ORIGBINARY_SHA1=`cat $INSTALLDIR/busybox.power.sha1`
- if test ! "$INSTBINARY_SHA1" == "$ORIGBINARY_SHA1"; then
- echo -e "Warning: /bin/busybox has been modified since installing busybox-power (invalid SHA1 checksum). Your current /bin/busybox won't be touched, our backup of the original /bin/busybox will be copied to /opt/busybox.original. \n" >> /tmp/busybox-power-error
- MODIFIEDBIN="1"
- fi
+ 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, our backup of the original /bin/busybox will be copied to /opt/busybox.original. \n" >> /tmp/busybox-power-error
+ MODIFIEDBIN="1"
fi
}
# Action to be performed after restoring original busybox
CLEANUP() {
OLDFILES="busybox-power.symlinks
- busybox.power.sha1
busybox.original.sha1"
for file in $OLDFILES; do