Skip to content

Instantly share code, notes, and snippets.

@turbolent
Created January 22, 2011 14:16
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save turbolent/791141 to your computer and use it in GitHub Desktop.
Bootstrap optware on Kindle
#! /bin/sh
FAILED=0
# remount
echo -n "Re-mounting rw: "
mntroot rw > /dev/null 2>&1 || FAILED=1
if [ "$FAILED" = 1 ] ; then
echo FAILED
exit 1
else
echo OK
fi
# ipkg-opt check
echo -n "Determining latest ipkg-opt package from the Optware package feed: "
cd /tmp || FAILED=1
rm Packages > /dev/null 2>&1
wget http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable/Packages > /dev/null 2>&1 || FAILED=1
IPKG_FILE=$(awk 'BEGIN { RS = "" }; /^Package: ipkg-opt\n/ {print}' Packages | awk '/^Filename:/ {print $2}')
IPKG_SUM=$(awk 'BEGIN { RS = "" }; /^Package: ipkg-opt\n/ {print}' Packages | awk '/^MD5Sum:/ {print $2}')
MD5SUM="${IPKG_SUM} ${IPKG_FILE}"
rm Packages
if [ "$FAILED" = 1 ] ; then
echo FAILED
exit 1
else
echo OK
fi
# ipkg-opt download
if [ ! -f ${IPKG_FILE} ]; then
echo -n "Downloading the ipkg-opt package from the Optware package feed: "
wget "http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable/${IPKG_FILE}" > /dev/null 2>&1 || FAILED=1
fi
if [ "$FAILED" = 1 ] ; then
echo FAILED
exit 1
else
echo OK
fi
# ipkg-opt md5 check
echo -n "Checking the md5sum of "
if [ "$(md5sum ${IPKG_FILE})" != "$MD5SUM" ]; then
echo FAILED
exit 1
fi
# ipkg-opt install
echo -n "Installing the ipkg-opt package: "
mkdir -p /tmp/ipkg-opt || FAILED=1
cd /tmp/ipkg-opt || FAILED=1
tar xzf ../"$IPKG_FILE" || FAILED=1
cd / || FAILED=1
tar xzf /tmp/ipkg-opt/data.tar.gz || FAILED=1
if [ "$FAILED" = 1 ] ; then
echo FAILED
exit 1
else
echo OK
fi
# cleanup
rm /tmp/"$IPKG_FILE"
rm -rf /tmp/ipkg
# feed configuration
echo -n "Configuring the Optware feeds: "
mkdir -p /opt/etc/ipkg || FAILED=1
echo "src/gz cross http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable" > /opt/etc/ipkg/optware.conf || FAILED=1
echo "src/gz native http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/native/unstable" >> /opt/etc/ipkg/optware.conf || FAILED=1
if [ "$FAILED" = 1 ] ; then
echo FAILED
exit 1
else
echo OK
fi
# add optware to PATH
grep "PATH:/opt/bin" /etc/profile
if [ "$?" != 0 ]; then
echo -n "Adding /opt/bin to the default \$PATH: "
cat <<EOF >> /etc/profile
PATH=\$PATH:/opt/bin
if [ "\`id -u\`" -eq 0 ]; then
PATH=\$PATH:/opt/sbin
fi
EOF
echo OK
fi
# patching ipkg
sed -i 's/ --passive-ftp / /g' \
/opt/lib/libipkg.so \
/opt/lib/libipkg.so.0.0.0
# optware update
export PATH=/opt/bin:$PATH
echo -n "Updating the Optware package database: "
ipkg-opt update > /dev/null 2>&1
if [ "$?" = 0 ] ; then
echo OK
else
echo FAILED
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment