update to util-say 3

Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
Mattias Andrée 2013-04-01 16:13:46 +02:00
parent 6db699c54a
commit 799bb335d5
4 changed files with 26 additions and 46 deletions

View file

@ -28,9 +28,8 @@ pv=0 # python version
(hash stty 2>/dev/null) || (rr=1 ; echo 'Missing stty, install coreutils [runtime required]')
(hash tty2colourfultty 2>/dev/null) || (ro=1 ; echo 'Missing tty2colourfultty, install util-say [runtime optional]')
(hash ponysay2ttyponysay 2>/dev/null) || (ro=1 ; echo 'Missing ponysay2ttyponysay, install util-say [runtime optional]')
(hash chmod 2>/dev/null) || (rr=1 ; echo 'Missing chmod, install coreutils [runtime optional]')
(hash ponytool 2>/dev/null) || (ro=1 ; echo 'Missing ponytool, install util-say [runtime optional]')
(hash chmod 2>/dev/null) || (rr=1 ; echo 'Missing chmod, install coreutils [runtime optional]')
( (test $br = 1) || (test $rr = 1) || (test $ro = 1) || (test $pv = 1) ) && echo

View file

@ -8,17 +8,14 @@
ttyponies()
{
defaultoutparams=--colourful y --left - --right - --top - --bottom - --balloon n --fullcolour y
mkdir -p "ttyponies"
for pony in $(ls --color=no "ponies/"); do
if [ ! "$pony" = '.info' ]; then
echo "building ttypony: $pony"
if [ "`readlink "ponies/$pony"`" = '' ]; then
./ponysay-tool.py --edit-stash "ponies/$pony" > ".pony.metadata~"
./ponysay-tool.py --edit-rm "ponies/$pony"
ponysay2ttyponysay < "ponies/$pony" | tty2colourfultty -c 1 > "ttyponies/$pony"
./ponysay-tool.py --edit-apply "ponies/$pony" < ".pony.metadata~"
./ponysay-tool.py --edit-apply "ttyponies/$pony" < ".pony.metadata~"
git add "ttyponies/$pony"
ponytool --import ponysay --file "ponies/$pony" --export ponysay --platform linux --file "ttyponies/$pony" $defaultoutparams
git add "ttyponies/$pony"
else
ln -sf `readlink "ponies/$pony"` "ttyponies/$pony"
git add "ttyponies/$pony"
@ -30,11 +27,7 @@ ttyponies()
if [ ! "$pony" = '.info' ]; then
echo "building extrattypony: $pony"
if [ "`readlink "extraponies/$pony"`" = '' ]; then
./ponysay-tool.py --edit-stash "extraponies/$pony" > ".pony.metadata~"
./ponysay-tool.py --edit-rm "extraponies/$pony"
ponysay2ttyponysay < "extraponies/$pony" | tty2colourfultty -c 1 > "extrattyponies/$pony"
./ponysay-tool.py --edit-apply "extraponies/$pony" < ".pony.metadata~"
./ponysay-tool.py --edit-apply "extrattyponies/$pony" < ".pony.metadata~"
ponytool --import ponysay --file "extraponies/$pony" --export ponysay --platform linux --file "extrattyponies/$pony" $defaultoutparams
git add "extrattyponies/$pony"
else
ln -sf `readlink "extraponies/$pony"` "extrattyponies/$pony"
@ -42,7 +35,6 @@ ttyponies()
fi
fi
done
rm ".pony.metadata~"
}
@ -88,3 +80,4 @@ tag()
[ "$1" = './dist.sh' ] && cd ..
"$@"

View file

