Skip to content

Instantly share code, notes, and snippets.

@fauxsaurus
Created September 23, 2025 16:09
Show Gist options
  • Save fauxsaurus/16503b718a76c91138afd1437e84f5f6 to your computer and use it in GitHub Desktop.
Save fauxsaurus/16503b718a76c91138afd1437e84f5f6 to your computer and use it in GitHub Desktop.
A short shell script to build an epub file.
#!/bin/bash
cd ./src/epub
# remove old file (if it exists)
rm -f ../../build/ebook.epub
# create an uncompressed file with no metadata as the first entry
zip -0X ../../build/ebook.epub mimetype
# recursively compress all files in directory (while omitting the mimetype file)
zip -rX -u ../../build/ebook.epub ./ -x "mimetype"
# validate epub
# download: epubCheck: https://www.w3.org/publishing/epubcheck/ unzip to scripts/epubcheck-5.2.1
# install: snap install openjdk, restart terminal
openjdk.java -jar ../../scripts/epubcheck-5.2.1/epubcheck.jar ../../build/ebook.epub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment