/usr/bin/lit2epub is in epub-utils 0.2.2-4ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #!/bin/sh
# Uses clit to convert .lit files to valid epub
# known issues: created metadata uses the old spec
check_tool()
{
var=$1
tool=$2
toolpath=$(which $tool 2>/dev/null)
if [ "$?" != 0 ]; then
echo "Cannot find $tool, please make sure it is in your PATH"
exit 1
fi
eval "$var=$toolpath"
}
check_tool CLIT clit
check_tool ZIP zip
LIT=$1
if [ "x$LIT" = "x" ]; then
echo "$0 <file.lit> [file.epub]"
exit 1;
fi
if [ "x$2" = "x" ]; then
EPUB=$(echo $1 | sed -e 's/\.lit$/.epub/')
else
EPUB=$2
fi
MKTEMP=$(which mktemp)
if [ "$?" != 0 ]; then
if [ ! -e /tmp/epub ]; then
mkdir /tmp/epub
else
echo "/tmp/epub already exists please erase it first"
exit 1
fi
else
TEMPDIR=$($MKTEMP -d)
fi
WD=$(pwd)
IFS='
'
$CLIT $LIT $TEMPDIR/OEBPS/
find "$TEMPDIR"/OEBPS/ -name "*.opf" -exec mv {} "$TEMPDIR"/OEBPS/content.opf \;
unset $IFS
mkdir "$TEMPDIR/META-INF"
cat << EOF > "$TEMPDIR/META-INF/container.xml"
<?xml version="1.0"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
EOF
printf 'application/epub+zip' > "$TEMPDIR"/mimetype
IFS='
'
cd "$TEMPDIR"
$ZIP -0 -m "$WD/$EPUB" mimetype
$ZIP -rg "$WD/$EPUB" *
cd $WD
unset $IFS
rm -rf $TEMPDIR
|