hets_script revision 6e933aed300d092a1ebc4da6f18b175e15beafa3
if [
"`id -u`" =
"0" ];
then import fcntl, os, sys, subprocess; subprocess.DEVNULL=os.open(os.devnull, os.O_RDWR) subprocess.STDOUT=sys.stdout subprocess.STDERR=sys.stderr class UpdateFailure(Exception): f = open("/var/lib/dpkg/lock", 'w') fcntl.lockf(f, fcntl.LOCK_EX|fcntl.LOCK_NB) print "Retrieving latest Hets library...", subprocess.call("rm -r -f /tmp/hets*",shell=True,stderr=subprocess.DEVNULL) subprocess.check_call(["svn","export", "--force", "-q", "https://svn-agbkb.informatik.uni-bremen.de/Hets-lib/trunk","/tmp/hets-lib"], stdout=subprocess.STDOUT,stderr=subprocess.STDERR) except subprocess.CalledProcessError: raise UpdateFailure("Failed to retrieve latest Hets library!") print "Retrieving latest Hets binary...", subprocess.call(["rm", "-f", "/tmp/hets-$HETS_DAILY_VERSION*"],stderr=subprocess.DEVNULL) if os.uname()[4] == "x86_64": subprocess.check_call("curl -sG http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/CoFI/hets/linux64/daily/hets.bz2 \ > /tmp/hets-$HETS_DAILY_VERSION.bz2",shell=True,stdout=sys.stdout,stderr=sys.stderr) subprocess.check_call("curl -sG http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/CoFI/hets/linux/daily/hets.bz2 \ > /tmp/hets-$HETS_DAILY_VERSION.bz2",shell=True,stdout=sys.stdout,stderr=sys.stderr) except subprocess.CalledProcessError: raise UpdateFailure("Failed to retrieve latest Hets binary...") subprocess.check_call(["bunzip2", "/tmp/hets-$HETS_DAILY_VERSION.bz2"], stdout=subprocess.STDOUT,stderr=subprocess.STDERR) subprocess.call(["chmod","+x","/tmp/hets-$HETS_DAILY_VERSION"]) subprocess.check_call(["/tmp/hets-$HETS_DAILY_VERSION","-V"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL) except subprocess.CalledProcessError: raise UpdateFailure("Retrieved Hets binary seems broken. Please try again later!") print "Creating Backups ...", subprocess.check_call(["mv", "/usr/lib/hets/hets", "/usr/lib/hets/hets.bak"],stderr=subprocess.DEVNULL) subprocess.check_call(["mv","/usr/lib/hets/hets-lib", "/usr/lib/hets/hets-lib.bak"],stderr=subprocess.DEVNULL) except subprocess.CalledProcessError: raise UpdateFailure("Couldn't create backups. Please make sure the package hets-core is properly installed!") print "Installing new files ...", subprocess.check_call(["install", "-m", "755", "/tmp/hets-$HETS_DAILY_VERSION", "/usr/lib/hets/hets"],stderr=subprocess.DEVNULL) subprocess.check_call(["cp", "-r", "/tmp/hets-lib", "/usr/lib/hets/hets-lib"]) except subprocess.CalledProcessError: subprocess.call(["rm", "-r", "-f", "/usr/lib/hets/hets", "/usr/lib/hets/hets-lib"],stderr=subprocess.DEVNULL) print "Could not acquire lock \"/var/lib/dpkg/lock\"" except UpdateFailure as e: print "Experienced update failure: ", e.value subprocess.call(["mv", "/usr/lib/hets/hets.bak", "/usr/lib/hets/hets"],stderr=subprocess.DEVNULL) subprocess.call(["mv","/usr/lib/hets/hets-lib.bak", "/usr/lib/hets/hets-lib"],stderr=subprocess.DEVNULL) if not os.path.exists("/usr/lib/hets/hets-lib"): subprocess.call(["mv","/usr/lib/hets/hets-lib.bak","/usr/lib/hets/hets-lib"],stderr=subprocess.DEVNULL) if not os.path.exists("/usr/lib/hets/hets"): subprocess.call(["mv","/usr/lib/hets/hets.bak","/usr/lib/hets/hets"],stderr=subprocess.DEVNULL) subprocess.call("rm -r -f /tmp/hets*",shell=True,stderr=subprocess.DEVNULL) echo "Updated to `hets -V`." echo "Root access required for \"hets -update\"" if [
"`id -u`" =
"0" ];
then import fcntl, os, sys, subprocess; subprocess.DEVNULL=os.open(os.devnull, os.O_RDWR) subprocess.STDOUT=sys.stdout subprocess.STDERR=sys.stderr class UpdateFailure(Exception): f = open("/var/lib/dpkg/lock", 'w') fcntl.lockf(f, fcntl.LOCK_EX|fcntl.LOCK_NB) print "Reverting to previous Hets binary... ", subprocess.check_call(["mv", "/usr/lib/hets/hets.bak", "/usr/lib/hets/hets"],stderr=subprocess.DEVNULL); if os.path.exists("/usr/lib/hets/hets-lib.bak"): subprocess.check_call(["rm", "-r", "-f", "/usr/lib/hets/hets-lib"], stderr=subprocess.DEVNULL) subprocess.check_call(["mv", "/usr/lib/hets/hets-lib.bak", "/usr/lib/hets/hets-lib"],stderr=subprocess.DEVNULL) except subprocess.CalledProcessError: raise UpdateFailure("Couldn't restore backup!") print "Could not acquire lock \"/var/lib/dpkg/lock\"" except UpdateFailure as e: print "Experienced revert failure: ", e.value echo "Reverted to `hets -V`." echo "Root access required for \"hets -revert\"" # Setting environment variables