#!/usr/bin/python
#
# $TEXMFDIST/texconfig/zypper.py
#
# The substitute for the %posttrans  scriptlets used by rpm.
# Make sure that the update script does its work only once after
# an installation/update transaction as zypper executes rpm for
# each single texlive package.
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
# 
# Author: Werner Fink, 2012
#
from os          import path, remove, access, F_OK,R_OK,X_OK
from subprocess  import call

global update, tagfile
update = "%{_texmfdistdir}/texconfig/update"
tagfile = "/var/run/texlive/run-update"

if access(update, F_OK|X_OK) and path.exists(tagfile):
    call("VERBOSE=false " + update + " 2>&1 || :", shell=True)
    try:
	remove(tagfile)
    except OSError:
	pass
