From 908616bcea3acaa34ad6b10b28e489189bb689db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 20 Aug 2012 18:53:00 +0200 Subject: [PATCH] private cache --- configure | 9 ++++++++- manuals/ponysay.texinfo | 7 +++++++ ponysay | 10 ++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/configure b/configure index ead5648d..abd69532 100755 --- a/configure +++ b/configure @@ -53,6 +53,7 @@ function getcompfile() +installCache=' install-cache' installPdf='' installInfo=' install-info' installInfoInstall=' install-info-install' @@ -73,6 +74,7 @@ for arg in "$@"; do elif [ "$opt" = '--shell' ]; then SHELL="$val" + elif [ "$opt" = '--without-shared-cache' ]; then installCache='' elif [ "$opt" = '--with-pdf' ]; then installPdf=' install-pdf' elif [ "$opt" = '--without-info' ]; then installInfo='' elif [ "$opt" = '--without-info-install' ]; then installInfoInstall='' @@ -83,6 +85,7 @@ for arg in "$@"; do elif [ "$opt" = '--without-zsh' ]; then installZsh='' elif [ "$opt" = "--everything" ]; then + installCache=' install-cache' installPdf=' install-pdf' installInfo=' install-info' installInfoInstall=' install-info-install' @@ -102,7 +105,7 @@ if [ "$installInfo" = '' ]; then fi compileMethods='core quotes manpages ponysaycompletion ponythinkcompletion' -installMethods='install-min'"$installPdf$installInfo$installInfoInstall$installMan$installManEs$installBash$installFish$installZsh" +installMethods='install-min'"$installCache$installPdf$installInfo$installInfoInstall$installMan$installManEs$installBash$installFish$installZsh" if [ ! "$installInfo" = '' ]; then compileMethods="$compileMethods infomanual" fi @@ -144,6 +147,7 @@ echo "PREFIX = $PREFIX, edit with option --prefix=PREFIX" echo "INFODESC = $INFODESC, edit with option --info-desc=INFODESC" echo "SHELL = $SHELL, edit with option --shell=PREFIX" echo +[ ! "$installCache" = '' ] && echo "Installing shared cache, add option --without-shared-cache to skip" [ ! "$installPdf" = '' ] && echo "Installing PDF manual" [ ! "$installInfo" = '' ] && echo "Installing info manual, add option --without-info to skip" [ ! "$installInfoInstall" = '' ] && echo "Installing info manual with info-install, add option --without-info to skip" @@ -153,6 +157,7 @@ echo [ ! "$installFish" = '' ] && echo "Installing autocompletion for fish, add option --without-fish to skip" [ ! "$installZsh" = '' ] && echo "Installing autocompletion for zsh, add option --without-zsh to skip" echo +[ ! "$installCache" = '' ] || echo "Skipping shared cache" [ ! "$installPdf" = '' ] || echo "Skipping PDF manual, add option --with-pdf to install" [ ! "$installInfo" = '' ] || echo "Skipping info manual" [ ! "$installInfoInstall" = '' ] || echo "Skipping info manual installation with info-install" @@ -232,6 +237,8 @@ function makeMakefile() echo 'install "'"$file"'" "$(INSTALLDIR)/share/licenses/ponysay/'"$file"'"' done echo + + echo 'install-cache:' echo -en '\t' ; echo 'if [ -d "/var/cache/ponysay" ]; then rm -r "/var/cache/ponysay"; fi' echo -en '\t' ; echo 'mkdir -p "$(DESTDIR)/var/cache/ponysay/"' echo -en '\t' ; echo 'chmod 777 "$(DESTDIR)/var/cache/ponysay/"' diff --git a/manuals/ponysay.texinfo b/manuals/ponysay.texinfo index f600522f..2e02e535 100644 --- a/manuals/ponysay.texinfo +++ b/manuals/ponysay.texinfo @@ -651,6 +651,12 @@ Friendly interactive shell, @command{fish}. @cindex @command{zsh}, without will skip installation of auto-completion for @command{ponysay} and the shell @command{zsh}. +@item @command{--without-shared-cache} +@cindex @command{--without-shared-cache} +@cindex cache +@cindex kms +will skip installing a shared cache for KMS support, when there is no +shared cache, private one will be used at @code{~/.cache/ponysay}. @end itemize @cindex @command{--prefix=TARGET} @@ -672,6 +678,7 @@ By default @command{bash} is in the make file, if you want to use another shell add the option @command{--shell=SHELL}. + @node Arch Linux @section Arch Linux @cindex arch linux diff --git a/ponysay b/ponysay index 8cbada9f..9786f669 100755 --- a/ponysay +++ b/ponysay @@ -452,11 +452,17 @@ class Ponysay(): palette = env_kms palettefile = env_kms.replace('\033]P', '') - kmsponies = '/var/cache/ponysay/kmsponies/' + palettefile + cachedir = '/var/cache/ponysay' + if not os.path.isdir(cachedir): + cachedir = HOME + '/.cache/ponysay' + if not os.path.isdir(cachedir): + os.makedirs(cachedir) + + kmsponies = cachedir + '/kmsponies/' + palettefile kmspony = (kmsponies + pony).replace('//', '/') if not os.path.isfile(kmspony): - protokmsponies = '/var/cache/ponysay/protokmsponies/' + protokmsponies = cachedir + '/protokmsponies/' protokmspony = (protokmsponies + pony).replace('//', '/') protokmsponydir = protokmspony[:protokmspony.rindex('/')]