All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: printing-architecture@lists.linux-foundation.org
Subject: [Printing-architecture] [PATCH] braille: Checking for tool presence
Date: Tue, 19 Jan 2016 23:09:29 +0100	[thread overview]
Message-ID: <20160119220929.GR3427@var.home> (raw)

[-- Attachment #1: Type: text/plain, Size: 192 bytes --]

Hello,

The attached patch makes the braille support check for tool presence, so
that cups nicely tells the user what is missing, allowing distributions
to relax package dependencies.

Samuel

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 4381 bytes --]

=== modified file 'filter/braille/filters/cups-braille.sh.in'
--- filter/braille/filters/cups-braille.sh.in	2015-12-21 13:51:08 +0000
+++ filter/braille/filters/cups-braille.sh.in	2016-01-19 21:51:03 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2015-2016 Samuel Thibault <samuel.thibault@ens-lyon.org>
+# Copyright (c) 2015-2016 Samuel Thibault <samuel.thibault@ens-lyon.org>
 # 
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -228,3 +228,17 @@ echo "DEBUG: Table4 $LIBLOUIS4" >&2
 [ "$LIBLOUIS2" != None ] && LIBLOUIS_TABLES="${LIBLOUIS_TABLES:+$LIBLOUIS_TABLES,}$LIBLOUIS2"
 [ "$LIBLOUIS3" != None ] && LIBLOUIS_TABLES="${LIBLOUIS_TABLES:+$LIBLOUIS_TABLES,}$LIBLOUIS3"
 [ "$LIBLOUIS4" != None ] && LIBLOUIS_TABLES="${LIBLOUIS_TABLES:+$LIBLOUIS_TABLES,}$LIBLOUIS4"
+
+#
+# Checking for presence of tools
+#
+checkTool() {
+  TOOL=$1
+  PACKAGE=$2
+  USE=$3
+  if ! type $TOOL
+  then
+    printf "ERROR: The $PACKAGE package is required for $USE\n" >&2
+    exit 1
+  fi
+}

=== modified file 'filter/braille/filters/imagetobrf.in'
--- filter/braille/filters/imagetobrf.in	2015-12-21 13:54:30 +0000
+++ filter/braille/filters/imagetobrf.in	2016-01-19 22:01:01 +0000
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 #
-# Copyright (c) 2015-2016 Samuel Thibault <samuel.thibault@ens-lyon.org>
+# Copyright (c) 2015-2016 Samuel Thibault <samuel.thibault@ens-lyon.org>
 # 
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -42,6 +42,8 @@ esac
 
 . @CUPS_DATADIR@/braille/cups-braille.sh
 
+checkTool convert imagemagick "embossing images"
+
 NEGATE=$(getOption Negate)
 case "$NEGATE" in
   True)  NEGATE=-negate ;;

=== modified file 'filter/braille/filters/texttobrf.in'
--- filter/braille/filters/texttobrf.in	2015-12-21 13:51:08 +0000
+++ filter/braille/filters/texttobrf.in	2016-01-19 21:54:10 +0000
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 #
-# Copyright (c) 2015-2016 Samuel Thibault <samuel.thibault@ens-lyon.org>
+# Copyright (c) 2015-2016 Samuel Thibault <samuel.thibault@ens-lyon.org>
 # 
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -57,6 +57,8 @@ echo "DEBUG: Input content type: $CONTEN
 #  Selected braille table
 if [ -n "$LIBLOUIS_TABLES" ]
 then
+  checkTool file2brl liblouis "translating braille"
+
   #  Tool to be used for the conversion
   # FIXME CONTENT_TYPE contains original document, not document passed as parameter ?!!
   case $CONTENT_TYPE in
@@ -75,18 +77,22 @@ then
     application/msword)
       LIBLOUIS_TOOL="file2brl"
       CONVERT="antiword -x db /dev/stdin"
+      checkTool antiword antiword "translating MS-Word doc files"
       ;;
     application/vnd.openxmlformats-officedocument.wordprocessingml.document)
       LIBLOUIS_TOOL="file2brl"
       CONVERT="docx2txt"
+      checkTool docx2txt docx2txt "translating MS-Word docx files"
       ;;
     text/rtf|application/rtf)
       LIBLOUIS_TOOL="file2brl"
       CONVERT="rtf2xml /dev/stdin"
+      checkTool rtf2xml rtf2xml "translating RTF files"
       ;;
     application/pdf)
       LIBLOUIS_TOOL="file2brl -p"
       CONVERT="pdftotext -raw /dev/stdin /dev/stdout"
+      checkTool pdftotext poppler "translating PDF files"
       ;;
     *)
       echo "ERROR: unsupported content type $CONTENT_TYPE" >&2
@@ -107,18 +113,23 @@ else
     text/html)
       CONVERT=""
       RENDER_CALL="lynx -width=$TEXTWIDTH -dump -stdin"
+      checkTool lynx lynx "translating html files"
       ;;
     application/msword)
       CONVERT="antiword /dev/stdin"
+      checkTool antiword antiword "translating MS-Word doc files"
       ;;
     application/vnd.openxmlformats-officedocument.wordprocessingml.document)
       CONVERT="docx2txt"
+      checkTool docx2txt docx2txt "translating MS-Word docx files"
       ;;
     text/rtf|application/rtf)
       CONVERT="rtf2txt /dev/stdin"
+      checkTool rtf2txt rtf2txt "translating RTF files"
       ;;
     application/pdf)
       CONVERT="pdftotext -raw /dev/stdin /dev/stdout"
+      checkTool pdftotext poppler "translating PDF files"
       ;;
     *)
       echo "ERROR: unsupported content type $CONTENT_TYPE" >&2


             reply	other threads:[~2016-01-19 22:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19 22:09 Samuel Thibault [this message]
2016-01-19 22:49 ` [Printing-architecture] [PATCH] braille: Checking for tool presence Till Kamppeter
2016-01-20 23:28   ` Samuel Thibault
2016-01-21  1:17     ` Till Kamppeter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160119220929.GR3427@var.home \
    --to=samuel.thibault@ens-lyon.org \
    --cc=printing-architecture@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.