@ -795,8 +795,9 @@ is used togather with @env{PONYSAY_WRAP_LIMIT}. The default value is 5.
@cindex @file{/var/cache/ponysay}
@cindex @file{~/.cache/ponysay}
KMS ponies is an optional feature that required that you have @command{util-say>=2}
(@command{util-say<2} for @command{ponysay<2.1}) installed. It lets TTY users that
KMS ponies is an optional feature that required that you have @command{util-say>=3}
(@command{util-say<2} for @command{ponysay<2.1} and @command{util-say<3} for
@command{ponysay<3}) installed. It lets TTY users that
have a custom TTY colour palette and KMS support get best TTY images that can be
display at the current state of the art. KMS is supported on most computers, but due
to lack of published specifications Nvidia drivers does not support KMS.
@ -1606,7 +1607,7 @@ in @command{fish}, so case you @command{sh} links to @command{fish}, run
@cindex optional dependencies
@table @command
@item util-say>=2
@item util-say>=3
@pindex @command{util-say}
@cindex kms
@cindex tty
@ -1664,7 +1665,7 @@ Required to run @command{dev/dist.sh}.
@pindex @command{coreutils}
@command{ln} and @command{readlink} are used in the @command{ttyponies} subscript
of @command{dev/dist.sh}.
@item util-say>=2
@item util-say>=3
Used by @command{dev/dist.sh ttyponies} to build ttyponies from xterm ponies.
It can be downloaded at @url{https://github.com/maandree/util-say}.
@end table
@ -2717,7 +2718,7 @@ pkgdesc="Cowsay reimplementation for ponies"
url="https://github.com/erkin/ponysay"
license=('WTFPL' 'GNU FDL v1.3')
depends=(python>=3 coreutils)
optdepends=("util-say>=2: Improved TTY support with KMS and PNG files")
optdepends=("util-say>=3: Improved TTY support with KMS and PNG files")
makedepends=('git' 'texinfo' 'info' 'gzip' 'python>=3')
build()

View file

@ -1161,7 +1161,8 @@ class Ponysay():
## Use PNG file as pony file
if endswith(pony.lower(), '.png'):
pony = '\'' + pony.replace('\'', '\'\\\'\'') + '\''
pngcmd = ('img2ponysay -p -- ' if self.linuxvt else 'img2ponysay -- ') + pony
pngcmd = 'ponytool --in image --file %s --out ponysay --platform %s --balloon y'
pngcmd %= (pony, ('linux' if self.linuxvt else 'xterm')) # XXX xterm should be haiku in Haiku
pngpipe = os.pipe()
Popen(pngcmd, stdout=os.fdopen(pngpipe[1], 'w'), shell=True).wait()
pony = '/proc/' + str(os.getpid()) + '/fd/' + str(pngpipe[0])
@ -1322,7 +1323,7 @@ class Ponysay():
return pony
## KMS support version constant
KMS_VERSION = '1'
KMS_VERSION = '2'
## Read the PONYSAY_KMS_PALETTE environment variable
env_kms = os.environ['PONYSAY_KMS_PALETTE'] if 'PONYSAY_KMS_PALETTE' in os.environ else None
@ -1339,7 +1340,7 @@ class Ponysay():
if env_kms == '':
return pony
## Store palette string and a clong with just the essentials
## Store palette string and a clone with just the essentials
palette = env_kms
palettefile = env_kms.replace('\033]P', '')
@ -1379,36 +1380,22 @@ class Ponysay():
## If the kmspony is missing, create it
if not os.path.isfile(kmspony):
## Protokmsponies are uncolourful ttyponies
protokmsponies = cachedir + '/protokmsponies/'
protokmspony = (protokmsponies + pony).replace('//', '/')
protokmsponydir = protokmspony[:protokmspony.rindex('/')]
kmsponydir = kmspony[: kmspony.rindex('/')]
## kmspony directory
kmsponydir = kmspony[:kmspony.rindex('/')]
## Change file names to be shell friendly
_protokmspony = '\'' + protokmspony.replace('\'', '\'\\\'\'') + '\''
_kmspony = '\'' + kmspony.replace('\'', '\'\\\'\'') + '\''
_pony = '\'' + pony.replace('\'', '\'\\\'\'') + '\''
## Create protokmspony is missing
if not os.path.isfile(protokmspony):
if not os.path.isdir(protokmsponydir):
os.makedirs(protokmsponydir)
if shared:
Popen('chmod -R 6777 -- ' + _cachedir, shell=True).wait()
if not os.system('ponysay2ttyponysay < ' + _pony + ' > ' + _protokmspony) == 0:
sys.stderr.write('Unable to run ponysay2ttyponysay successfully, you need util-say for KMS support\n')
exit(1)
if shared:
Popen('chmod 666 -- ' + _protokmspony, shell=True).wait()
_kmspony = '\'' + kmspony.replace('\'', '\'\\\'\'') + '\''
_pony = '\'' + pony.replace('\'', '\'\\\'\'') + '\''
## Create kmspony
if not os.path.isdir(kmsponydir):
os.makedirs(kmsponydir)
if shared:
Popen('chmod -R 6777 -- ' + _cachedir, shell=True).wait()
if not os.system('tty2colourfultty -p ' + palette + ' < ' + _protokmspony + ' > ' + _kmspony) == 0:
sys.stderr.write('Unable to run tty2colourfultty successfully, you need util-say for KMS support\n')
ponytoolcmd = 'ponytoolcmd --import ponysay --file %s --export ponysay --file %s --platform linux ' +
'--balloon n --colourful y --fullcolour y --left - --right - --top - --bottom - --palette %s'
if not os.system(ponytoolcmd % (_pony, _kmspony, palette)) == 0:
sys.stderr.write('Unable to run ponytool successfully, you need util-say>=3 for KMS support\n')
exit(1)
if shared:
Popen('chmod 666 -- ' + _kmspony, shell=True).wait()
@ -1882,7 +1869,7 @@ class Backend():
printinfo(info)
self.pony = self.pony[infoend:]
elif self.infolevel == 2:
self.message = '\033[1;31mI am the mysterious mare...\033[21;3m'
self.message = '\033[01;31mI am the mysterious mare...\033[21;39m'
elif self.infolevel == 1:
self.pony = 'There is not metadata for this pony file'
self.pony = self.mode + self.pony