[tex-live] texlinks patch - unlink option
Zdenek Wagner
zdenek.wagner at gmail.com
Wed Oct 10 12:26:58 CEST 2007
2007/10/10, Edd Barrett <vext01 at gmail.com>:
> Hi there,
>
> I have added an option to the texlinks script which allows the user to
> unlink, effectively reversing the texlinks process. I needed this to
> clean up the filesystem before the texlive package is removed.
>
The following command removes all symlinks to nonexistent files:
find / -name "*" -type l ! -xtype f ! -xtype d -ok rm {} \;
I am aware that this need not be desirable in all cases.
> a) Is the code correct? It appears to do what I think it should, but a
> second pair of eyes might reveal more.
>
> b) Can this go upstream? I would find it useful, as I wouldn't have to
> re-patch my port each year.
>
> --- texk/tetex/texlinks.orig Tue Oct 9 14:21:16 2007
> +++ texk/tetex/texlinks Tue Oct 9 14:24:11 2007
> @@ -6,6 +6,9 @@
> # the lines given in fmtutil.cnf.
>
> # History:
> +# Tue Oct 9 14:23:01 BST 2007
> +# Added unlink option (-u) to aid OpenBSD package uninstall
> +# Edd Barrett <vext01 at gmail.com>
> # Sun Aug 28 21:41:06 CEST 2005
> # remove special cases for csplain,cslatex,pdfcslatex,pdfcsplain
> # Fr Apr 8 19:15:05 CEST 2005
> @@ -57,6 +60,8 @@ Valid options:
> --silent
> -s silently skip over existing scripts / binaries
> instead of creating a warning
> + --unlink Delete symlinks created by texlinks
> + -u
>
> directories is an optional list of directories in which to operate.
> If no directories are specified the list of directories depends on the
> @@ -205,6 +210,25 @@ upd_symlinkdir()
> }
>
> ###############################################################################
> +# rm_link()
> +# Delete a previously installed link
> +###############################################################################
> +
> +rm_link()
> +{
> + link=$1;
> + if test -e $link; then
> + if test -h $link; then
> + verbose_do rm -Rf $link
> + else
> + verbose_echo "$link: Not a symlink. Keeping"
> + fi
> + else
> + verbose_echo "$link: Non-existent. Skipping"
> + fi
> +}
> +
> +###############################################################################
> # main()
> # parse commandline arguments, initialize variables,
> # switch into temp. direcrory, execute desired command
> @@ -217,6 +241,7 @@ main()
>
> multiplatform=false
> verbose=false
> + unlink=false
> silent=false
> thisdir=`pwd`
> : ${KPSE_DOT=$thisdir}; export KPSE_DOT
> @@ -232,6 +257,7 @@ main()
> --v*|-v) verbose=true;;
> --s*|-s) silent=true;;
> --m*|-m) multiplatform=true;;
> + --u*|-u) unlink=true;;
> -*) errmsg "fmtutil: unknown option \`$1' ignored.";;
> *) break;;
> esac
> @@ -278,7 +304,12 @@ main()
>
> test "x$fmt" = "x$engine" && continue
> if test -f "$d/$engine"; then
> - install_link "$engine" "$d/$fmt"
> + case $unlink in
> + true)
> + rm_link "$d/$fmt";;
> + *)
> + install_link "$engine" "$d/$fmt";;
> + esac
> else
> verbose_echo "$d/$engine: engine does not exist. Skipping..."
> fi
>
> Thanks
>
> --
> Best Regards
>
> Edd
>
> ---------------------------------------------------
> http://students.dec.bournemouth.ac.uk/ebarrett
>
--
Zdeněk Wagner
http://hroch486.icpf.cas.cz/wagner/
http://icebearsoft.euweb.cz
More information about the tex-live
mailing list