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 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 ponytool 2>/dev/null) || (ro=1 ; echo 'Missing ponytool, 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 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 ( (test $br = 1) || (test $rr = 1) || (test $ro = 1) || (test $pv = 1) ) && echo

View file

@ -8,17 +8,14 @@
ttyponies() ttyponies()
{ {
defaultoutparams=--colourful y --left - --right - --top - --bottom - --balloon n --fullcolour y
mkdir -p "ttyponies" mkdir -p "ttyponies"
for pony in $(ls --color=no "ponies/"); do for pony in $(ls --color=no "ponies/"); do
if [ ! "$pony" = '.info' ]; then if [ ! "$pony" = '.info' ]; then
echo "building ttypony: $pony" echo "building ttypony: $pony"
if [ "`readlink "ponies/$pony"`" = '' ]; then if [ "`readlink "ponies/$pony"`" = '' ]; then
./ponysay-tool.py --edit-stash "ponies/$pony" > ".pony.metadata~" ponytool --import ponysay --file "ponies/$pony" --export ponysay --platform linux --file "ttyponies/$pony" $defaultoutparams
./ponysay-tool.py --edit-rm "ponies/$pony" git add "ttyponies/$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"
else else
ln -sf `readlink "ponies/$pony"` "ttyponies/$pony" ln -sf `readlink "ponies/$pony"` "ttyponies/$pony"
git add "ttyponies/$pony" git add "ttyponies/$pony"
@ -30,11 +27,7 @@ ttyponies()
if [ ! "$pony" = '.info' ]; then if [ ! "$pony" = '.info' ]; then
echo "building extrattypony: $pony" echo "building extrattypony: $pony"
if [ "`readlink "extraponies/$pony"`" = '' ]; then if [ "`readlink "extraponies/$pony"`" = '' ]; then
./ponysay-tool.py --edit-stash "extraponies/$pony" > ".pony.metadata~" ponytool --import ponysay --file "extraponies/$pony" --export ponysay --platform linux --file "extrattyponies/$pony" $defaultoutparams
./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~"
git add "extrattyponies/$pony" git add "extrattyponies/$pony"
else else
ln -sf `readlink "extraponies/$pony"` "extrattyponies/$pony" ln -sf `readlink "extraponies/$pony"` "extrattyponies/$pony"
@ -42,7 +35,6 @@ ttyponies()
fi fi
fi fi
done done
rm ".pony.metadata~"
} }
@ -88,3 +80,4 @@ tag()
[ "$1" = './dist.sh' ] && cd .. [ "$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{/var/cache/ponysay}
@cindex @file{~/.cache/ponysay} @cindex @file{~/.cache/ponysay}
KMS ponies is an optional feature that required that you have @command{util-say>=2} KMS ponies is an optional feature that required that you have @command{util-say>=3}
(@command{util-say<2} for @command{ponysay<2.1}) installed. It lets TTY users that (@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 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 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. 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 @cindex optional dependencies
@table @command @table @command
@item util-say>=2 @item util-say>=3
@pindex @command{util-say} @pindex @command{util-say}
@cindex kms @cindex kms
@cindex tty @cindex tty
@ -1664,7 +1665,7 @@ Required to run @command{dev/dist.sh}.
@pindex @command{coreutils} @pindex @command{coreutils}
@command{ln} and @command{readlink} are used in the @command{ttyponies} subscript @command{ln} and @command{readlink} are used in the @command{ttyponies} subscript
of @command{dev/dist.sh}. 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. 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}. It can be downloaded at @url{https://github.com/maandree/util-say}.
@end table @end table
@ -2717,7 +2718,7 @@ pkgdesc="Cowsay reimplementation for ponies"
url="https://github.com/erkin/ponysay" url="https://github.com/erkin/ponysay"
license=('WTFPL' 'GNU FDL v1.3') license=('WTFPL' 'GNU FDL v1.3')
depends=(python>=3 coreutils) 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') makedepends=('git' 'texinfo' 'info' 'gzip' 'python>=3')
build() build()

View file

@ -1161,7 +1161,8 @@ class Ponysay():
## Use PNG file as pony file ## Use PNG file as pony file
if endswith(pony.lower(), '.png'): if endswith(pony.lower(), '.png'):
pony = '\'' + pony.replace('\'', '\'\\\'\'') + '\'' 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() pngpipe = os.pipe()
Popen(pngcmd, stdout=os.fdopen(pngpipe[1], 'w'), shell=True).wait() Popen(pngcmd, stdout=os.fdopen(pngpipe[1], 'w'), shell=True).wait()
pony = '/proc/' + str(os.getpid()) + '/fd/' + str(pngpipe[0]) pony = '/proc/' + str(os.getpid()) + '/fd/' + str(pngpipe[0])
@ -1322,7 +1323,7 @@ class Ponysay():
return pony return pony
## KMS support version constant ## KMS support version constant
KMS_VERSION = '1' KMS_VERSION = '2'
## Read the PONYSAY_KMS_PALETTE environment variable ## Read the PONYSAY_KMS_PALETTE environment variable
env_kms = os.environ['PONYSAY_KMS_PALETTE'] if 'PONYSAY_KMS_PALETTE' in os.environ else None 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 == '': if env_kms == '':
return pony 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 palette = env_kms
palettefile = env_kms.replace('\033]P', '') palettefile = env_kms.replace('\033]P', '')
@ -1379,36 +1380,22 @@ class Ponysay():
## If the kmspony is missing, create it ## If the kmspony is missing, create it
if not os.path.isfile(kmspony): if not os.path.isfile(kmspony):
## Protokmsponies are uncolourful ttyponies ## kmspony directory
protokmsponies = cachedir + '/protokmsponies/' kmsponydir = kmspony[:kmspony.rindex('/')]
protokmspony = (protokmsponies + pony).replace('//', '/')
protokmsponydir = protokmspony[:protokmspony.rindex('/')]
kmsponydir = kmspony[: kmspony.rindex('/')]
## Change file names to be shell friendly ## Change file names to be shell friendly
_protokmspony = '\'' + protokmspony.replace('\'', '\'\\\'\'') + '\'' _kmspony = '\'' + kmspony.replace('\'', '\'\\\'\'') + '\''
_kmspony = '\'' + kmspony.replace('\'', '\'\\\'\'') + '\'' _pony = '\'' + pony.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()
## Create kmspony ## Create kmspony
if not os.path.isdir(kmsponydir): if not os.path.isdir(kmsponydir):
os.makedirs(kmsponydir) os.makedirs(kmsponydir)
if shared: if shared:
Popen('chmod -R 6777 -- ' + _cachedir, shell=True).wait() Popen('chmod -R 6777 -- ' + _cachedir, shell=True).wait()
if not os.system('tty2colourfultty -p ' + palette + ' < ' + _protokmspony + ' > ' + _kmspony) == 0: ponytoolcmd = 'ponytoolcmd --import ponysay --file %s --export ponysay --file %s --platform linux ' +
sys.stderr.write('Unable to run tty2colourfultty successfully, you need util-say for KMS support\n') '--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) exit(1)
if shared: if shared:
Popen('chmod 666 -- ' + _kmspony, shell=True).wait() Popen('chmod 666 -- ' + _kmspony, shell=True).wait()
@ -1882,7 +1869,7 @@ class Backend():
printinfo(info) printinfo(info)
self.pony = self.pony[infoend:] self.pony = self.pony[infoend:]
elif self.infolevel == 2: 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: elif self.infolevel == 1:
self.pony = 'There is not metadata for this pony file' self.pony = 'There is not metadata for this pony file'
self.pony = self.mode + self.pony self.pony = self.mode + self.pony