[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: jadetex upload



Hi Frank, hi all,

On Mit, 02 Mai 2007, Frank Küster wrote:
> I haven't looked at the code you want to drop, but it sounds sensible.

I attach the few files here, please take a look and tell me what you
think, drop all?

Best wishes

Norbert

-------------------------------------------------------------------------------
Dr. Norbert Preining <preining@logic.at>                    Università di Siena
Debian Developer <preining@debian.org>                         Debian TeX Group
gpg DSA: 0x09C5B094      fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
What the hell, he thought, you're only young once, and
threw himself out of the window. That would at least keep
the element of surprise on his side.
                 --- Ford outwitting a Vogon with a rocket launcher by going
                 --- into another certain death situation.
                 --- Douglas Adams, The Hitchhikers Guide to the Galaxy
#!/bin/bash
# jadetex postinst
#   jobs: remove old cruft we used to make

set -e

# clear environment
TETEXDIR=
TEXMF=
TEXINPUTS=

PACKAGE=jadetex

umask 022

# emit a warning, generic routine
warn ( ) {
   echo $* 1>&2
   if [ -f $MYTMPFILE ]; then
       echo $* >> $MYTMPFILE
   fi
}

dpkg_md5sum(){
  grep "$1[[:space:]]"  /var/lib/dpkg/status | cut -f 3 -d ' '
}

config_rename ()
{
    oldfile=$1
    oldmd5sum=$(dpkg_md5sum $oldfile)

    if ! [ -r $oldfile ] ; then
        return 0
    fi
    oldloc=$(dirname $oldfile)
    newmd5sum=$(md5sum $oldfile |  cut -d ' ' -f 1)
    if [ "$newmd5sum" = "$oldmd5sum" ] ; then
        echo "Removing obsolete, unchanged conffile $oldfile"
        rm $oldfile
    else
        echo "Conffile $oldfile was changed, renaming it to $oldfile.dpkg-save"
	echo "Please see the TeX Policy on where to put the file."
        mv $oldfile $oldfile.dpkg-save
    fi
    test -d $oldloc && rmdir --ignore-fail-on-non-empty $oldloc || true
}

remove_conffile_commit () {
  # syntax: remove_conffile_commit filename
  #
  # Complete the removal of a conffile "filename" that has become obsolete.
  #
  # Call this function from a postinst script after having used
  # remove_conffile_prepare() in the preinst.

  # validate arguments
  if [ $# -ne 1 ]; then
    echo "remove_conffile_commit() called with wrong number of" \
                "arguments; expected 1, got $#"
    exit 2
  fi

  conffile="$1"

  # if the temporary file created by remove_conffile_prepare() exists, remove it
  if [ -e "$conffile.${PACKAGE}-tmp" ]; then
    echo "committing removal of obsolete conffile $conffile"
    rm "$conffile.${PACKAGE}-tmp"
  fi
}

if [ "$1" = "configure" ]; then
    # old crufty stuff we used to build in postinst - I wonder whether we
    # should actually do this in preinst?
	remove_conffile_commit /etc/texmf/fmt.d/40jadetex.cnf

    if [ -L /usr/lib/texmf/tex/jadetex/config ]; then
	warn "removing old JadeTeX config symlink"
	rm /usr/lib/texmf/tex/jadetex/config
    fi
    if [ -d /usr/lib/texmf/tex/jadetex ]; then
	rmdir /usr/lib/texmf/tex/jadetex || \
	  warn "unused, obsolete dir /usr/lib/texmf/tex/jadetex, remove it yourself if you care"
    fi
    if [ -f /etc/texmf/texmf.d/96JadeTeX ]; then
	warn "removing old texmf.d config snippet"
	rm /etc/texmf/texmf.d/96JadeTeX
    fi
    # rename the files in /etc/texmf/jadetex/ or remove them.
    config_rename /etc/texmf/jadetex/jadetex.ini 
    config_rename /etc/texmf/jadetex/pdfjadetex.ini 
fi

#DEBHELPER#

exit 0

#! /bin/sh
# preinst script for jadetex
#
# see: dh_installdeb(1)

set -e

PACKAGE=jadetex

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>
#
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

remove_conffile_prepare () {
  # syntax: remove_conffile_prepare filename official_md5sum ...
  #
  # Check a conffile "filename" against a list of canonical MD5 checksums.
  # If the file's current MD5 checksum matches one of the "official_md5sum"
  # operands provided, then prepare the conffile for removal from the system.
  # We defer actual deletion until the package is configured so that we can
  # roll this operation back if package installation fails.
  #
  # Call this function from a preinst script in the event $1 is "upgrade" or
  # "install" and verify $2 to ensure the package is being upgraded from a
  # version (or installed over a version removed-but-not-purged) prior to the
  # one in which the conffile was obsoleted.

  # validate arguments
  if [ $# -lt 2 ]; then
    echo "remove_conffile_prepare() called with wrong number of" \
                "arguments; expected at least 2, got $#"
    exit 2
  fi

  conffile="$1"
  shift

  # does the conffile even exist?
  if [ -e "$conffile" ]; then
    # calculate its checksum
    current_checksum=$(md5sum < "$conffile" | sed 's/[[:space:]].*//')
    # compare it to each supplied checksum
    while [ -n "$1" ]; do
      if [ "$current_checksum" = "$1" ]; then
        # we found a match; move the confffile and stop looking
        echo "preparing obsolete conffile $conffile for removal"
        mv "$conffile" "$conffile.${PACKAGE}-tmp"
        break
      fi
      shift
    done
  fi
}


case "$1" in
    install|upgrade)
	if dpkg --compare-versions "$2" le "3.13-3"; then
		remove_conffile_prepare /etc/texmf/fmt.d/40jadetex.cnf \
			0812091d71375023df7dcecb7290b10a
	fi
	if [ -L /usr/share/texmf/tex/jadetex/config ] ; then
	    if [ "$(readlink -n -s /usr/share/texmf/tex/jadetex/config)" = "/etc/texmf/jadetex" ] ; then
	        echo "Removing /usr/share/texmf/tex/jadetex/config symlink."
		rm /usr/share/texmf/tex/jadetex/config
	    fi
	fi
    ;;

    abort-upgrade)
        if ! [ -e /usr/share/texmf/tex/jadetex/config ] ; then
	    ln -s /etc/texmf/jadetex /usr/share/texmf/tex/jadetex/config
	fi
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


#! /bin/sh
# postrm script for jadetex
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PACKAGE=jadatex
ETC_CONFIG=/etc/texmf/jadetex
FMTDIR=/etc/texmf/fmt.d

remove_conffile_rollback () {
  # syntax: remove_conffile_rollback filename
  #
  # Roll back the removal of a conffile "filename".
  #
  # Call this function from a postrm script in the event $1 is "abort-upgrade"
  # or "abort-install" is  after having used remove_conffile_prepare() in the
  # preinst.

  # validate arguments
  if [ $# -ne 1 ]; then
    echo "remove_conffile_rollback() called with wrong number of" \
                "arguments; expected 1, got $#"
    exit 2
  fi

  conffile="$1"

  # if the temporary file created by remove_conffile_prepare() exists, move it
  # back
  if [ -e "$conffile.${PACKAGE}-tmp" ]; then
    echo "rolling back removal of obsolete conffile $conffile"
    mv "$conffile.${PACKAGE}-tmp" "$conffile"
  fi
}

case "$1" in
    purge)
	rm -rf $ETC_CONFIG || true
	rm -f ${FMTDIR}/*jadetex.cnf*
	rm -f /etc/texmf/texmf.d/*JadeTeX*
	update-texmf || true

	;;

    abort-install|abort-upgrade)
	remove_conffile_rollback /etc/texmf/fmt.d/40jadetex.cnf
	;;

    remove|upgrade|failed-upgrade|disappear)

        ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1

esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

Reply to: