View Single Post
Old 02-07-2014, 05:35 PM   #32
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
In case anyone is interested -- edge case

As there have been a couple times now that Kovid pushed an updated binary due to critical errors, I upgraded my update script to allow a "force" option, this keeps everything in one script.

It looks like this now:

Code:
#!/bin/bash

# Unset git development source
export CALIBRE_DEVELOP_FROM=
# by default, switch is off
force_upgrade=0

# Functions

usage()
{
	cat <<- _EOF_
		Usage: calibre-upgrade [OPTIONS]
		Upgrades calibre installation. Automaticaly checks if the current version is up to date.

		OPTIONS
		    -f, --force        Force an update. This is only useful if binaries
		                       were updated for a critical error :shrug:
_EOF_
}

do_upgrade()
{
	cd ~/bin/calibre-portable
	rm -rf ../calibre-portable/*
	wget -O - "http://status.calibre-ebook.com/dist/linux32" | tar xjf -
}

# Options
while [ "$1" != "" ]; do
	case $1 in
		-h|--help)		usage
						exit
						;;
		-f|--force)		shift
						force_upgrade=1
						;;
		*)				echo "calibre-upgrade: unrecognized option '$1'"
						echo "Try 'calibre-upgrade --help' for more information."
						exit 1
	esac
	shift
done

# Main

	calibre-debug -c "import urllib as u; from calibre.constants import numeric_version; raise SystemExit(int(numeric_version  < (tuple(map(int, u.urlopen('http://calibre-ebook.com/downloads/latest_version').read().split('.'))))))"

UP_TO_DATE=$?


if [ "$UP_TO_DATE" = 0 ]; then
	echo "Calibre is up-to-date"

	if [ "$force_upgrade" = 1 ]; then
		echo ""
		echo "Forcing upgrade anyway -- are you sure you want to continue? [y/n]"
		read answer

		if [[ "$answer" = "y" || "$answer" = "yes" ]]; then
			do_upgrade
		else
			echo "Exiting..."
			exit 1
		fi
	fi
else
	do_upgrade
fi
Keep in mind I only use
Code:
cd ~/bin/calibre-portable
rm -rf ../calibre-portable/*
wget -O - "http://status.calibre-ebook.com/dist/linux32" | tar xjf -
to upgrade since I am not running as sudo -- I'm on a school computer ATM

Last edited by eschwartz; 02-28-2014 at 01:24 AM.
eschwartz is offline   Reply With Quote